Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: hda - Add card field to hda_codec struct

Allow the codec object to have an individual card pointer. Not only
this simplifies the redirections in many places, also this will allow
us to make each codec assigned to a different card object.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+41 -40
+2 -2
sound/pci/hda/hda_beep.c
··· 160 160 input_dev->name = "HDA Digital PCBeep"; 161 161 input_dev->phys = beep->phys; 162 162 input_dev->id.bustype = BUS_PCI; 163 - input_dev->dev.parent = &codec->bus->card->card_dev; 163 + input_dev->dev.parent = &codec->card->card_dev; 164 164 165 165 input_dev->id.vendor = codec->vendor_id >> 16; 166 166 input_dev->id.product = codec->vendor_id & 0xffff; ··· 224 224 if (beep == NULL) 225 225 return -ENOMEM; 226 226 snprintf(beep->phys, sizeof(beep->phys), 227 - "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); 227 + "card%d/codec#%d/beep0", codec->card->number, codec->addr); 228 228 /* enable linear scale */ 229 229 snd_hda_codec_write_cache(codec, nid, 0, 230 230 AC_VERB_SET_DIGI_CONVERT_2, 0x01);
+3 -3
sound/pci/hda/hda_bind.c
··· 287 287 } 288 288 289 289 /* audio codec should override the mixer name */ 290 - if (codec->afg || !*codec->bus->card->mixername) 291 - snprintf(codec->bus->card->mixername, 292 - sizeof(codec->bus->card->mixername), 290 + if (codec->afg || !*codec->card->mixername) 291 + snprintf(codec->card->mixername, 292 + sizeof(codec->card->mixername), 293 293 "%s %s", codec->vendor_name, codec->chip_name); 294 294 return 0; 295 295
+15 -15
sound/pci/hda/hda_codec.c
··· 1196 1196 * 1197 1197 * Returns 0 if successful, or a negative error code. 1198 1198 */ 1199 - int snd_hda_codec_new(struct hda_bus *bus, 1200 - unsigned int codec_addr, 1201 - struct hda_codec **codecp) 1199 + int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card, 1200 + unsigned int codec_addr, struct hda_codec **codecp) 1202 1201 { 1203 1202 struct hda_codec *codec; 1204 1203 struct device *dev; ··· 1216 1217 return -EINVAL; 1217 1218 1218 1219 if (bus->caddr_tbl[codec_addr]) { 1219 - dev_err(bus->card->dev, 1220 + dev_err(card->dev, 1220 1221 "address 0x%x is already occupied\n", 1221 1222 codec_addr); 1222 1223 return -EBUSY; ··· 1224 1225 1225 1226 codec = kzalloc(sizeof(*codec), GFP_KERNEL); 1226 1227 if (codec == NULL) { 1227 - dev_err(bus->card->dev, "can't allocate struct hda_codec\n"); 1228 + dev_err(card->dev, "can't allocate struct hda_codec\n"); 1228 1229 return -ENOMEM; 1229 1230 } 1230 1231 1231 1232 dev = hda_codec_dev(codec); 1232 1233 device_initialize(dev); 1233 - dev->parent = bus->card->dev; 1234 + dev->parent = card->dev; 1234 1235 dev->bus = &snd_hda_bus_type; 1235 1236 dev->release = snd_hda_codec_dev_release; 1236 1237 dev->groups = snd_hda_dev_attr_groups; 1237 - dev_set_name(dev, "hdaudioC%dD%d", bus->card->number, codec_addr); 1238 + dev_set_name(dev, "hdaudioC%dD%d", card->number, codec_addr); 1238 1239 dev_set_drvdata(dev, codec); /* for sysfs */ 1239 1240 device_enable_async_suspend(dev); 1240 1241 1241 1242 codec->bus = bus; 1243 + codec->card = card; 1242 1244 codec->addr = codec_addr; 1243 1245 mutex_init(&codec->spdif_mutex); 1244 1246 mutex_init(&codec->control_mutex); ··· 1300 1300 1301 1301 setup_fg_nodes(codec); 1302 1302 if (!codec->afg && !codec->mfg) { 1303 - dev_err(bus->card->dev, "no AFG or MFG node found\n"); 1303 + dev_err(card->dev, "no AFG or MFG node found\n"); 1304 1304 err = -ENODEV; 1305 1305 goto error; 1306 1306 } ··· 1308 1308 fg = codec->afg ? codec->afg : codec->mfg; 1309 1309 err = read_widget_caps(codec, fg); 1310 1310 if (err < 0) { 1311 - dev_err(bus->card->dev, "cannot malloc\n"); 1311 + dev_err(card->dev, "cannot malloc\n"); 1312 1312 goto error; 1313 1313 } 1314 1314 err = read_pin_defaults(codec); ··· 1337 1337 1338 1338 sprintf(component, "HDA:%08x,%08x,%08x", codec->vendor_id, 1339 1339 codec->subsystem_id, codec->revision_id); 1340 - snd_component_add(codec->bus->card, component); 1340 + snd_component_add(card, component); 1341 1341 1342 - err = snd_device_new(bus->card, SNDRV_DEV_CODEC, codec, &dev_ops); 1342 + err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops); 1343 1343 if (err < 0) 1344 1344 goto error; 1345 1345 ··· 2237 2237 if (snd_BUG_ON(strlen(name) >= sizeof(id.name))) 2238 2238 return NULL; 2239 2239 strcpy(id.name, name); 2240 - return snd_ctl_find_id(codec->bus->card, &id); 2240 + return snd_ctl_find_id(codec->card, &id); 2241 2241 } 2242 2242 2243 2243 /** ··· 2301 2301 nid = kctl->id.subdevice & 0xffff; 2302 2302 if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG)) 2303 2303 kctl->id.subdevice = 0; 2304 - err = snd_ctl_add(codec->bus->card, kctl); 2304 + err = snd_ctl_add(codec->card, kctl); 2305 2305 if (err < 0) 2306 2306 return err; 2307 2307 item = snd_array_new(&codec->mixers); ··· 2354 2354 int i; 2355 2355 struct hda_nid_item *items = codec->mixers.list; 2356 2356 for (i = 0; i < codec->mixers.used; i++) 2357 - snd_ctl_remove(codec->bus->card, items[i].kctl); 2357 + snd_ctl_remove(codec->card, items[i].kctl); 2358 2358 snd_array_free(&codec->mixers); 2359 2359 snd_array_free(&codec->nids); 2360 2360 } ··· 2427 2427 int snd_hda_codec_reset(struct hda_codec *codec) 2428 2428 { 2429 2429 struct hda_bus *bus = codec->bus; 2430 - struct snd_card *card = bus->card; 2430 + struct snd_card *card = codec->card; 2431 2431 int i; 2432 2432 2433 2433 if (snd_hda_lock_devices(bus) < 0)
+3 -2
sound/pci/hda/hda_codec.h
··· 274 274 struct hda_codec { 275 275 struct device dev; 276 276 struct hda_bus *bus; 277 + struct snd_card *card; 277 278 unsigned int addr; /* codec addr*/ 278 279 struct list_head list; /* list point */ 279 280 ··· 421 420 * constructors 422 421 */ 423 422 int snd_hda_bus_new(struct snd_card *card, struct hda_bus **busp); 424 - int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 425 - struct hda_codec **codecp); 423 + int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card, 424 + unsigned int codec_addr, struct hda_codec **codecp); 426 425 int snd_hda_codec_configure(struct hda_codec *codec); 427 426 int snd_hda_codec_update_widgets(struct hda_codec *codec); 428 427
+1 -1
sound/pci/hda/hda_controller.c
··· 1898 1898 for (c = 0; c < max_slots; c++) { 1899 1899 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { 1900 1900 struct hda_codec *codec; 1901 - err = snd_hda_codec_new(bus, c, &codec); 1901 + err = snd_hda_codec_new(bus, bus->card, c, &codec); 1902 1902 if (err < 0) 1903 1903 continue; 1904 1904 codec->jackpoll_interval = get_jackpoll_interval(chip);
+1 -1
sound/pci/hda/hda_hwdep.c
··· 101 101 int err; 102 102 103 103 sprintf(hwname, "HDA Codec %d", codec->addr); 104 - err = snd_hwdep_new(codec->bus->card, hwname, codec->addr, &hwdep); 104 + err = snd_hwdep_new(codec->card, hwname, codec->addr, &hwdep); 105 105 if (err < 0) 106 106 return err; 107 107 codec->hwdep = hwdep;
+4 -4
sound/pci/hda/hda_jack.c
··· 135 135 #ifdef CONFIG_SND_HDA_INPUT_JACK 136 136 /* free jack instances manually when clearing/reconfiguring */ 137 137 if (!codec->bus->shutdown && jack->jack) 138 - snd_device_free(codec->bus->card, jack->jack); 138 + snd_device_free(codec->card, jack->jack); 139 139 #endif 140 140 for (cb = jack->callback; cb; cb = next) { 141 141 next = cb->next; ··· 340 340 if (!jack->kctl || jack->block_report) 341 341 continue; 342 342 state = get_jack_plug_state(jack->pin_sense); 343 - snd_kctl_jack_report(codec->bus->card, jack->kctl, state); 343 + snd_kctl_jack_report(codec->card, jack->kctl, state); 344 344 #ifdef CONFIG_SND_HDA_INPUT_JACK 345 345 if (jack->jack) 346 346 snd_jack_report(jack->jack, ··· 412 412 jack->phantom_jack = !!phantom_jack; 413 413 414 414 state = snd_hda_jack_detect(codec, nid); 415 - snd_kctl_jack_report(codec->bus->card, kctl, state); 415 + snd_kctl_jack_report(codec->card, kctl, state); 416 416 #ifdef CONFIG_SND_HDA_INPUT_JACK 417 417 if (!phantom_jack) { 418 418 jack->type = get_input_jack_type(codec, nid); 419 - err = snd_jack_new(codec->bus->card, name, jack->type, 419 + err = snd_jack_new(codec->card, name, jack->type, 420 420 &jack->jack); 421 421 if (err < 0) 422 422 return err;
+1 -1
sound/pci/hda/hda_proc.c
··· 839 839 int err; 840 840 841 841 snprintf(name, sizeof(name), "codec#%d", codec->addr); 842 - err = snd_card_proc_new(codec->bus->card, name, &entry); 842 + err = snd_card_proc_new(codec->card, name, &entry); 843 843 if (err < 0) 844 844 return err; 845 845
+1 -1
sound/pci/hda/hda_sysfs.c
··· 149 149 err = snd_hda_codec_build_controls(codec); 150 150 if (err < 0) 151 151 goto error; 152 - err = snd_card_register(codec->bus->card); 152 + err = snd_card_register(codec->card); 153 153 error: 154 154 snd_hda_power_down(codec); 155 155 return err;
+2 -2
sound/pci/hda/hda_trace.h
··· 23 23 ), 24 24 25 25 TP_fast_assign( 26 - __entry->card = (codec)->bus->card->number; 26 + __entry->card = (codec)->card->number; 27 27 __entry->addr = (codec)->addr; 28 28 __entry->val = (val); 29 29 ), ··· 71 71 ), 72 72 73 73 TP_fast_assign( 74 - __entry->card = (codec)->bus->card->number; 74 + __entry->card = (codec)->card->number; 75 75 __entry->addr = (codec)->addr; 76 76 ), 77 77
+1 -1
sound/pci/hda/patch_ca0132.c
··· 4352 4352 const struct dsp_image_seg *dsp_os_image; 4353 4353 const struct firmware *fw_entry; 4354 4354 4355 - if (request_firmware(&fw_entry, EFX_FILE, codec->bus->card->dev) != 0) 4355 + if (request_firmware(&fw_entry, EFX_FILE, codec->card->dev) != 0) 4356 4356 return false; 4357 4357 4358 4358 dsp_os_image = (struct dsp_image_seg *)(fw_entry->data);
+3 -3
sound/pci/hda/patch_hdmi.c
··· 579 579 int err; 580 580 581 581 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); 582 - err = snd_card_proc_new(codec->bus->card, name, &entry); 582 + err = snd_card_proc_new(codec->card, name, &entry); 583 583 if (err < 0) 584 584 return err; 585 585 ··· 594 594 static void eld_proc_free(struct hdmi_spec_per_pin *per_pin) 595 595 { 596 596 if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { 597 - snd_device_free(per_pin->codec->bus->card, per_pin->proc_entry); 597 + snd_device_free(per_pin->codec->card, per_pin->proc_entry); 598 598 per_pin->proc_entry = NULL; 599 599 } 600 600 } ··· 1624 1624 } 1625 1625 1626 1626 if (eld_changed) 1627 - snd_ctl_notify(codec->bus->card, 1627 + snd_ctl_notify(codec->card, 1628 1628 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, 1629 1629 &per_pin->eld_ctl->id); 1630 1630 unlock:
+4 -4
sound/pci/hda/patch_via.c
··· 907 907 if (get_codec_type(codec) == VT1708BCE) { 908 908 kfree(codec->chip_name); 909 909 codec->chip_name = kstrdup("VT1708BCE", GFP_KERNEL); 910 - snprintf(codec->bus->card->mixername, 911 - sizeof(codec->bus->card->mixername), 910 + snprintf(codec->card->mixername, 911 + sizeof(codec->card->mixername), 912 912 "%s %s", codec->vendor_name, codec->chip_name); 913 913 } 914 914 /* correct names for VT1705 */ 915 915 if (codec->vendor_id == 0x11064397) { 916 916 kfree(codec->chip_name); 917 917 codec->chip_name = kstrdup("VT1705", GFP_KERNEL); 918 - snprintf(codec->bus->card->mixername, 919 - sizeof(codec->bus->card->mixername), 918 + snprintf(codec->card->mixername, 919 + sizeof(codec->card->mixername), 920 920 "%s %s", codec->vendor_name, codec->chip_name); 921 921 } 922 922