Changeset 1e92bc3 in mainline for uspace/drv/audio/hdaudio/codec.c
- Timestamp:
- 2014-08-26T15:32:19Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9bae8b8
- Parents:
- c67195c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/codec.c
rc67195c r1e92bc3 156 156 } 157 157 158 static int hda_set_out_amp_max(hda_codec_t *codec, uint8_t aw) 159 { 160 uint32_t ampcaps; 161 uint32_t gmleft, gmright; 162 uint32_t offset; 163 int rc; 164 165 rc = hda_get_parameter(codec, aw, 166 hda_out_amp_caps, &caps); 167 if (rc != EOK) 168 goto error; 169 170 rc = hda_get_amp_gain_mute(codec, aw, 0x8000, &gmleft); 171 if (rc != EOK) 172 goto error; 173 174 rc = hda_get_amp_gain_mute(codec, aw, 0xc000, &gmright); 175 if (rc != EOK) 176 goto error; 177 178 ddf_msg(LVL_NOTE, "out amp caps 0x%x " 179 "gain/mute: L:0x%x R:0x%x", 180 ampcaps, gmleft, gmright); 181 offset = ampcaps & 0x7f; 182 183 rc = hda_set_amp_gain_mute(codec, aw, 0xb000 + offset); 184 if (rc != EOK) 185 goto error; 186 187 return EOK; 188 error: 189 return rc; 190 } 191 192 static int hda_set_in_amp_max(hda_codec_t *codec, uint8_t aw) 193 { 194 uint32_t ampcaps; 195 uint32_t gmleft, gmright; 196 uint32_t offset; 197 int i; 198 int rc; 199 200 rc = hda_get_parameter(codec, aw, 201 hda_out_amp_caps, &caps); 202 if (rc != EOK) 203 goto error; 204 205 ddf_msg(LVL_NOTE, "in amp caps 0x%x ", ampcaps); 206 offset = ampcaps & 0x7f; 207 208 for (i = 0; i < 15; i++) { 209 rc = hda_get_amp_gain_mute(codec, aw, 0x0000 + i, &gmleft); 210 if (rc != EOK) 211 goto error; 212 213 rc = hda_get_amp_gain_mute(codec, aw, 0x4000 + i, &gmright); 214 if (rc != EOK) 215 goto error; 216 217 ddf_msg(LVL_NOTE, "in:%d gain/mute: L:0x%x R:0x%x", 218 i, gmleft, gmright); 219 220 rc = hda_set_amp_gain_mute(codec, aw, 0x7000 + (i << 8) + offset); 221 if (rc != EOK) 222 goto error; 223 } 224 225 return EOK; 226 error: 227 return rc; 228 } 229 158 230 hda_codec_t *hda_codec_init(hda_t *hda, uint8_t address) 159 231 { … … 218 290 } else if (awtype == awt_audio_output) { 219 291 codec->out_aw = aw; 292 codec->out_aw_list[codec->out_aw_num++] = aw; 220 293 } 221 294 222 if ((awcaps & BIT_V(uint32_t, awc_out_amp_present)) != 0) { 223 uint32_t ampcaps; 224 uint32_t gmleft, gmright; 225 226 rc = hda_get_parameter(codec, aw, 227 hda_out_amp_caps, &caps); 228 if (rc != EOK) 229 goto error; 230 231 rc = hda_get_amp_gain_mute(codec, aw, 0x8000, &gmleft); 232 if (rc != EOK) 233 goto error; 234 235 rc = hda_get_amp_gain_mute(codec, aw, 0xc000, &gmright); 236 if (rc != EOK) 237 goto error; 238 239 ddf_msg(LVL_NOTE, "out amp caps 0x%x " 240 "gain/mute: L:0x%x R:0x%x", 241 ampcaps, gmleft, gmright); 242 243 rc = hda_set_amp_gain_mute(codec, aw, 0xb04a); 244 if (rc != EOK) 245 goto error; 246 } 295 if ((awcaps & BIT_V(uint32_t, awc_out_amp_present)) != 0) 296 hda_set_out_amp_max(codec, aw); 297 298 if ((awcaps & BIT_V(uint32_t, awc_in_amp_present)) != 0) 299 hda_set_in_amp_max(codec, aw); 247 300 } 248 301 } … … 275 328 { 276 329 int rc; 277 278 /* XXX Choose appropriate parameters */ 279 uint32_t fmt; 280 /* 48 kHz, 16-bits, 1 channel */ 281 fmt = (fmt_base_44khz << fmt_base) | (fmt_bits_16 << fmt_bits_l); 282 283 /* Configure converter */ 284 285 ddf_msg(LVL_NOTE, "Configure converter format"); 286 rc = hda_set_converter_fmt(codec, codec->out_aw, fmt); 287 if (rc != EOK) 288 goto error; 289 290 ddf_msg(LVL_NOTE, "Configure converter stream, channel"); 291 rc = hda_set_converter_ctl(codec, codec->out_aw, sid, 0); 292 if (rc != EOK) 293 goto error; 330 int out_aw; 331 int i; 332 333 for (i = 0; i < codec->out_aw_num; i++) { 334 out_aw = codec->out_aw_list[i]; 335 336 /* XXX Choose appropriate parameters */ 337 uint32_t fmt; 338 /* 48 kHz, 16-bits, 1 channel */ 339 fmt = (fmt_base_44khz << fmt_base) | (fmt_bits_16 << fmt_bits_l); 340 341 /* Configure converter */ 342 343 ddf_msg(LVL_NOTE, "Configure converter format"); 344 rc = hda_set_converter_fmt(codec, out_aw, fmt); 345 if (rc != EOK) 346 goto error; 347 348 ddf_msg(LVL_NOTE, "Configure converter stream, channel"); 349 rc = hda_set_converter_ctl(codec, out_aw, sid, 0); 350 if (rc != EOK) 351 goto error; 352 } 294 353 295 354 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.