diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-08-24 13:09:45 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-09-11 10:45:09 -0400 |
commit | b35aabd78ddae8300fda7e6a1ac6f0484ef3e804 (patch) | |
tree | e0280cacf6c23c2fb69de45db56ecf65a9efe3d8 /sound/pci/hda | |
parent | a33b7b0a89a240a1416fa489f0b805488bfb9afd (diff) |
ALSA: hda - Replace with the generic fixup codes in patch_cirrus.c
... to make easier to integrate into the common generic parser in near
future.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r-- | sound/pci/hda/patch_cirrus.c | 193 |
1 files changed, 103 insertions, 90 deletions
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 0bddb3ee1101..6aca4a05a329 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -34,7 +34,8 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | struct cs_spec { | 36 | struct cs_spec { |
37 | int board_config; | 37 | struct hda_gen_spec gen; |
38 | |||
38 | struct auto_pin_cfg autocfg; | 39 | struct auto_pin_cfg autocfg; |
39 | struct hda_multi_out multiout; | 40 | struct hda_multi_out multiout; |
40 | struct snd_kcontrol *vmaster_sw; | 41 | struct snd_kcontrol *vmaster_sw; |
@@ -80,16 +81,17 @@ enum { | |||
80 | CS420X_MBP53, | 81 | CS420X_MBP53, |
81 | CS420X_MBP55, | 82 | CS420X_MBP55, |
82 | CS420X_IMAC27, | 83 | CS420X_IMAC27, |
83 | CS420X_IMAC27_122, | 84 | CS420X_GPIO_13, |
84 | CS420X_APPLE, | 85 | CS420X_GPIO_23, |
86 | CS420X_IMAC27_122 = CS420X_GPIO_23, | ||
87 | CS420X_APPLE = CS420X_GPIO_13, | ||
85 | CS420X_AUTO, | 88 | CS420X_AUTO, |
86 | CS420X_MODELS | ||
87 | }; | 89 | }; |
88 | 90 | ||
89 | /* CS421x boards */ | 91 | /* CS421x boards */ |
90 | enum { | 92 | enum { |
91 | CS421X_CDB4210, | 93 | CS421X_CDB4210, |
92 | CS421X_MODELS | 94 | CS421X_SENSE_B, |
93 | }; | 95 | }; |
94 | 96 | ||
95 | /* Vendor-specific processing widget */ | 97 | /* Vendor-specific processing widget */ |
@@ -1278,38 +1280,30 @@ static int cs_parse_auto_config(struct hda_codec *codec) | |||
1278 | return 0; | 1280 | return 0; |
1279 | } | 1281 | } |
1280 | 1282 | ||
1281 | static const char * const cs420x_models[CS420X_MODELS] = { | 1283 | static const struct hda_model_fixup cs420x_models[] = { |
1282 | [CS420X_MBP53] = "mbp53", | 1284 | { .id = CS420X_MBP53, .name = "mbp53" }, |
1283 | [CS420X_MBP55] = "mbp55", | 1285 | { .id = CS420X_MBP55, .name = "mbp55" }, |
1284 | [CS420X_IMAC27] = "imac27", | 1286 | { .id = CS420X_IMAC27, .name = "imac27" }, |
1285 | [CS420X_IMAC27_122] = "imac27_122", | 1287 | { .id = CS420X_IMAC27_122, .name = "imac27_122" }, |
1286 | [CS420X_APPLE] = "apple", | 1288 | { .id = CS420X_APPLE, .name = "apple" }, |
1287 | [CS420X_AUTO] = "auto", | 1289 | {} |
1288 | }; | 1290 | }; |
1289 | 1291 | ||
1290 | 1292 | static const struct snd_pci_quirk cs420x_fixup_tbl[] = { | |
1291 | static const struct snd_pci_quirk cs420x_cfg_tbl[] = { | ||
1292 | SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), | 1293 | SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), |
1293 | SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), | 1294 | SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), |
1294 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), | 1295 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), |
1295 | SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), | 1296 | SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), |
1296 | /* this conflicts with too many other models */ | 1297 | /* this conflicts with too many other models */ |
1297 | /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/ | 1298 | /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/ |
1298 | {} /* terminator */ | ||
1299 | }; | ||
1300 | 1299 | ||
1301 | static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = { | 1300 | /* codec SSID */ |
1302 | SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122), | 1301 | SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122), |
1303 | SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE), | 1302 | SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE), |
1304 | {} /* terminator */ | 1303 | {} /* terminator */ |
1305 | }; | 1304 | }; |
1306 | 1305 | ||
1307 | struct cs_pincfg { | 1306 | static const struct hda_pintbl mbp53_pincfgs[] = { |
1308 | hda_nid_t nid; | ||
1309 | u32 val; | ||
1310 | }; | ||
1311 | |||
1312 | static const struct cs_pincfg mbp53_pincfgs[] = { | ||
1313 | { 0x09, 0x012b4050 }, | 1307 | { 0x09, 0x012b4050 }, |
1314 | { 0x0a, 0x90100141 }, | 1308 | { 0x0a, 0x90100141 }, |
1315 | { 0x0b, 0x90100140 }, | 1309 | { 0x0b, 0x90100140 }, |
@@ -1323,7 +1317,7 @@ static const struct cs_pincfg mbp53_pincfgs[] = { | |||
1323 | {} /* terminator */ | 1317 | {} /* terminator */ |
1324 | }; | 1318 | }; |
1325 | 1319 | ||
1326 | static const struct cs_pincfg mbp55_pincfgs[] = { | 1320 | static const struct hda_pintbl mbp55_pincfgs[] = { |
1327 | { 0x09, 0x012b4030 }, | 1321 | { 0x09, 0x012b4030 }, |
1328 | { 0x0a, 0x90100121 }, | 1322 | { 0x0a, 0x90100121 }, |
1329 | { 0x0b, 0x90100120 }, | 1323 | { 0x0b, 0x90100120 }, |
@@ -1337,7 +1331,7 @@ static const struct cs_pincfg mbp55_pincfgs[] = { | |||
1337 | {} /* terminator */ | 1331 | {} /* terminator */ |
1338 | }; | 1332 | }; |
1339 | 1333 | ||
1340 | static const struct cs_pincfg imac27_pincfgs[] = { | 1334 | static const struct hda_pintbl imac27_pincfgs[] = { |
1341 | { 0x09, 0x012b4050 }, | 1335 | { 0x09, 0x012b4050 }, |
1342 | { 0x0a, 0x90100140 }, | 1336 | { 0x0a, 0x90100140 }, |
1343 | { 0x0b, 0x90100142 }, | 1337 | { 0x0b, 0x90100142 }, |
@@ -1351,22 +1345,59 @@ static const struct cs_pincfg imac27_pincfgs[] = { | |||
1351 | {} /* terminator */ | 1345 | {} /* terminator */ |
1352 | }; | 1346 | }; |
1353 | 1347 | ||
1354 | static const struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { | 1348 | static void cs420x_fixup_gpio_13(struct hda_codec *codec, |
1355 | [CS420X_MBP53] = mbp53_pincfgs, | 1349 | const struct hda_fixup *fix, int action) |
1356 | [CS420X_MBP55] = mbp55_pincfgs, | 1350 | { |
1357 | [CS420X_IMAC27] = imac27_pincfgs, | 1351 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
1358 | }; | 1352 | struct cs_spec *spec = codec->spec; |
1353 | spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ | ||
1354 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ | ||
1355 | spec->gpio_mask = spec->gpio_dir = | ||
1356 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker; | ||
1357 | } | ||
1358 | } | ||
1359 | 1359 | ||
1360 | static void fix_pincfg(struct hda_codec *codec, int model, | 1360 | static void cs420x_fixup_gpio_23(struct hda_codec *codec, |
1361 | const struct cs_pincfg **pin_configs) | 1361 | const struct hda_fixup *fix, int action) |
1362 | { | 1362 | { |
1363 | const struct cs_pincfg *cfg = pin_configs[model]; | 1363 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
1364 | if (!cfg) | 1364 | struct cs_spec *spec = codec->spec; |
1365 | return; | 1365 | spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ |
1366 | for (; cfg->nid; cfg++) | 1366 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ |
1367 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | 1367 | spec->gpio_mask = spec->gpio_dir = |
1368 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker; | ||
1369 | } | ||
1368 | } | 1370 | } |
1369 | 1371 | ||
1372 | static const struct hda_fixup cs420x_fixups[] = { | ||
1373 | [CS420X_MBP53] = { | ||
1374 | .type = HDA_FIXUP_PINS, | ||
1375 | .v.pins = mbp53_pincfgs, | ||
1376 | .chained = true, | ||
1377 | .chain_id = CS420X_APPLE, | ||
1378 | }, | ||
1379 | [CS420X_MBP55] = { | ||
1380 | .type = HDA_FIXUP_PINS, | ||
1381 | .v.pins = mbp55_pincfgs, | ||
1382 | .chained = true, | ||
1383 | .chain_id = CS420X_GPIO_13, | ||
1384 | }, | ||
1385 | [CS420X_IMAC27] = { | ||
1386 | .type = HDA_FIXUP_PINS, | ||
1387 | .v.pins = imac27_pincfgs, | ||
1388 | .chained = true, | ||
1389 | .chain_id = CS420X_GPIO_13, | ||
1390 | }, | ||
1391 | [CS420X_GPIO_13] = { | ||
1392 | .type = HDA_FIXUP_FUNC, | ||
1393 | .v.func = cs420x_fixup_gpio_13, | ||
1394 | }, | ||
1395 | [CS420X_GPIO_23] = { | ||
1396 | .type = HDA_FIXUP_FUNC, | ||
1397 | .v.func = cs420x_fixup_gpio_23, | ||
1398 | }, | ||
1399 | }; | ||
1400 | |||
1370 | static int patch_cs420x(struct hda_codec *codec) | 1401 | static int patch_cs420x(struct hda_codec *codec) |
1371 | { | 1402 | { |
1372 | struct cs_spec *spec; | 1403 | struct cs_spec *spec; |
@@ -1379,33 +1410,9 @@ static int patch_cs420x(struct hda_codec *codec) | |||
1379 | 1410 | ||
1380 | spec->vendor_nid = CS420X_VENDOR_NID; | 1411 | spec->vendor_nid = CS420X_VENDOR_NID; |
1381 | 1412 | ||
1382 | spec->board_config = | 1413 | snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl, |
1383 | snd_hda_check_board_config(codec, CS420X_MODELS, | 1414 | cs420x_fixups); |
1384 | cs420x_models, cs420x_cfg_tbl); | 1415 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
1385 | if (spec->board_config < 0) | ||
1386 | spec->board_config = | ||
1387 | snd_hda_check_board_codec_sid_config(codec, | ||
1388 | CS420X_MODELS, NULL, cs420x_codec_cfg_tbl); | ||
1389 | if (spec->board_config >= 0) | ||
1390 | fix_pincfg(codec, spec->board_config, cs_pincfgs); | ||
1391 | |||
1392 | switch (spec->board_config) { | ||
1393 | case CS420X_IMAC27: | ||
1394 | case CS420X_MBP53: | ||
1395 | case CS420X_MBP55: | ||
1396 | case CS420X_APPLE: | ||
1397 | spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ | ||
1398 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ | ||
1399 | spec->gpio_mask = spec->gpio_dir = | ||
1400 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker; | ||
1401 | break; | ||
1402 | case CS420X_IMAC27_122: | ||
1403 | spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ | ||
1404 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ | ||
1405 | spec->gpio_mask = spec->gpio_dir = | ||
1406 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker; | ||
1407 | break; | ||
1408 | } | ||
1409 | 1416 | ||
1410 | err = cs_parse_auto_config(codec); | 1417 | err = cs_parse_auto_config(codec); |
1411 | if (err < 0) | 1418 | if (err < 0) |
@@ -1413,6 +1420,8 @@ static int patch_cs420x(struct hda_codec *codec) | |||
1413 | 1420 | ||
1414 | codec->patch_ops = cs_patch_ops; | 1421 | codec->patch_ops = cs_patch_ops; |
1415 | 1422 | ||
1423 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); | ||
1424 | |||
1416 | return 0; | 1425 | return 0; |
1417 | 1426 | ||
1418 | error: | 1427 | error: |
@@ -1430,11 +1439,12 @@ static int patch_cs420x(struct hda_codec *codec) | |||
1430 | */ | 1439 | */ |
1431 | 1440 | ||
1432 | /* CS4210 board names */ | 1441 | /* CS4210 board names */ |
1433 | static const char *cs421x_models[CS421X_MODELS] = { | 1442 | static const struct hda_model_fixup cs421x_models[] = { |
1434 | [CS421X_CDB4210] = "cdb4210", | 1443 | { .id = CS421X_CDB4210, .name = "cdb4210" }, |
1444 | {} | ||
1435 | }; | 1445 | }; |
1436 | 1446 | ||
1437 | static const struct snd_pci_quirk cs421x_cfg_tbl[] = { | 1447 | static const struct snd_pci_quirk cs421x_fixup_tbl[] = { |
1438 | /* Test Intel board + CDB2410 */ | 1448 | /* Test Intel board + CDB2410 */ |
1439 | SND_PCI_QUIRK(0x8086, 0x5001, "DP45SG/CDB4210", CS421X_CDB4210), | 1449 | SND_PCI_QUIRK(0x8086, 0x5001, "DP45SG/CDB4210", CS421X_CDB4210), |
1440 | {} /* terminator */ | 1450 | {} /* terminator */ |
@@ -1442,7 +1452,7 @@ static const struct snd_pci_quirk cs421x_cfg_tbl[] = { | |||
1442 | 1452 | ||
1443 | /* CS4210 board pinconfigs */ | 1453 | /* CS4210 board pinconfigs */ |
1444 | /* Default CS4210 (CDB4210)*/ | 1454 | /* Default CS4210 (CDB4210)*/ |
1445 | static const struct cs_pincfg cdb4210_pincfgs[] = { | 1455 | static const struct hda_pintbl cdb4210_pincfgs[] = { |
1446 | { 0x05, 0x0321401f }, | 1456 | { 0x05, 0x0321401f }, |
1447 | { 0x06, 0x90170010 }, | 1457 | { 0x06, 0x90170010 }, |
1448 | { 0x07, 0x03813031 }, | 1458 | { 0x07, 0x03813031 }, |
@@ -1452,8 +1462,26 @@ static const struct cs_pincfg cdb4210_pincfgs[] = { | |||
1452 | {} /* terminator */ | 1462 | {} /* terminator */ |
1453 | }; | 1463 | }; |
1454 | 1464 | ||
1455 | static const struct cs_pincfg *cs421x_pincfgs[CS421X_MODELS] = { | 1465 | /* Setup GPIO/SENSE for each board (if used) */ |
1456 | [CS421X_CDB4210] = cdb4210_pincfgs, | 1466 | static void cs421x_fixup_sense_b(struct hda_codec *codec, |
1467 | const struct hda_fixup *fix, int action) | ||
1468 | { | ||
1469 | struct cs_spec *spec = codec->spec; | ||
1470 | if (action == HDA_FIXUP_ACT_PRE_PROBE) | ||
1471 | spec->sense_b = 1; | ||
1472 | } | ||
1473 | |||
1474 | static const struct hda_fixup cs421x_fixups[] = { | ||
1475 | [CS421X_CDB4210] = { | ||
1476 | .type = HDA_FIXUP_PINS, | ||
1477 | .v.pins = cdb4210_pincfgs, | ||
1478 | .chained = true, | ||
1479 | .chain_id = CS421X_SENSE_B, | ||
1480 | }, | ||
1481 | [CS421X_SENSE_B] = { | ||
1482 | .type = HDA_FIXUP_FUNC, | ||
1483 | .v.func = cs421x_fixup_sense_b, | ||
1484 | } | ||
1457 | }; | 1485 | }; |
1458 | 1486 | ||
1459 | static const struct hda_verb cs421x_coef_init_verbs[] = { | 1487 | static const struct hda_verb cs421x_coef_init_verbs[] = { |
@@ -1935,26 +1963,9 @@ static int patch_cs4210(struct hda_codec *codec) | |||
1935 | 1963 | ||
1936 | spec->vendor_nid = CS4210_VENDOR_NID; | 1964 | spec->vendor_nid = CS4210_VENDOR_NID; |
1937 | 1965 | ||
1938 | spec->board_config = | 1966 | snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl, |
1939 | snd_hda_check_board_config(codec, CS421X_MODELS, | 1967 | cs421x_fixups); |
1940 | cs421x_models, cs421x_cfg_tbl); | 1968 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
1941 | if (spec->board_config >= 0) | ||
1942 | fix_pincfg(codec, spec->board_config, cs421x_pincfgs); | ||
1943 | /* | ||
1944 | Setup GPIO/SENSE for each board (if used) | ||
1945 | */ | ||
1946 | switch (spec->board_config) { | ||
1947 | case CS421X_CDB4210: | ||
1948 | snd_printd("CS4210 board: %s\n", | ||
1949 | cs421x_models[spec->board_config]); | ||
1950 | /* spec->gpio_mask = 3; | ||
1951 | spec->gpio_dir = 3; | ||
1952 | spec->gpio_data = 3; | ||
1953 | */ | ||
1954 | spec->sense_b = 1; | ||
1955 | |||
1956 | break; | ||
1957 | } | ||
1958 | 1969 | ||
1959 | /* | 1970 | /* |
1960 | Update the GPIO/DMIC/SENSE_B pinmux before the configuration | 1971 | Update the GPIO/DMIC/SENSE_B pinmux before the configuration |
@@ -1969,6 +1980,8 @@ static int patch_cs4210(struct hda_codec *codec) | |||
1969 | 1980 | ||
1970 | codec->patch_ops = cs421x_patch_ops; | 1981 | codec->patch_ops = cs421x_patch_ops; |
1971 | 1982 | ||
1983 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); | ||
1984 | |||
1972 | return 0; | 1985 | return 0; |
1973 | 1986 | ||
1974 | error: | 1987 | error: |