MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ioctl

Method ioctl

source/kernel/devs/devdsp.cpp:71–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71U32 DevDsp::ioctl(KThread* thread, U32 request) {
72 U32 len = (request >> 16) & 0x3FFF;
73 CPU* cpu = thread->cpu;
74 KMemory* memory = thread->memory;
75
76 //BOOL read = request & 0x40000000;
77 bool write = (request & 0x80000000)!=0;
78
79 switch (request & 0xFFFF) {
80 case 0x5000: // SNDCTL_DSP_RESET
81 return 0;
82 case 0x5002: // SNDCTL_DSP_SPEED
83 if (len!=4) {
84 kpanic("SNDCTL_DSP_SPEED was expecting a len of 4");
85 }
86 this->freq = memory->readd(IOCTL_ARG1);
87 if (write)
88 memory->writed(IOCTL_ARG1, this->freq);
89 return 0;
90 case 0x5003: { // SNDCTL_DSP_STEREO
91 if (len!=4) {
92 kpanic("SNDCTL_DSP_STEREO was expecting a len of 4");
93 }
94 U32 fmt = memory->readd(IOCTL_ARG1);
95 if (fmt != (U32)(this->channels - 1)) {
96 this->audio->closeAudio();
97 }
98 if (fmt == 0) {
99 this->channels = 1;
100 } else if (fmt == 1) {
101 this->channels = 2;
102 } else {
103 kpanic_fmt("SNDCTL_DSP_STEREO wasn't expecting a value of %d", fmt);
104 }
105 if (write)
106 memory->writed(IOCTL_ARG1, this->channels - 1);
107 return 0;
108 }
109 case 0x5005: { // SNDCTL_DSP_SETFMT
110 if (len!=4) {
111 kpanic("SNDCTL_DSP_SETFMT was expecting a len of 4");
112 }
113 U32 fmt = memory->readd(IOCTL_ARG1);
114 if (fmt != AFMT_QUERY && fmt != this->format) {
115 this->audio->closeAudio();
116 }
117 switch (fmt) {
118 case AFMT_QUERY:
119 break;
120 case AFMT_MU_LAW:
121 case AFMT_A_LAW:
122 case AFMT_IMA_ADPCM:
123 case AFMT_U8:
124 this->format = AFMT_U8;
125 break;
126 case AFMT_S16_LE:
127 this->format = AFMT_S16_LE;
128 break;

Callers

nothing calls this directly

Calls 9

kpanicFunction · 0.85
kpanic_fmtFunction · 0.85
klogFunction · 0.85
closeAudioMethod · 0.80
getBufferCapacityMethod · 0.80
getFragmentSizeMethod · 0.80
strcpyMethod · 0.80
readdMethod · 0.45
writedMethod · 0.45

Tested by

no test coverage detected