1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
|
/* Marc.Hoffman@analog.com
This is a pss driver.
it is based on Greg.Yukna@analog.com @file{host} for DOG
Unfortunately I can't distribute the ld file needed to
make the pss card to emulate the SB stuff.
I have provided a simple interface to the PSS unlike the
DOG version. to download a new algorithm just cat it to
/dev/pss 14,9.
You really need to rebuild this with the synth.ld file
get the <synth>.ld from your dos directory maybe
voyetra\dsp001.ld
ld2inc < synth.ld > synth-ld.h
(make config does the same).
rebuild
Okay if you blow things away no problem just
main(){ioctl(open("/dev/pss"),SNDCTL_PSS_RESET)};
and everything will be okay.
At first I was going to worry about applications that were using
the sound stuff and disallow the use of /dev/pss. But for
now I figured it doesn't matter.
And if you change algos all the other applications running die off
due to DMA problems. Yeah just pull the plug and watch em die.
If the registers get hosed
main(){ioctl(open("/dev/pss"),SNDCTL_PSS_SETUP_REGISTERS)};
Probably everything else can be done via mmap
Oh if you want to develop code for the ADSP-21xx or Program the
1848 just send me mail and I will hook you up.
marc.hoffman@analog.com
*/
#include "sound_config.h"
#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_PSS)
#ifndef PSS_MSS_BASE
#define PSS_MSS_BASE 0
#endif
#ifndef PSS_MPU_BASE
#define PSS_MPU_BASE 0
#endif
#ifndef PSS_MPU_IRQ
#define PSS_MPU_IRQ 0
#endif
#undef DEB
#define DEB(x) x
#include "pss.h"
static int pss_ok = 0;
static int sb_ok = 0;
static int pss_base;
static int pss_irq;
static int pss_dma;
static int gamePort = 0;
static int sbInt;
static int cdPol;
static int cdAddr = 0; /* 0x340; */
static int cdInt = 10;
/* Define these by hand in local.h */
static int wssAddr = PSS_MSS_BASE;
static int midiAddr = PSS_MPU_BASE;
static int midiInt = PSS_MPU_IRQ;
static int SoundPortAddress;
static int SoundPortData;
static int speaker = 1;
static struct pss_speaker default_speaker =
{0, 0, 0, PSS_STEREO};
DEFINE_WAIT_QUEUE (pss_sleeper, pss_sleep_flag);
#include "synth-ld.h"
static int pss_download_boot (unsigned char *block, int size);
static int pss_reset_dsp (void);
static inline void
pss_outpw (unsigned short port, unsigned short value)
{
__asm__ __volatile__ ("outw %w0, %w1"
: /* no outputs */
:"a" (value), "d" (port));
}
static inline unsigned int
pss_inpw (unsigned short port)
{
unsigned int _v;
__asm__ __volatile__ ("inw %w1,%w0"
:"=a" (_v):"d" (port), "0" (0));
return _v;
}
static void
PSS_write (int data)
{
int i, limit;
limit = GET_TIME () + 10; /* The timeout is 0.1 seconds */
/*
* Note! the i<5000000 is an emergency exit. The dsp_command() is sometimes
* called while interrupts are disabled. This means that the timer is
* disabled also. However the timeout situation is a abnormal condition.
* Normally the DSP should be ready to accept commands after just couple of
* loops.
*/
for (i = 0; i < 5000000 && GET_TIME () < limit; i++)
{
if (pss_inpw (pss_base + PSS_STATUS) & PSS_WRITE_EMPTY)
{
pss_outpw (pss_base + PSS_DATA, data);
return;
}
}
printk ("PSS: DSP Command (%04x) Timeout.\n", data);
printk ("IRQ conflict???\n");
}
static void
pss_setaddr (int addr, int configAddr)
{
int val;
val = pss_inpw (configAddr);
val &= ADDR_MASK;
val |= (addr << 4);
pss_outpw (configAddr, val);
}
/*_____ pss_checkint
This function tests an interrupt number to see if
it is available. It takes the interrupt button
as it's argument and returns TRUE if the interrupt
is ok.
*/
static int
pss_checkint (int intNum)
{
int val;
int ret;
int i;
/*_____ Set the interrupt bits */
switch (intNum)
{
case 3:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_3_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
case 5:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_5_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
case 7:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_7_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
case 9:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_9_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
case 10:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_10_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
case 11:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_11_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
case 12:
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_MASK;
val |= INT_12_BITS;
pss_outpw (pss_base + PSS_CONFIG, val);
break;
default:
printk ("unknown interrupt selected. %d\n", intNum);
return 0;
}
/*_____ Set the interrupt test bit */
val = pss_inpw (pss_base + PSS_CONFIG);
val |= INT_TEST_BIT;
pss_outpw (pss_base + PSS_CONFIG, val);
/*_____ Check if the interrupt is in use */
/*_____ Do it a few times in case there is a delay */
ret = 0;
for (i = 0; i < 5; i++)
{
val = pss_inpw (pss_base + PSS_CONFIG);
if (val & INT_TEST_PASS)
{
ret = 1;
break;
}
}
/*_____ Clear the Test bit and the interrupt bits */
val = pss_inpw (pss_base + PSS_CONFIG);
val &= INT_TEST_BIT_MASK;
val &= INT_MASK;
pss_outpw (pss_base + PSS_CONFIG, val);
return (ret);
}
/*____ pss_setint
This function sets the correct bits in the
configuration register to
enable the chosen interrupt.
*/
static void
pss_setint (int intNum, int configAddress)
{
int val;
switch (intNum)
{
case 0:
val = pss_inpw (configAddress);
val &= INT_MASK;
pss_outpw (configAddress, val);
break;
case 3:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_3_BITS;
pss_outpw (configAddress, val);
break;
case 5:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_5_BITS;
pss_outpw (configAddress, val);
break;
case 7:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_7_BITS;
pss_outpw (configAddress, val);
break;
case 9:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_9_BITS;
pss_outpw (configAddress, val);
break;
case 10:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_10_BITS;
pss_outpw (configAddress, val);
break;
case 11:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_11_BITS;
pss_outpw (configAddress, val);
break;
case 12:
val = pss_inpw (configAddress);
val &= INT_MASK;
val |= INT_12_BITS;
pss_outpw (configAddress, val);
break;
default:
printk ("pss_setint unknown int\n");
}
}
/*____ pss_setsbint
This function sets the correct bits in the
SoundBlaster configuration PSS register to
enable the chosen interrupt.
It takes a interrupt button as its argument.
*/
static void
pss_setsbint (int intNum)
{
int val;
int sbConfigAddress;
sbConfigAddress = pss_base + SB_CONFIG;
switch (intNum)
{
case 3:
val = pss_inpw (sbConfigAddress);
val &= INT_MASK;
val |= INT_3_BITS;
pss_outpw (sbConfigAddress, val);
break;
case 5:
val = pss_inpw (sbConfigAddress);
val &= INT_MASK;
val |= INT_5_BITS;
pss_outpw (sbConfigAddress, val);
break;
case 7:
val = pss_inpw (sbConfigAddress);
val &= INT_MASK;
val |= INT_7_BITS;
pss_outpw (sbConfigAddress, val);
break;
default:
printk ("pss_setsbint: unknown_int\n");
}
}
/*____ pss_setsbdma
This function sets the correct bits in the
SoundBlaster configuration PSS register to
enable the chosen DMA channel.
It takes a DMA button as its argument.
*/
static void
pss_setsbdma (int dmaNum)
{
int val;
int sbConfigAddress;
sbConfigAddress = pss_base + SB_CONFIG;
switch (dmaNum)
{
case 1:
val = pss_inpw (sbConfigAddress);
val &= DMA_MASK;
val |= DMA_1_BITS;
pss_outpw (sbConfigAddress, val);
break;
default:
printk ("Personal Sound System ERROR! pss_setsbdma: unknown_dma\n");
}
}
/*____ pss_setwssdma
This function sets the correct bits in the
WSS configuration PSS register to
enable the chosen DMA channel.
It takes a DMA button as its argument.
*/
static void
pss_setwssdma (int dmaNum)
{
int val;
int wssConfigAddress;
wssConfigAddress = pss_base + PSS_WSS_CONFIG;
switch (dmaNum)
{
case 0:
val = pss_inpw (wssConfigAddress);
val &= DMA_MASK;
val |= DMA_0_BITS;
pss_outpw (wssConfigAddress, val);
break;
case 1:
val = pss_inpw (wssConfigAddress);
val &= DMA_MASK;
val |= DMA_1_BITS;
pss_outpw (wssConfigAddress, val);
break;
case 3:
val = pss_inpw (wssConfigAddress);
val &= DMA_MASK;
val |= DMA_3_BITS;
pss_outpw (wssConfigAddress, val);
break;
default:
printk ("Personal Sound System ERROR! pss_setwssdma: unknown_dma\n");
}
}
/*_____ SetSpeakerOut
This function sets the Volume, Bass, Treble and Mode of
the speaker out channel.
*/
void
pss_setspeaker (struct pss_speaker *spk)
{
PSS_write (SET_MASTER_COMMAND);
if (spk->volume > PHILLIPS_VOL_MAX)
spk->volume = PHILLIPS_VOL_MAX;
if (spk->volume < PHILLIPS_VOL_MIN)
spk->volume = PHILLIPS_VOL_MIN;
PSS_write (MASTER_VOLUME_LEFT
| (PHILLIPS_VOL_CONSTANT + spk->volume / PHILLIPS_VOL_STEP));
PSS_write (SET_MASTER_COMMAND);
PSS_write (MASTER_VOLUME_RIGHT
| (PHILLIPS_VOL_CONSTANT + spk->volume / PHILLIPS_VOL_STEP));
if (spk->bass > PHILLIPS_BASS_MAX)
spk->bass = PHILLIPS_BASS_MAX;
if (spk->bass < PHILLIPS_BASS_MIN)
spk->bass = PHILLIPS_BASS_MIN;
PSS_write (SET_MASTER_COMMAND);
PSS_write (MASTER_BASS
| (PHILLIPS_BASS_CONSTANT + spk->bass / PHILLIPS_BASS_STEP));
if (spk->treb > PHILLIPS_TREBLE_MAX)
spk->treb = PHILLIPS_TREBLE_MAX;
if (spk->treb < PHILLIPS_TREBLE_MIN)
spk->treb = PHILLIPS_TREBLE_MIN;
PSS_write (SET_MASTER_COMMAND);
PSS_write (MASTER_TREBLE
| (PHILLIPS_TREBLE_CONSTANT + spk->treb / PHILLIPS_TREBLE_STEP));
PSS_write (SET_MASTER_COMMAND);
PSS_write (MASTER_SWITCH | spk->mode);
}
static void
pss_init1848 (void)
{
/*_____ Wait for 1848 to init */
while (INB (SoundPortAddress) & SP_IN_INIT);
/*_____ Wait for 1848 to autocal */
OUTB (SoundPortAddress, SP_TEST_AND_INIT);
while (INB (SoundPortData) & AUTO_CAL_IN_PROG);
}
static int
pss_configure_registers_to_look_like_sb (void)
{
pss_setaddr (wssAddr, pss_base + PSS_WSS_CONFIG);
SoundPortAddress = wssAddr + 4;
SoundPortData = wssAddr + 5;
DEB (printk ("Turning Game Port %s.\n",
gamePort ? "On" : "Off"));
/*_____ Turn on the Game port */
if (gamePort)
pss_outpw (pss_base + PSS_STATUS,
pss_inpw (pss_base + PSS_STATUS) | GAME_BIT);
else
pss_outpw (pss_base + PSS_STATUS,
pss_inpw (pss_base + PSS_STATUS) & GAME_BIT_MASK);
DEB (printk ("PSS attaching base %x irq %d dma %d\n",
pss_base, pss_irq, pss_dma));
/* Check if sb is enabled if it is check the interrupt */
pss_outpw (pss_base + SB_CONFIG, 0);
if (pss_irq != 0)
{
DEB (printk ("PSS Emulating Sound Blaster ADDR %04x\n", pss_base));
DEB (printk ("PSS SBC: attaching base %x irq %d dma %d\n",
SBC_BASE, SBC_IRQ, SBC_DMA));
if (pss_checkint (SBC_IRQ) == 0)
{
printk ("PSS! attach: int_error\n");
return 0;
}
pss_setsbint (SBC_IRQ);
pss_setsbdma (SBC_DMA);
sb_ok = 1;
}
else
{
sb_ok = 0;
printk ("PSS: sound blaster error init\n");
}
/* Check if cd is enabled if it is check the interrupt */
pss_outpw (pss_base + CD_CONFIG, 0);
if (cdAddr != 0)
{
DEB (printk ("PSS:CD drive %x irq: %d", cdAddr, cdInt));
if (cdInt != 0)
{
if (pss_checkint (cdInt) == 0)
{
printk ("Can't allocate cdInt %d\n", cdInt);
}
else
{
int val;
printk ("CD poll ");
pss_setaddr (cdAddr, pss_base + CD_CONFIG);
pss_setint (cdInt, pss_base + CD_CONFIG);
/* set the correct bit in the
configuration register to
set the irq polarity for the CD-Rom.
NOTE: This bit is in the address config
field, It must be configured after setting
the CD-ROM ADDRESS!!! */
val = pss_inpw (pss_base + CD_CONFIG);
pss_outpw (pss_base + CD_CONFIG, 0);
val &= CD_POL_MASK;
if (cdPol)
val |= CD_POL_BIT;
pss_outpw (pss_base + CD_CONFIG, val);
}
}
}
/* Check if midi is enabled if it is check the interrupt */
pss_outpw (pss_base + MIDI_CONFIG, 0);
if (midiAddr != 0)
{
printk ("midi init %x %d\n", midiAddr, midiInt);
if (pss_checkint (midiInt) == 0)
{
printk ("midi init int error %x %d\n", midiAddr, midiInt);
}
else
{
pss_setaddr (midiAddr, pss_base + MIDI_CONFIG);
pss_setint (midiInt, pss_base + MIDI_CONFIG);
}
}
return 1;
}
long
attach_pss (long mem_start, struct address_info *hw_config)
{
if (pss_ok)
{
if (hw_config)
{
printk (" <PSS-ESC614>");
}
return mem_start;
}
pss_ok = 1;
if (pss_configure_registers_to_look_like_sb () == 0)
return mem_start;
if (sb_ok)
if (pss_synthLen
&& pss_download_boot (pss_synth, pss_synthLen))
{
if (speaker)
pss_setspeaker (&default_speaker);
pss_ok = 1;
}
else
pss_reset_dsp ();
return mem_start;
}
int
probe_pss (struct address_info *hw_config)
{
pss_base = hw_config->io_base;
pss_irq = hw_config->irq;
pss_dma = hw_config->dma;
if ((pss_inpw (pss_base + 4) & 0xff00) == 0x4500)
{
attach_pss (0, hw_config);
return 1;
}
printk (" fail base %x irq %d dma %d\n", pss_base, pss_irq, pss_dma);
return 0;
}
static int
pss_reattach (void)
{
pss_ok = 0;
attach_pss (0, 0);
return 1;
}
static int
pss_reset_dsp ()
{
unsigned long i, limit = GET_TIME () + 10;
pss_outpw (pss_base + PSS_CONTROL, 0x2000);
for (i = 0; i < 32768 && GET_TIME () < limit; i++)
pss_inpw (pss_base + PSS_CONTROL);
pss_outpw (pss_base + PSS_CONTROL, 0x0000);
return 1;
}
static int
pss_download_boot (unsigned char *block, int size)
{
int i, limit, val, count;
printk ("PSS: downloading boot code synth.ld... ");
/*_____ Warn DSP software that a boot is coming */
pss_outpw (pss_base + PSS_DATA, 0x00fe);
limit = GET_TIME () + 10;
for (i = 0; i < 32768 && GET_TIME () < limit; i++)
if (pss_inpw (pss_base + PSS_DATA) == 0x5500)
break;
pss_outpw (pss_base + PSS_DATA, *block++);
pss_reset_dsp ();
printk ("start ");
count = 1;
while (1)
{
int j;
for (j = 0; j < 327670; j++)
{
/*_____ Wait for BG to appear */
if (pss_inpw (pss_base + PSS_STATUS) & PSS_FLAG3)
break;
}
if (j == 327670)
{
/* It's ok we timed out when the file was empty */
if (count >= size)
break;
else
{
printk ("\nPSS: DownLoad timeout problems, byte %d=%d\n",
count, size);
return 0;
}
}
/*_____ Send the next byte */
pss_outpw (pss_base + PSS_DATA, *block++);
count++;
}
/*_____ Why */
pss_outpw (pss_base + PSS_DATA, 0);
limit = GET_TIME () + 10;
for (i = 0; i < 32768 && GET_TIME () < limit; i++)
val = pss_inpw (pss_base + PSS_STATUS);
printk ("downloaded\n");
limit = GET_TIME () + 10;
for (i = 0; i < 32768 && GET_TIME () < limit; i++)
{
val = pss_inpw (pss_base + PSS_STATUS);
if (val & 0x4000)
break;
}
/* now read the version */
for (i = 0; i < 32000; i++)
{
val = pss_inpw (pss_base + PSS_STATUS_REG);
if (val & PSS_READ_FULL)
break;
}
if (i == 32000)
return 0;
val = pss_inpw (pss_base + PSS_DATA_REG);
return 1;
}
/* The following is a simple device driver for the pss.
All I really care about is communication to and from the pss.
The ability to reinitialize the <synth.ld> This will be
default when release is chosen.
SNDCTL_PSS_DOWNLOAD:
Okay we need to creat new minor numbers for the
DOWNLOAD functionality.
14,0x19 -- /dev/pssld where a read operation would output the
current ld to user space
where a write operation would effectively
download a new ld.
14,0x09 -- /dev/psecho would open up a communication path to the
esc614 asic. Given the ability to send
messages to the asic and receive messages too.
All messages would get read and written in the
same manner. It would be up to the application
and the ld to maintain a relationship
of what the messages mean.
for this device we need to implement select. */
#define CODE_BUFFER_LEN (64*1024)
static char *code_buffer;
static int code_length;
static int lock_pss = 0;
int
pss_open (int dev, struct fileinfo *file)
{
int mode;
DEB (printk ("pss_open\n"));
if (pss_ok == 0)
return RET_ERROR (EIO);
if (lock_pss)
return 0;
lock_pss = 1;
dev = dev >> 4;
mode = file->mode & O_ACCMODE;
if (mode == O_WRONLY)
{
printk ("pss-open for WRONLY\n");
code_length = 0;
}
RESET_WAIT_QUEUE (pss_sleeper, pss_sleep_flag);
return 1;
}
void
pss_release (int dev, struct fileinfo *file)
{
int mode;
DEB (printk ("pss_release\n"));
if (pss_ok == 0)
return RET_ERROR (EIO);
dev = dev >> 4;
mode = file->mode & O_ACCMODE;
if (mode == O_WRONLY && code_length > 0)
{
#ifdef linux
/* This just allows interrupts while the conversion is running */
__asm__ ("sti");
#endif
if (!pss_download_boot (code_buffer, code_length))
{
pss_reattach ();
}
}
lock_pss = 0;
}
int
pss_read (int dev, struct fileinfo *file, snd_rw_buf * buf, int count)
{
int c, p;
DEB (printk ("pss_read\n"));
if (pss_ok == 0)
return RET_ERROR (EIO);
dev = dev >> 4;
p = 0;
c = count;
return count - c;
}
int
pss_write (int dev, struct fileinfo *file, snd_rw_buf * buf, int count)
{
DEB (printk ("pss_write\n"));
if (pss_ok == 0)
return RET_ERROR (EIO);
dev = dev >> 4;
if (count) /* Flush output */
{
COPY_FROM_USER (&code_buffer[code_length], buf, 0, count);
code_length += count;
}
return count;
}
int
pss_ioctl (int dev, struct fileinfo *file,
unsigned int cmd, unsigned int arg)
{
DEB (printk ("pss_ioctl dev=%d cmd=%x\n", dev, cmd));
if (pss_ok == 0)
return RET_ERROR (EIO);
dev = dev >> 4;
switch (cmd)
{
case SNDCTL_PSS_RESET:
pss_reattach ();
return 1;
case SNDCTL_PSS_SETUP_REGISTERS:
pss_configure_registers_to_look_like_sb ();
return 1;
case SNDCTL_PSS_SPEAKER:
{
struct pss_speaker params;
COPY_FROM_USER (¶ms, (char *) arg, 0, sizeof (struct pss_speaker));
pss_setspeaker (¶ms);
return 0;
}
default:
return RET_ERROR (EIO);
}
}
/* This is going to be used to implement
waiting on messages sent from the DSP and to the
DSP when communication is used via the pss directly.
We need to find out if the pss can generate a different
interrupt other than the one it has been setup for.
This way we can carry on a conversation with the pss
on a separate channel. This would be useful for debugging. */
pss_select (int dev, struct fileinfo * file, int sel_type, select_table * wait)
{
return 0;
if (pss_ok == 0)
return RET_ERROR (EIO);
dev = dev >> 4;
switch (sel_type)
{
case SEL_IN:
select_wait (&pss_sleeper, wait);
return 0;
break;
case SEL_OUT:
select_wait (&pss_sleeper, wait);
return 0;
break;
case SEL_EX:
return 0;
}
return 0;
}
long
pss_init (long mem_start)
{
DEB (printk ("pss_init\n"));
if (pss_ok)
{
code_buffer = mem_start;
mem_start += CODE_BUFFER_LEN;
}
return mem_start;
}
#endif
|