diff options
150 files changed, 5339 insertions, 935 deletions
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 2a5f0e14efa3..7cbfa3c4fc3d 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt | |||
| @@ -138,6 +138,7 @@ Code Seq#(hex) Include File Comments | |||
| 138 | 'H' C0-DF net/bluetooth/cmtp/cmtp.h conflict! | 138 | 'H' C0-DF net/bluetooth/cmtp/cmtp.h conflict! |
| 139 | 'H' C0-DF net/bluetooth/bnep/bnep.h conflict! | 139 | 'H' C0-DF net/bluetooth/bnep/bnep.h conflict! |
| 140 | 'H' F1 linux/hid-roccat.h <mailto:erazor_de@users.sourceforge.net> | 140 | 'H' F1 linux/hid-roccat.h <mailto:erazor_de@users.sourceforge.net> |
| 141 | 'H' F8-FA sound/firewire.h | ||
| 141 | 'I' all linux/isdn.h conflict! | 142 | 'I' all linux/isdn.h conflict! |
| 142 | 'I' 00-0F drivers/isdn/divert/isdn_divert.h conflict! | 143 | 'I' 00-0F drivers/isdn/divert/isdn_divert.h conflict! |
| 143 | 'I' 40-4F linux/mISDNif.h conflict! | 144 | 'I' 40-4F linux/mISDNif.h conflict! |
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt index 86c52360ffe7..fc04c14de4bb 100644 --- a/Documentation/laptops/thinkpad-acpi.txt +++ b/Documentation/laptops/thinkpad-acpi.txt | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | ThinkPad ACPI Extras Driver | 1 | ThinkPad ACPI Extras Driver |
| 2 | 2 | ||
| 3 | Version 0.24 | 3 | Version 0.25 |
| 4 | December 11th, 2009 | 4 | October 16th, 2013 |
| 5 | 5 | ||
| 6 | Borislav Deianov <borislav@users.sf.net> | 6 | Borislav Deianov <borislav@users.sf.net> |
| 7 | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 7 | Henrique de Moraes Holschuh <hmh@hmh.eng.br> |
| @@ -741,6 +741,9 @@ compiled with the CONFIG_THINKPAD_ACPI_UNSAFE_LEDS option enabled. | |||
| 741 | Distributions must never enable this option. Individual users that | 741 | Distributions must never enable this option. Individual users that |
| 742 | are aware of the consequences are welcome to enabling it. | 742 | are aware of the consequences are welcome to enabling it. |
| 743 | 743 | ||
| 744 | Audio mute and microphone mute LEDs are supported, but currently not | ||
| 745 | visible to userspace. They are used by the snd-hda-intel audio driver. | ||
| 746 | |||
| 744 | procfs notes: | 747 | procfs notes: |
| 745 | 748 | ||
| 746 | The available commands are: | 749 | The available commands are: |
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 95731a08f257..b8dd0df76952 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt | |||
| @@ -616,7 +616,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
| 616 | 616 | ||
| 617 | As default, snd-dummy drivers doesn't allocate the real buffers | 617 | As default, snd-dummy drivers doesn't allocate the real buffers |
| 618 | but either ignores read/write or mmap a single dummy page to all | 618 | but either ignores read/write or mmap a single dummy page to all |
| 619 | buffer pages, in order to save the resouces. If your apps need | 619 | buffer pages, in order to save the resources. If your apps need |
| 620 | the read/ written buffer data to be consistent, pass fake_buffer=0 | 620 | the read/ written buffer data to be consistent, pass fake_buffer=0 |
| 621 | option. | 621 | option. |
| 622 | 622 | ||
diff --git a/Documentation/sound/alsa/Audiophile-Usb.txt b/Documentation/sound/alsa/Audiophile-Usb.txt index 654dd3b694a8..e7a5ed4dcae8 100644 --- a/Documentation/sound/alsa/Audiophile-Usb.txt +++ b/Documentation/sound/alsa/Audiophile-Usb.txt | |||
| @@ -232,7 +232,7 @@ The parameter can be given: | |||
| 232 | # modprobe snd-usb-audio index=1 device_setup=0x09 | 232 | # modprobe snd-usb-audio index=1 device_setup=0x09 |
| 233 | 233 | ||
| 234 | * Or while configuring the modules options in your modules configuration file | 234 | * Or while configuring the modules options in your modules configuration file |
| 235 | (tipically a .conf file in /etc/modprobe.d/ directory: | 235 | (typically a .conf file in /etc/modprobe.d/ directory: |
| 236 | alias snd-card-1 snd-usb-audio | 236 | alias snd-card-1 snd-usb-audio |
| 237 | options snd-usb-audio index=1 device_setup=0x09 | 237 | options snd-usb-audio index=1 device_setup=0x09 |
| 238 | 238 | ||
diff --git a/Documentation/sound/alsa/CMIPCI.txt b/Documentation/sound/alsa/CMIPCI.txt index 16935c8561f7..4e36e6e809ca 100644 --- a/Documentation/sound/alsa/CMIPCI.txt +++ b/Documentation/sound/alsa/CMIPCI.txt | |||
| @@ -87,7 +87,7 @@ with 4 channels, | |||
| 87 | 87 | ||
| 88 | and use the interleaved 4 channel data. | 88 | and use the interleaved 4 channel data. |
| 89 | 89 | ||
| 90 | There are some control switchs affecting to the speaker connections: | 90 | There are some control switches affecting to the speaker connections: |
| 91 | 91 | ||
| 92 | "Line-In Mode" - an enum control to change the behavior of line-in | 92 | "Line-In Mode" - an enum control to change the behavior of line-in |
| 93 | jack. Either "Line-In", "Rear Output" or "Bass Output" can | 93 | jack. Either "Line-In", "Rear Output" or "Bass Output" can |
diff --git a/Documentation/sound/alsa/compress_offload.txt b/Documentation/sound/alsa/compress_offload.txt index fd74ff26376e..630c492c3dc2 100644 --- a/Documentation/sound/alsa/compress_offload.txt +++ b/Documentation/sound/alsa/compress_offload.txt | |||
| @@ -217,12 +217,12 @@ Not supported: | |||
| 217 | would be enabled with ALSA kcontrols. | 217 | would be enabled with ALSA kcontrols. |
| 218 | 218 | ||
| 219 | - Audio policy/resource management. This API does not provide any | 219 | - Audio policy/resource management. This API does not provide any |
| 220 | hooks to query the utilization of the audio DSP, nor any premption | 220 | hooks to query the utilization of the audio DSP, nor any preemption |
| 221 | mechanisms. | 221 | mechanisms. |
| 222 | 222 | ||
| 223 | - No notion of underun/overrun. Since the bytes written are compressed | 223 | - No notion of underrun/overrun. Since the bytes written are compressed |
| 224 | in nature and data written/read doesn't translate directly to | 224 | in nature and data written/read doesn't translate directly to |
| 225 | rendered output in time, this does not deal with underrun/overun and | 225 | rendered output in time, this does not deal with underrun/overrun and |
| 226 | maybe dealt in user-library | 226 | maybe dealt in user-library |
| 227 | 227 | ||
| 228 | Credits: | 228 | Credits: |
diff --git a/Documentation/sound/alsa/soc/DPCM.txt b/Documentation/sound/alsa/soc/DPCM.txt index aa8546f2d144..0110180b7ac6 100644 --- a/Documentation/sound/alsa/soc/DPCM.txt +++ b/Documentation/sound/alsa/soc/DPCM.txt | |||
| @@ -192,7 +192,7 @@ This BE DAI link connects DAI0 to the codec (in this case RT5460 AIF1). It sets | |||
| 192 | the "no_pcm" flag to mark it has a BE and sets flags for supported stream | 192 | the "no_pcm" flag to mark it has a BE and sets flags for supported stream |
| 193 | directions using "dpcm_playback" and "dpcm_capture" above. | 193 | directions using "dpcm_playback" and "dpcm_capture" above. |
| 194 | 194 | ||
| 195 | The BE has also flags set for ignoreing suspend and PM down time. This allows | 195 | The BE has also flags set for ignoring suspend and PM down time. This allows |
| 196 | the BE to work in a hostless mode where the host CPU is not transferring data | 196 | the BE to work in a hostless mode where the host CPU is not transferring data |
| 197 | like a BT phone call :- | 197 | like a BT phone call :- |
| 198 | 198 | ||
| @@ -328,7 +328,7 @@ The host can control the hostless link either by :- | |||
| 328 | between both DAIs. | 328 | between both DAIs. |
| 329 | 329 | ||
| 330 | 2) Hostless FE. This FE has a virtual connection to the BE DAI links on the DAPM | 330 | 2) Hostless FE. This FE has a virtual connection to the BE DAI links on the DAPM |
| 331 | graph. Control is then carried out by the FE as regualar PCM operations. | 331 | graph. Control is then carried out by the FE as regular PCM operations. |
| 332 | This method gives more control over the DAI links, but requires much more | 332 | This method gives more control over the DAI links, but requires much more |
| 333 | userspace code to control the link. Its recommended to use CODEC<->CODEC | 333 | userspace code to control the link. Its recommended to use CODEC<->CODEC |
| 334 | unless your HW needs more fine grained sequencing of the PCM ops. | 334 | unless your HW needs more fine grained sequencing of the PCM ops. |
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt index 7dfd88ce31ac..6faab4880006 100644 --- a/Documentation/sound/alsa/soc/dapm.txt +++ b/Documentation/sound/alsa/soc/dapm.txt | |||
| @@ -30,7 +30,7 @@ There are 4 power domains within DAPM | |||
| 30 | machine driver and responds to asynchronous events e.g when HP | 30 | machine driver and responds to asynchronous events e.g when HP |
| 31 | are inserted | 31 | are inserted |
| 32 | 32 | ||
| 33 | 3. Path domain - audio susbsystem signal paths | 33 | 3. Path domain - audio subsystem signal paths |
| 34 | Automatically set when mixer and mux settings are changed by the user. | 34 | Automatically set when mixer and mux settings are changed by the user. |
| 35 | e.g. alsamixer, amixer. | 35 | e.g. alsamixer, amixer. |
| 36 | 36 | ||
| @@ -64,7 +64,7 @@ Audio DAPM widgets fall into a number of types:- | |||
| 64 | o Speaker - Speaker | 64 | o Speaker - Speaker |
| 65 | o Supply - Power or clock supply widget used by other widgets. | 65 | o Supply - Power or clock supply widget used by other widgets. |
| 66 | o Regulator - External regulator that supplies power to audio components. | 66 | o Regulator - External regulator that supplies power to audio components. |
| 67 | o Clock - External clock that supplies clock to audio componnents. | 67 | o Clock - External clock that supplies clock to audio components. |
| 68 | o AIF IN - Audio Interface Input (with TDM slot mask). | 68 | o AIF IN - Audio Interface Input (with TDM slot mask). |
| 69 | o AIF OUT - Audio Interface Output (with TDM slot mask). | 69 | o AIF OUT - Audio Interface Output (with TDM slot mask). |
| 70 | o Siggen - Signal Generator. | 70 | o Siggen - Signal Generator. |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 03ca6c139f1a..0b7efb269cf1 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 25 | 25 | ||
| 26 | #define TPACPI_VERSION "0.24" | 26 | #define TPACPI_VERSION "0.25" |
| 27 | #define TPACPI_SYSFS_VERSION 0x020700 | 27 | #define TPACPI_SYSFS_VERSION 0x020700 |
| 28 | 28 | ||
| 29 | /* | 29 | /* |
| @@ -88,6 +88,7 @@ | |||
| 88 | 88 | ||
| 89 | #include <linux/pci_ids.h> | 89 | #include <linux/pci_ids.h> |
| 90 | 90 | ||
| 91 | #include <linux/thinkpad_acpi.h> | ||
| 91 | 92 | ||
| 92 | /* ThinkPad CMOS commands */ | 93 | /* ThinkPad CMOS commands */ |
| 93 | #define TP_CMOS_VOLUME_DOWN 0 | 94 | #define TP_CMOS_VOLUME_DOWN 0 |
| @@ -8350,6 +8351,91 @@ static struct ibm_struct fan_driver_data = { | |||
| 8350 | .resume = fan_resume, | 8351 | .resume = fan_resume, |
| 8351 | }; | 8352 | }; |
| 8352 | 8353 | ||
| 8354 | /************************************************************************* | ||
| 8355 | * Mute LED subdriver | ||
| 8356 | */ | ||
| 8357 | |||
| 8358 | |||
| 8359 | struct tp_led_table { | ||
| 8360 | acpi_string name; | ||
| 8361 | int on_value; | ||
| 8362 | int off_value; | ||
| 8363 | int state; | ||
| 8364 | }; | ||
| 8365 | |||
| 8366 | static struct tp_led_table led_tables[] = { | ||
| 8367 | [TPACPI_LED_MUTE] = { | ||
| 8368 | .name = "SSMS", | ||
| 8369 | .on_value = 1, | ||
| 8370 | .off_value = 0, | ||
| 8371 | }, | ||
| 8372 | [TPACPI_LED_MICMUTE] = { | ||
| 8373 | .name = "MMTS", | ||
| 8374 | .on_value = 2, | ||
| 8375 | .off_value = 0, | ||
| 8376 | }, | ||
| 8377 | }; | ||
| 8378 | |||
| 8379 | static int mute_led_on_off(struct tp_led_table *t, bool state) | ||
| 8380 | { | ||
| 8381 | acpi_handle temp; | ||
| 8382 | int output; | ||
| 8383 | |||
| 8384 | if (!ACPI_SUCCESS(acpi_get_handle(hkey_handle, t->name, &temp))) { | ||
| 8385 | pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); | ||
| 8386 | return -EIO; | ||
| 8387 | } | ||
| 8388 | |||
| 8389 | if (!acpi_evalf(hkey_handle, &output, t->name, "dd", | ||
| 8390 | state ? t->on_value : t->off_value)) | ||
| 8391 | return -EIO; | ||
| 8392 | |||
| 8393 | t->state = state; | ||
| 8394 | return state; | ||
| 8395 | } | ||
| 8396 | |||
| 8397 | int tpacpi_led_set(int whichled, bool on) | ||
| 8398 | { | ||
| 8399 | struct tp_led_table *t; | ||
| 8400 | |||
| 8401 | if (whichled < 0 || whichled >= TPACPI_LED_MAX) | ||
| 8402 | return -EINVAL; | ||
| 8403 | |||
| 8404 | t = &led_tables[whichled]; | ||
| 8405 | if (t->state < 0 || t->state == on) | ||
| 8406 | return t->state; | ||
| 8407 | return mute_led_on_off(t, on); | ||
| 8408 | } | ||
| 8409 | EXPORT_SYMBOL_GPL(tpacpi_led_set); | ||
| 8410 | |||
| 8411 | static int mute_led_init(struct ibm_init_struct *iibm) | ||
| 8412 | { | ||
| 8413 | acpi_handle temp; | ||
| 8414 | int i; | ||
| 8415 | |||
| 8416 | for (i = 0; i < TPACPI_LED_MAX; i++) { | ||
| 8417 | struct tp_led_table *t = &led_tables[i]; | ||
| 8418 | if (ACPI_SUCCESS(acpi_get_handle(hkey_handle, t->name, &temp))) | ||
| 8419 | mute_led_on_off(t, false); | ||
| 8420 | else | ||
| 8421 | t->state = -ENODEV; | ||
| 8422 | } | ||
| 8423 | return 0; | ||
| 8424 | } | ||
| 8425 | |||
| 8426 | static void mute_led_exit(void) | ||
| 8427 | { | ||
| 8428 | int i; | ||
| 8429 | |||
| 8430 | for (i = 0; i < TPACPI_LED_MAX; i++) | ||
| 8431 | tpacpi_led_set(i, false); | ||
| 8432 | } | ||
| 8433 | |||
| 8434 | static struct ibm_struct mute_led_driver_data = { | ||
| 8435 | .name = "mute_led", | ||
| 8436 | .exit = mute_led_exit, | ||
| 8437 | }; | ||
| 8438 | |||
| 8353 | /**************************************************************************** | 8439 | /**************************************************************************** |
| 8354 | **************************************************************************** | 8440 | **************************************************************************** |
| 8355 | * | 8441 | * |
| @@ -8768,6 +8854,10 @@ static struct ibm_init_struct ibms_init[] __initdata = { | |||
| 8768 | .init = fan_init, | 8854 | .init = fan_init, |
| 8769 | .data = &fan_driver_data, | 8855 | .data = &fan_driver_data, |
| 8770 | }, | 8856 | }, |
| 8857 | { | ||
| 8858 | .init = mute_led_init, | ||
| 8859 | .data = &mute_led_driver_data, | ||
| 8860 | }, | ||
| 8771 | }; | 8861 | }; |
| 8772 | 8862 | ||
| 8773 | static int __init set_ibm_param(const char *val, struct kernel_param *kp) | 8863 | static int __init set_ibm_param(const char *val, struct kernel_param *kp) |
diff --git a/include/linux/thinkpad_acpi.h b/include/linux/thinkpad_acpi.h new file mode 100644 index 000000000000..361de59a2285 --- /dev/null +++ b/include/linux/thinkpad_acpi.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #ifndef __THINKPAD_ACPI_H__ | ||
| 2 | #define __THINKPAD_ACPI_H__ | ||
| 3 | |||
| 4 | /* These two functions return 0 if success, or negative error code | ||
| 5 | (e g -ENODEV if no led present) */ | ||
| 6 | |||
| 7 | enum { | ||
| 8 | TPACPI_LED_MUTE, | ||
| 9 | TPACPI_LED_MICMUTE, | ||
| 10 | TPACPI_LED_MAX, | ||
| 11 | }; | ||
| 12 | |||
| 13 | int tpacpi_led_set(int whichled, bool on); | ||
| 14 | |||
| 15 | #endif | ||
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h index 3ce69fd92523..52f02a60dba7 100644 --- a/include/sound/ak4114.h +++ b/include/sound/ak4114.h | |||
| @@ -170,7 +170,7 @@ struct ak4114 { | |||
| 170 | void * private_data; | 170 | void * private_data; |
| 171 | unsigned int init: 1; | 171 | unsigned int init: 1; |
| 172 | spinlock_t lock; | 172 | spinlock_t lock; |
| 173 | unsigned char regmap[7]; | 173 | unsigned char regmap[6]; |
| 174 | unsigned char txcsb[5]; | 174 | unsigned char txcsb[5]; |
| 175 | struct snd_kcontrol *kctls[AK4114_CONTROLS]; | 175 | struct snd_kcontrol *kctls[AK4114_CONTROLS]; |
| 176 | struct snd_pcm_substream *playback_substream; | 176 | struct snd_pcm_substream *playback_substream; |
| @@ -189,7 +189,7 @@ struct ak4114 { | |||
| 189 | 189 | ||
| 190 | int snd_ak4114_create(struct snd_card *card, | 190 | int snd_ak4114_create(struct snd_card *card, |
| 191 | ak4114_read_t *read, ak4114_write_t *write, | 191 | ak4114_read_t *read, ak4114_write_t *write, |
| 192 | const unsigned char pgm[7], const unsigned char txcsb[5], | 192 | const unsigned char pgm[6], const unsigned char txcsb[5], |
| 193 | void *private_data, struct ak4114 **r_ak4114); | 193 | void *private_data, struct ak4114 **r_ak4114); |
| 194 | void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val); | 194 | void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val); |
| 195 | void snd_ak4114_reinit(struct ak4114 *ak4114); | 195 | void snd_ak4114_reinit(struct ak4114 *ak4114); |
diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index 9031a26249b5..ae6c3b8ed2f5 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h | |||
| @@ -171,4 +171,13 @@ static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream) | |||
| 171 | wake_up(&stream->runtime->sleep); | 171 | wake_up(&stream->runtime->sleep); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) | ||
| 175 | { | ||
| 176 | if (snd_BUG_ON(!stream)) | ||
| 177 | return; | ||
| 178 | |||
| 179 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | ||
| 180 | wake_up(&stream->runtime->sleep); | ||
| 181 | } | ||
| 182 | |||
| 174 | #endif | 183 | #endif |
diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h index cf15b8213df7..af9983970417 100644 --- a/include/sound/memalloc.h +++ b/include/sound/memalloc.h | |||
| @@ -52,6 +52,11 @@ struct snd_dma_device { | |||
| 52 | #else | 52 | #else |
| 53 | #define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */ | 53 | #define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */ |
| 54 | #endif | 54 | #endif |
| 55 | #ifdef CONFIG_GENERIC_ALLOCATOR | ||
| 56 | #define SNDRV_DMA_TYPE_DEV_IRAM 4 /* generic device iram-buffer */ | ||
| 57 | #else | ||
| 58 | #define SNDRV_DMA_TYPE_DEV_IRAM SNDRV_DMA_TYPE_DEV | ||
| 59 | #endif | ||
| 55 | 60 | ||
| 56 | /* | 61 | /* |
| 57 | * info for buffer allocation | 62 | * info for buffer allocation |
diff --git a/include/uapi/sound/Kbuild b/include/uapi/sound/Kbuild index 0f7d279ebde3..a7f27704f980 100644 --- a/include/uapi/sound/Kbuild +++ b/include/uapi/sound/Kbuild | |||
| @@ -5,6 +5,7 @@ header-y += asound_fm.h | |||
| 5 | header-y += compress_offload.h | 5 | header-y += compress_offload.h |
| 6 | header-y += compress_params.h | 6 | header-y += compress_params.h |
| 7 | header-y += emu10k1.h | 7 | header-y += emu10k1.h |
| 8 | header-y += firewire.h | ||
| 8 | header-y += hdsp.h | 9 | header-y += hdsp.h |
| 9 | header-y += hdspm.h | 10 | header-y += hdspm.h |
| 10 | header-y += sb16_csp.h | 11 | header-y += sb16_csp.h |
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 041203f20f6d..9fc6219d3848 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h | |||
| @@ -93,9 +93,10 @@ enum { | |||
| 93 | SNDRV_HWDEP_IFACE_SB_RC, /* SB Extigy/Audigy2NX remote control */ | 93 | SNDRV_HWDEP_IFACE_SB_RC, /* SB Extigy/Audigy2NX remote control */ |
| 94 | SNDRV_HWDEP_IFACE_HDA, /* HD-audio */ | 94 | SNDRV_HWDEP_IFACE_HDA, /* HD-audio */ |
| 95 | SNDRV_HWDEP_IFACE_USB_STREAM, /* direct access to usb stream */ | 95 | SNDRV_HWDEP_IFACE_USB_STREAM, /* direct access to usb stream */ |
| 96 | SNDRV_HWDEP_IFACE_FW_DICE, /* TC DICE FireWire device */ | ||
| 96 | 97 | ||
| 97 | /* Don't forget to change the following: */ | 98 | /* Don't forget to change the following: */ |
| 98 | SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM | 99 | SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_FW_DICE |
| 99 | }; | 100 | }; |
| 100 | 101 | ||
| 101 | struct snd_hwdep_info { | 102 | struct snd_hwdep_info { |
diff --git a/include/uapi/sound/firewire.h b/include/uapi/sound/firewire.h new file mode 100644 index 000000000000..59f5961302bf --- /dev/null +++ b/include/uapi/sound/firewire.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef _UAPI_SOUND_FIREWIRE_H_INCLUDED | ||
| 2 | #define _UAPI_SOUND_FIREWIRE_H_INCLUDED | ||
| 3 | |||
| 4 | #include <linux/ioctl.h> | ||
| 5 | |||
| 6 | /* events can be read() from the hwdep device */ | ||
| 7 | |||
| 8 | #define SNDRV_FIREWIRE_EVENT_LOCK_STATUS 0x000010cc | ||
| 9 | #define SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION 0xd1ce004e | ||
| 10 | |||
| 11 | struct snd_firewire_event_common { | ||
| 12 | unsigned int type; /* SNDRV_FIREWIRE_EVENT_xxx */ | ||
| 13 | }; | ||
| 14 | |||
| 15 | struct snd_firewire_event_lock_status { | ||
| 16 | unsigned int type; | ||
| 17 | unsigned int status; /* 0/1 = unlocked/locked */ | ||
| 18 | }; | ||
| 19 | |||
| 20 | struct snd_firewire_event_dice_notification { | ||
| 21 | unsigned int type; | ||
| 22 | unsigned int notification; /* DICE-specific bits */ | ||
| 23 | }; | ||
| 24 | |||
| 25 | union snd_firewire_event { | ||
| 26 | struct snd_firewire_event_common common; | ||
| 27 | struct snd_firewire_event_lock_status lock_status; | ||
| 28 | struct snd_firewire_event_dice_notification dice_notification; | ||
| 29 | }; | ||
| 30 | |||
| 31 | |||
| 32 | #define SNDRV_FIREWIRE_IOCTL_GET_INFO _IOR('H', 0xf8, struct snd_firewire_get_info) | ||
| 33 | #define SNDRV_FIREWIRE_IOCTL_LOCK _IO('H', 0xf9) | ||
| 34 | #define SNDRV_FIREWIRE_IOCTL_UNLOCK _IO('H', 0xfa) | ||
| 35 | |||
| 36 | #define SNDRV_FIREWIRE_TYPE_DICE 1 | ||
| 37 | /* Fireworks, AV/C, RME, MOTU, ... */ | ||
| 38 | |||
| 39 | struct snd_firewire_get_info { | ||
| 40 | unsigned int type; /* SNDRV_FIREWIRE_TYPE_xxx */ | ||
| 41 | unsigned int card; /* same as fw_cdev_get_info.card */ | ||
| 42 | unsigned char guid[8]; | ||
| 43 | char device_name[16]; /* device node in /dev */ | ||
| 44 | }; | ||
| 45 | |||
| 46 | /* | ||
| 47 | * SNDRV_FIREWIRE_IOCTL_LOCK prevents the driver from streaming. | ||
| 48 | * Returns -EBUSY if the driver is already streaming. | ||
| 49 | */ | ||
| 50 | |||
| 51 | #endif /* _UAPI_SOUND_FIREWIRE_H_INCLUDED */ | ||
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c index 61ab640e195f..9dc5806d23dd 100644 --- a/sound/aoa/fabrics/layout.c +++ b/sound/aoa/fabrics/layout.c | |||
| @@ -644,7 +644,7 @@ static int n##_control_put(struct snd_kcontrol *kcontrol, \ | |||
| 644 | struct snd_ctl_elem_value *ucontrol) \ | 644 | struct snd_ctl_elem_value *ucontrol) \ |
| 645 | { \ | 645 | { \ |
| 646 | struct gpio_runtime *gpio = snd_kcontrol_chip(kcontrol); \ | 646 | struct gpio_runtime *gpio = snd_kcontrol_chip(kcontrol); \ |
| 647 | if (gpio->methods && gpio->methods->get_##n) \ | 647 | if (gpio->methods && gpio->methods->set_##n) \ |
| 648 | gpio->methods->set_##n(gpio, \ | 648 | gpio->methods->set_##n(gpio, \ |
| 649 | !!ucontrol->value.integer.value[0]); \ | 649 | !!ucontrol->value.integer.value[0]); \ |
| 650 | return 1; \ | 650 | return 1; \ |
| @@ -1135,7 +1135,7 @@ static int aoa_fabric_layout_resume(struct soundbus_dev *sdev) | |||
| 1135 | { | 1135 | { |
| 1136 | struct layout_dev *ldev = dev_get_drvdata(&sdev->ofdev.dev); | 1136 | struct layout_dev *ldev = dev_get_drvdata(&sdev->ofdev.dev); |
| 1137 | 1137 | ||
| 1138 | if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off) | 1138 | if (ldev->gpio.methods && ldev->gpio.methods->all_amps_restore) |
| 1139 | ldev->gpio.methods->all_amps_restore(&ldev->gpio); | 1139 | ldev->gpio.methods->all_amps_restore(&ldev->gpio); |
| 1140 | 1140 | ||
| 1141 | return 0; | 1141 | return 0; |
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c index 99a466822a7d..66de90ed30ca 100644 --- a/sound/arm/pxa2xx-ac97-lib.c +++ b/sound/arm/pxa2xx-ac97-lib.c | |||
| @@ -208,7 +208,7 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) | |||
| 208 | pxa_ac97_warm_pxa3xx(); | 208 | pxa_ac97_warm_pxa3xx(); |
| 209 | else | 209 | else |
| 210 | #endif | 210 | #endif |
| 211 | BUG(); | 211 | snd_BUG(); |
| 212 | 212 | ||
| 213 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) | 213 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) |
| 214 | mdelay(1); | 214 | mdelay(1); |
| @@ -245,7 +245,7 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) | |||
| 245 | pxa_ac97_cold_pxa3xx(); | 245 | pxa_ac97_cold_pxa3xx(); |
| 246 | else | 246 | else |
| 247 | #endif | 247 | #endif |
| 248 | BUG(); | 248 | snd_BUG(); |
| 249 | 249 | ||
| 250 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) | 250 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) |
| 251 | mdelay(1); | 251 | mdelay(1); |
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index 5066a3768b28..9a2ac1e0f77a 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c | |||
| @@ -185,7 +185,7 @@ static int pxa2xx_ac97_probe(struct platform_device *dev) | |||
| 185 | goto err; | 185 | goto err; |
| 186 | 186 | ||
| 187 | card->dev = &dev->dev; | 187 | card->dev = &dev->dev; |
| 188 | strncpy(card->driver, dev->dev.driver->name, sizeof(card->driver)); | 188 | strlcpy(card->driver, dev->dev.driver->name, sizeof(card->driver)); |
| 189 | 189 | ||
| 190 | ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm); | 190 | ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm); |
| 191 | if (ret) | 191 | if (ret) |
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index ae63d22c0f88..c5f0ddd729b3 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c | |||
| @@ -34,7 +34,6 @@ | |||
| 34 | #include <linux/dw_dmac.h> | 34 | #include <linux/dw_dmac.h> |
| 35 | 35 | ||
| 36 | #include <mach/cpu.h> | 36 | #include <mach/cpu.h> |
| 37 | #include <mach/gpio.h> | ||
| 38 | 37 | ||
| 39 | #ifdef CONFIG_ARCH_AT91 | 38 | #ifdef CONFIG_ARCH_AT91 |
| 40 | #include <mach/hardware.h> | 39 | #include <mach/hardware.h> |
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index bea523a5d852..9d518ac73eea 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c | |||
| @@ -384,8 +384,7 @@ static unsigned int snd_compr_poll(struct file *f, poll_table *wait) | |||
| 384 | return -EFAULT; | 384 | return -EFAULT; |
| 385 | 385 | ||
| 386 | mutex_lock(&stream->device->lock); | 386 | mutex_lock(&stream->device->lock); |
| 387 | if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED || | 387 | if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) { |
| 388 | stream->runtime->state == SNDRV_PCM_STATE_OPEN) { | ||
| 389 | retval = -EBADFD; | 388 | retval = -EBADFD; |
| 390 | goto out; | 389 | goto out; |
| 391 | } | 390 | } |
| @@ -680,14 +679,48 @@ static int snd_compr_stop(struct snd_compr_stream *stream) | |||
| 680 | return -EPERM; | 679 | return -EPERM; |
| 681 | retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); | 680 | retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); |
| 682 | if (!retval) { | 681 | if (!retval) { |
| 683 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | 682 | snd_compr_drain_notify(stream); |
| 684 | wake_up(&stream->runtime->sleep); | ||
| 685 | stream->runtime->total_bytes_available = 0; | 683 | stream->runtime->total_bytes_available = 0; |
| 686 | stream->runtime->total_bytes_transferred = 0; | 684 | stream->runtime->total_bytes_transferred = 0; |
| 687 | } | 685 | } |
| 688 | return retval; | 686 | return retval; |
| 689 | } | 687 | } |
| 690 | 688 | ||
| 689 | static int snd_compress_wait_for_drain(struct snd_compr_stream *stream) | ||
| 690 | { | ||
| 691 | int ret; | ||
| 692 | |||
| 693 | /* | ||
| 694 | * We are called with lock held. So drop the lock while we wait for | ||
| 695 | * drain complete notfication from the driver | ||
| 696 | * | ||
| 697 | * It is expected that driver will notify the drain completion and then | ||
| 698 | * stream will be moved to SETUP state, even if draining resulted in an | ||
| 699 | * error. We can trigger next track after this. | ||
| 700 | */ | ||
| 701 | stream->runtime->state = SNDRV_PCM_STATE_DRAINING; | ||
| 702 | mutex_unlock(&stream->device->lock); | ||
| 703 | |||
| 704 | /* we wait for drain to complete here, drain can return when | ||
| 705 | * interruption occurred, wait returned error or success. | ||
| 706 | * For the first two cases we don't do anything different here and | ||
| 707 | * return after waking up | ||
| 708 | */ | ||
| 709 | |||
| 710 | ret = wait_event_interruptible(stream->runtime->sleep, | ||
| 711 | (stream->runtime->state != SNDRV_PCM_STATE_DRAINING)); | ||
| 712 | if (ret == -ERESTARTSYS) | ||
| 713 | pr_debug("wait aborted by a signal"); | ||
| 714 | else if (ret) | ||
| 715 | pr_debug("wait for drain failed with %d\n", ret); | ||
| 716 | |||
| 717 | |||
| 718 | wake_up(&stream->runtime->sleep); | ||
| 719 | mutex_lock(&stream->device->lock); | ||
| 720 | |||
| 721 | return ret; | ||
| 722 | } | ||
| 723 | |||
| 691 | static int snd_compr_drain(struct snd_compr_stream *stream) | 724 | static int snd_compr_drain(struct snd_compr_stream *stream) |
| 692 | { | 725 | { |
| 693 | int retval; | 726 | int retval; |
| @@ -695,12 +728,15 @@ static int snd_compr_drain(struct snd_compr_stream *stream) | |||
| 695 | if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || | 728 | if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || |
| 696 | stream->runtime->state == SNDRV_PCM_STATE_SETUP) | 729 | stream->runtime->state == SNDRV_PCM_STATE_SETUP) |
| 697 | return -EPERM; | 730 | return -EPERM; |
| 731 | |||
| 698 | retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); | 732 | retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); |
| 699 | if (!retval) { | 733 | if (retval) { |
| 700 | stream->runtime->state = SNDRV_PCM_STATE_DRAINING; | 734 | pr_debug("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval); |
| 701 | wake_up(&stream->runtime->sleep); | 735 | wake_up(&stream->runtime->sleep); |
| 736 | return retval; | ||
| 702 | } | 737 | } |
| 703 | return retval; | 738 | |
| 739 | return snd_compress_wait_for_drain(stream); | ||
| 704 | } | 740 | } |
| 705 | 741 | ||
| 706 | static int snd_compr_next_track(struct snd_compr_stream *stream) | 742 | static int snd_compr_next_track(struct snd_compr_stream *stream) |
| @@ -736,9 +772,14 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) | |||
| 736 | return -EPERM; | 772 | return -EPERM; |
| 737 | 773 | ||
| 738 | retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); | 774 | retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); |
| 775 | if (retval) { | ||
| 776 | pr_debug("Partial drain returned failure\n"); | ||
| 777 | wake_up(&stream->runtime->sleep); | ||
| 778 | return retval; | ||
| 779 | } | ||
| 739 | 780 | ||
| 740 | stream->next_track = false; | 781 | stream->next_track = false; |
| 741 | return retval; | 782 | return snd_compress_wait_for_drain(stream); |
| 742 | } | 783 | } |
| 743 | 784 | ||
| 744 | static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | 785 | static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) |
diff --git a/sound/core/init.c b/sound/core/init.c index 6b9087115da2..1351f22f651c 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
| @@ -66,7 +66,7 @@ static int module_slot_match(struct module *module, int idx) | |||
| 66 | #ifdef MODULE | 66 | #ifdef MODULE |
| 67 | const char *s1, *s2; | 67 | const char *s1, *s2; |
| 68 | 68 | ||
| 69 | if (!module || !module->name || !slots[idx]) | 69 | if (!module || !*module->name || !slots[idx]) |
| 70 | return 0; | 70 | return 0; |
| 71 | 71 | ||
| 72 | s1 = module->name; | 72 | s1 = module->name; |
| @@ -597,7 +597,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src, | |||
| 597 | /* last resort... */ | 597 | /* last resort... */ |
| 598 | snd_printk(KERN_ERR "unable to set card id (%s)\n", id); | 598 | snd_printk(KERN_ERR "unable to set card id (%s)\n", id); |
| 599 | if (card->proc_root->name) | 599 | if (card->proc_root->name) |
| 600 | strcpy(card->id, card->proc_root->name); | 600 | strlcpy(card->id, card->proc_root->name, sizeof(card->id)); |
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | /** | 603 | /** |
diff --git a/sound/core/jack.c b/sound/core/jack.c index b35fe7345c20..8658578eb584 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
| @@ -34,12 +34,12 @@ static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { | |||
| 34 | SW_LINEIN_INSERT, | 34 | SW_LINEIN_INSERT, |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | static int snd_jack_dev_free(struct snd_device *device) | 37 | static int snd_jack_dev_disconnect(struct snd_device *device) |
| 38 | { | 38 | { |
| 39 | struct snd_jack *jack = device->device_data; | 39 | struct snd_jack *jack = device->device_data; |
| 40 | 40 | ||
| 41 | if (jack->private_free) | 41 | if (!jack->input_dev) |
| 42 | jack->private_free(jack); | 42 | return 0; |
| 43 | 43 | ||
| 44 | /* If the input device is registered with the input subsystem | 44 | /* If the input device is registered with the input subsystem |
| 45 | * then we need to use a different deallocator. */ | 45 | * then we need to use a different deallocator. */ |
| @@ -47,6 +47,18 @@ static int snd_jack_dev_free(struct snd_device *device) | |||
| 47 | input_unregister_device(jack->input_dev); | 47 | input_unregister_device(jack->input_dev); |
| 48 | else | 48 | else |
| 49 | input_free_device(jack->input_dev); | 49 | input_free_device(jack->input_dev); |
| 50 | jack->input_dev = NULL; | ||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | static int snd_jack_dev_free(struct snd_device *device) | ||
| 55 | { | ||
| 56 | struct snd_jack *jack = device->device_data; | ||
| 57 | |||
| 58 | if (jack->private_free) | ||
| 59 | jack->private_free(jack); | ||
| 60 | |||
| 61 | snd_jack_dev_disconnect(device); | ||
| 50 | 62 | ||
| 51 | kfree(jack->id); | 63 | kfree(jack->id); |
| 52 | kfree(jack); | 64 | kfree(jack); |
| @@ -110,6 +122,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, | |||
| 110 | static struct snd_device_ops ops = { | 122 | static struct snd_device_ops ops = { |
| 111 | .dev_free = snd_jack_dev_free, | 123 | .dev_free = snd_jack_dev_free, |
| 112 | .dev_register = snd_jack_dev_register, | 124 | .dev_register = snd_jack_dev_register, |
| 125 | .dev_disconnect = snd_jack_dev_disconnect, | ||
| 113 | }; | 126 | }; |
| 114 | 127 | ||
| 115 | jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); | 128 | jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); |
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index bdf826f4fe0c..9d93f02c6285 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/seq_file.h> | 30 | #include <linux/seq_file.h> |
| 31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
| 32 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
| 33 | #include <linux/genalloc.h> | ||
| 33 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> |
| 34 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
| 35 | #include <sound/memalloc.h> | 36 | #include <sound/memalloc.h> |
| @@ -157,6 +158,51 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr, | |||
| 157 | dec_snd_pages(pg); | 158 | dec_snd_pages(pg); |
| 158 | dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); | 159 | dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); |
| 159 | } | 160 | } |
| 161 | |||
| 162 | #ifdef CONFIG_GENERIC_ALLOCATOR | ||
| 163 | /** | ||
| 164 | * snd_malloc_dev_iram - allocate memory from on-chip internal ram | ||
| 165 | * @dmab: buffer allocation record to store the allocated data | ||
| 166 | * @size: number of bytes to allocate from the iram | ||
| 167 | * | ||
| 168 | * This function requires iram phandle provided via of_node | ||
| 169 | */ | ||
| 170 | static void snd_malloc_dev_iram(struct snd_dma_buffer *dmab, size_t size) | ||
| 171 | { | ||
| 172 | struct device *dev = dmab->dev.dev; | ||
| 173 | struct gen_pool *pool = NULL; | ||
| 174 | |||
| 175 | dmab->area = NULL; | ||
| 176 | dmab->addr = 0; | ||
| 177 | |||
| 178 | if (dev->of_node) | ||
| 179 | pool = of_get_named_gen_pool(dev->of_node, "iram", 0); | ||
| 180 | |||
| 181 | if (!pool) | ||
| 182 | return; | ||
| 183 | |||
| 184 | /* Assign the pool into private_data field */ | ||
| 185 | dmab->private_data = pool; | ||
| 186 | |||
| 187 | dmab->area = (void *)gen_pool_alloc(pool, size); | ||
| 188 | if (!dmab->area) | ||
| 189 | return; | ||
| 190 | |||
| 191 | dmab->addr = gen_pool_virt_to_phys(pool, (unsigned long)dmab->area); | ||
| 192 | } | ||
| 193 | |||
| 194 | /** | ||
| 195 | * snd_free_dev_iram - free allocated specific memory from on-chip internal ram | ||
| 196 | * @dmab: buffer allocation record to store the allocated data | ||
| 197 | */ | ||
| 198 | static void snd_free_dev_iram(struct snd_dma_buffer *dmab) | ||
| 199 | { | ||
| 200 | struct gen_pool *pool = dmab->private_data; | ||
| 201 | |||
| 202 | if (pool && dmab->area) | ||
| 203 | gen_pool_free(pool, (unsigned long)dmab->area, dmab->bytes); | ||
| 204 | } | ||
| 205 | #endif /* CONFIG_GENERIC_ALLOCATOR */ | ||
| 160 | #endif /* CONFIG_HAS_DMA */ | 206 | #endif /* CONFIG_HAS_DMA */ |
| 161 | 207 | ||
| 162 | /* | 208 | /* |
| @@ -197,6 +243,16 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, | |||
| 197 | dmab->addr = 0; | 243 | dmab->addr = 0; |
| 198 | break; | 244 | break; |
| 199 | #ifdef CONFIG_HAS_DMA | 245 | #ifdef CONFIG_HAS_DMA |
| 246 | #ifdef CONFIG_GENERIC_ALLOCATOR | ||
| 247 | case SNDRV_DMA_TYPE_DEV_IRAM: | ||
| 248 | snd_malloc_dev_iram(dmab, size); | ||
| 249 | if (dmab->area) | ||
| 250 | break; | ||
| 251 | /* Internal memory might have limited size and no enough space, | ||
| 252 | * so if we fail to malloc, try to fetch memory traditionally. | ||
| 253 | */ | ||
| 254 | dmab->dev.type = SNDRV_DMA_TYPE_DEV; | ||
| 255 | #endif /* CONFIG_GENERIC_ALLOCATOR */ | ||
| 200 | case SNDRV_DMA_TYPE_DEV: | 256 | case SNDRV_DMA_TYPE_DEV: |
| 201 | dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); | 257 | dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); |
| 202 | break; | 258 | break; |
| @@ -269,6 +325,11 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab) | |||
| 269 | snd_free_pages(dmab->area, dmab->bytes); | 325 | snd_free_pages(dmab->area, dmab->bytes); |
| 270 | break; | 326 | break; |
| 271 | #ifdef CONFIG_HAS_DMA | 327 | #ifdef CONFIG_HAS_DMA |
| 328 | #ifdef CONFIG_GENERIC_ALLOCATOR | ||
| 329 | case SNDRV_DMA_TYPE_DEV_IRAM: | ||
| 330 | snd_free_dev_iram(dmab); | ||
| 331 | break; | ||
| 332 | #endif /* CONFIG_GENERIC_ALLOCATOR */ | ||
| 272 | case SNDRV_DMA_TYPE_DEV: | 333 | case SNDRV_DMA_TYPE_DEV: |
| 273 | snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); | 334 | snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); |
| 274 | break; | 335 | break; |
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c index aa924d9b7986..94d08733cb38 100644 --- a/sound/core/pcm_dmaengine.c +++ b/sound/core/pcm_dmaengine.c | |||
| @@ -63,23 +63,19 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, | |||
| 63 | struct dma_slave_config *slave_config) | 63 | struct dma_slave_config *slave_config) |
| 64 | { | 64 | { |
| 65 | enum dma_slave_buswidth buswidth; | 65 | enum dma_slave_buswidth buswidth; |
| 66 | int bits; | ||
| 66 | 67 | ||
| 67 | switch (params_format(params)) { | 68 | bits = snd_pcm_format_physical_width(params_format(params)); |
| 68 | case SNDRV_PCM_FORMAT_S8: | 69 | if (bits < 8 || bits > 64) |
| 70 | return -EINVAL; | ||
| 71 | else if (bits == 8) | ||
| 69 | buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; | 72 | buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; |
| 70 | break; | 73 | else if (bits == 16) |
| 71 | case SNDRV_PCM_FORMAT_S16_LE: | ||
| 72 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; | 74 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; |
| 73 | break; | 75 | else if (bits <= 32) |
| 74 | case SNDRV_PCM_FORMAT_S18_3LE: | ||
| 75 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
| 76 | case SNDRV_PCM_FORMAT_S24_LE: | ||
| 77 | case SNDRV_PCM_FORMAT_S32_LE: | ||
| 78 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; | 76 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 79 | break; | 77 | else |
| 80 | default: | 78 | buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES; |
| 81 | return -EINVAL; | ||
| 82 | } | ||
| 83 | 79 | ||
| 84 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 80 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 85 | slave_config->direction = DMA_MEM_TO_DEV; | 81 | slave_config->direction = DMA_MEM_TO_DEV; |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index a68d4c6d702c..01a5e05ede95 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
| @@ -2428,6 +2428,7 @@ static int snd_pcm_hwsync(struct snd_pcm_substream *substream) | |||
| 2428 | case SNDRV_PCM_STATE_DRAINING: | 2428 | case SNDRV_PCM_STATE_DRAINING: |
| 2429 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | 2429 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
| 2430 | goto __badfd; | 2430 | goto __badfd; |
| 2431 | /* Fall through */ | ||
| 2431 | case SNDRV_PCM_STATE_RUNNING: | 2432 | case SNDRV_PCM_STATE_RUNNING: |
| 2432 | if ((err = snd_pcm_update_hw_ptr(substream)) < 0) | 2433 | if ((err = snd_pcm_update_hw_ptr(substream)) < 0) |
| 2433 | break; | 2434 | break; |
| @@ -2460,6 +2461,7 @@ static int snd_pcm_delay(struct snd_pcm_substream *substream, | |||
| 2460 | case SNDRV_PCM_STATE_DRAINING: | 2461 | case SNDRV_PCM_STATE_DRAINING: |
| 2461 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | 2462 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
| 2462 | goto __badfd; | 2463 | goto __badfd; |
| 2464 | /* Fall through */ | ||
| 2463 | case SNDRV_PCM_STATE_RUNNING: | 2465 | case SNDRV_PCM_STATE_RUNNING: |
| 2464 | if ((err = snd_pcm_update_hw_ptr(substream)) < 0) | 2466 | if ((err = snd_pcm_update_hw_ptr(substream)) < 0) |
| 2465 | break; | 2467 | break; |
| @@ -3199,6 +3201,14 @@ int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, | |||
| 3199 | struct vm_area_struct *area) | 3201 | struct vm_area_struct *area) |
| 3200 | { | 3202 | { |
| 3201 | area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | 3203 | area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; |
| 3204 | #ifdef CONFIG_GENERIC_ALLOCATOR | ||
| 3205 | if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV_IRAM) { | ||
| 3206 | area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); | ||
| 3207 | return remap_pfn_range(area, area->vm_start, | ||
| 3208 | substream->dma_buffer.addr >> PAGE_SHIFT, | ||
| 3209 | area->vm_end - area->vm_start, area->vm_page_prot); | ||
| 3210 | } | ||
| 3211 | #endif /* CONFIG_GENERIC_ALLOCATOR */ | ||
| 3202 | #ifdef ARCH_HAS_DMA_MMAP_COHERENT | 3212 | #ifdef ARCH_HAS_DMA_MMAP_COHERENT |
| 3203 | if (!substream->ops->page && | 3213 | if (!substream->ops->page && |
| 3204 | substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) | 3214 | substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) |
diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 0c796bcbc0a3..6c6d09a51f42 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c | |||
| @@ -390,6 +390,11 @@ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) | |||
| 390 | voice = snd_opl3_oss_map[chan->number]; | 390 | voice = snd_opl3_oss_map[chan->number]; |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | if (voice < 0) { | ||
| 394 | spin_unlock_irqrestore(&opl3->voice_lock, flags); | ||
| 395 | return; | ||
| 396 | } | ||
| 397 | |||
| 393 | if (voice < MAX_OPL2_VOICES) { | 398 | if (voice < MAX_OPL2_VOICES) { |
| 394 | /* Left register block for voices 0 .. 8 */ | 399 | /* Left register block for voices 0 .. 8 */ |
| 395 | reg_side = OPL3_LEFT; | 400 | reg_side = OPL3_LEFT; |
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 1c19cd7ad26e..328bd29264ce 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c | |||
| @@ -46,8 +46,9 @@ static int snd_pcsp_create(struct snd_card *card) | |||
| 46 | int err; | 46 | int err; |
| 47 | int div, min_div, order; | 47 | int div, min_div, order; |
| 48 | 48 | ||
| 49 | hrtimer_get_res(CLOCK_MONOTONIC, &tp); | ||
| 50 | |||
| 49 | if (!nopcm) { | 51 | if (!nopcm) { |
| 50 | hrtimer_get_res(CLOCK_MONOTONIC, &tp); | ||
| 51 | if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { | 52 | if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { |
| 52 | printk(KERN_ERR "PCSP: Timer resolution is not sufficient " | 53 | printk(KERN_ERR "PCSP: Timer resolution is not sufficient " |
| 53 | "(%linS)\n", tp.tv_nsec); | 54 | "(%linS)\n", tp.tv_nsec); |
| @@ -187,8 +188,8 @@ static int pcsp_probe(struct platform_device *dev) | |||
| 187 | static int pcsp_remove(struct platform_device *dev) | 188 | static int pcsp_remove(struct platform_device *dev) |
| 188 | { | 189 | { |
| 189 | struct snd_pcsp *chip = platform_get_drvdata(dev); | 190 | struct snd_pcsp *chip = platform_get_drvdata(dev); |
| 190 | alsa_card_pcsp_exit(chip); | ||
| 191 | pcspkr_input_remove(chip->input_dev); | 191 | pcspkr_input_remove(chip->input_dev); |
| 192 | alsa_card_pcsp_exit(chip); | ||
| 192 | return 0; | 193 | return 0; |
| 193 | } | 194 | } |
| 194 | 195 | ||
diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig index ea063e1f8722..b3e274fe4a77 100644 --- a/sound/firewire/Kconfig +++ b/sound/firewire/Kconfig | |||
| @@ -11,6 +11,21 @@ config SND_FIREWIRE_LIB | |||
| 11 | tristate | 11 | tristate |
| 12 | depends on SND_PCM | 12 | depends on SND_PCM |
| 13 | 13 | ||
| 14 | config SND_DICE | ||
| 15 | tristate "DICE-based DACs (EXPERIMENTAL)" | ||
| 16 | select SND_HWDEP | ||
| 17 | select SND_PCM | ||
| 18 | select SND_FIREWIRE_LIB | ||
| 19 | help | ||
| 20 | Say Y here to include support for many DACs based on the DICE | ||
| 21 | chip family (DICE-II/Jr/Mini) from TC Applied Technologies. | ||
| 22 | |||
| 23 | At the moment, this driver supports playback only. If you | ||
| 24 | want to use devices that support capturing, use FFADO instead. | ||
| 25 | |||
| 26 | To compile this driver as a module, choose M here: the module | ||
| 27 | will be called snd-dice. | ||
| 28 | |||
| 14 | config SND_FIREWIRE_SPEAKERS | 29 | config SND_FIREWIRE_SPEAKERS |
| 15 | tristate "FireWire speakers" | 30 | tristate "FireWire speakers" |
| 16 | select SND_PCM | 31 | select SND_PCM |
diff --git a/sound/firewire/Makefile b/sound/firewire/Makefile index 460179df5bb5..509955061d30 100644 --- a/sound/firewire/Makefile +++ b/sound/firewire/Makefile | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \ | 1 | snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \ |
| 2 | fcp.o cmp.o amdtp.o | 2 | fcp.o cmp.o amdtp.o |
| 3 | snd-dice-objs := dice.o | ||
| 3 | snd-firewire-speakers-objs := speakers.o | 4 | snd-firewire-speakers-objs := speakers.o |
| 4 | snd-isight-objs := isight.o | 5 | snd-isight-objs := isight.o |
| 5 | snd-scs1x-objs := scs1x.o | 6 | snd-scs1x-objs := scs1x.o |
| 6 | 7 | ||
| 7 | obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o | 8 | obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o |
| 9 | obj-$(CONFIG_SND_DICE) += snd-dice.o | ||
| 8 | obj-$(CONFIG_SND_FIREWIRE_SPEAKERS) += snd-firewire-speakers.o | 10 | obj-$(CONFIG_SND_FIREWIRE_SPEAKERS) += snd-firewire-speakers.o |
| 9 | obj-$(CONFIG_SND_ISIGHT) += snd-isight.o | 11 | obj-$(CONFIG_SND_ISIGHT) += snd-isight.o |
| 10 | obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o | 12 | obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o |
diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index ea995af6d049..d3226892ad6b 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c | |||
| @@ -42,9 +42,6 @@ static void pcm_period_tasklet(unsigned long data); | |||
| 42 | int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, | 42 | int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, |
| 43 | enum cip_out_flags flags) | 43 | enum cip_out_flags flags) |
| 44 | { | 44 | { |
| 45 | if (flags != CIP_NONBLOCKING) | ||
| 46 | return -EINVAL; | ||
| 47 | |||
| 48 | s->unit = fw_unit_get(unit); | 45 | s->unit = fw_unit_get(unit); |
| 49 | s->flags = flags; | 46 | s->flags = flags; |
| 50 | s->context = ERR_PTR(-1); | 47 | s->context = ERR_PTR(-1); |
| @@ -62,73 +59,91 @@ EXPORT_SYMBOL(amdtp_out_stream_init); | |||
| 62 | */ | 59 | */ |
| 63 | void amdtp_out_stream_destroy(struct amdtp_out_stream *s) | 60 | void amdtp_out_stream_destroy(struct amdtp_out_stream *s) |
| 64 | { | 61 | { |
| 65 | WARN_ON(!IS_ERR(s->context)); | 62 | WARN_ON(amdtp_out_stream_running(s)); |
| 66 | mutex_destroy(&s->mutex); | 63 | mutex_destroy(&s->mutex); |
| 67 | fw_unit_put(s->unit); | 64 | fw_unit_put(s->unit); |
| 68 | } | 65 | } |
| 69 | EXPORT_SYMBOL(amdtp_out_stream_destroy); | 66 | EXPORT_SYMBOL(amdtp_out_stream_destroy); |
| 70 | 67 | ||
| 68 | const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT] = { | ||
| 69 | [CIP_SFC_32000] = 8, | ||
| 70 | [CIP_SFC_44100] = 8, | ||
| 71 | [CIP_SFC_48000] = 8, | ||
| 72 | [CIP_SFC_88200] = 16, | ||
| 73 | [CIP_SFC_96000] = 16, | ||
| 74 | [CIP_SFC_176400] = 32, | ||
| 75 | [CIP_SFC_192000] = 32, | ||
| 76 | }; | ||
| 77 | EXPORT_SYMBOL(amdtp_syt_intervals); | ||
| 78 | |||
| 71 | /** | 79 | /** |
| 72 | * amdtp_out_stream_set_rate - set the sample rate | 80 | * amdtp_out_stream_set_parameters - set stream parameters |
| 73 | * @s: the AMDTP output stream to configure | 81 | * @s: the AMDTP output stream to configure |
| 74 | * @rate: the sample rate | 82 | * @rate: the sample rate |
| 83 | * @pcm_channels: the number of PCM samples in each data block, to be encoded | ||
| 84 | * as AM824 multi-bit linear audio | ||
| 85 | * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels) | ||
| 75 | * | 86 | * |
| 76 | * The sample rate must be set before the stream is started, and must not be | 87 | * The parameters must be set before the stream is started, and must not be |
| 77 | * changed while the stream is running. | 88 | * changed while the stream is running. |
| 78 | */ | 89 | */ |
| 79 | void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate) | 90 | void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s, |
| 91 | unsigned int rate, | ||
| 92 | unsigned int pcm_channels, | ||
| 93 | unsigned int midi_ports) | ||
| 80 | { | 94 | { |
| 81 | static const struct { | 95 | static const unsigned int rates[] = { |
| 82 | unsigned int rate; | 96 | [CIP_SFC_32000] = 32000, |
| 83 | unsigned int syt_interval; | 97 | [CIP_SFC_44100] = 44100, |
| 84 | } rate_info[] = { | 98 | [CIP_SFC_48000] = 48000, |
| 85 | [CIP_SFC_32000] = { 32000, 8, }, | 99 | [CIP_SFC_88200] = 88200, |
| 86 | [CIP_SFC_44100] = { 44100, 8, }, | 100 | [CIP_SFC_96000] = 96000, |
| 87 | [CIP_SFC_48000] = { 48000, 8, }, | 101 | [CIP_SFC_176400] = 176400, |
| 88 | [CIP_SFC_88200] = { 88200, 16, }, | 102 | [CIP_SFC_192000] = 192000, |
| 89 | [CIP_SFC_96000] = { 96000, 16, }, | ||
| 90 | [CIP_SFC_176400] = { 176400, 32, }, | ||
| 91 | [CIP_SFC_192000] = { 192000, 32, }, | ||
| 92 | }; | 103 | }; |
| 93 | unsigned int sfc; | 104 | unsigned int sfc; |
| 94 | 105 | ||
| 95 | if (WARN_ON(!IS_ERR(s->context))) | 106 | if (WARN_ON(amdtp_out_stream_running(s))) |
| 96 | return; | 107 | return; |
| 97 | 108 | ||
| 98 | for (sfc = 0; sfc < ARRAY_SIZE(rate_info); ++sfc) | 109 | for (sfc = 0; sfc < CIP_SFC_COUNT; ++sfc) |
| 99 | if (rate_info[sfc].rate == rate) { | 110 | if (rates[sfc] == rate) |
| 100 | s->sfc = sfc; | 111 | goto sfc_found; |
| 101 | s->syt_interval = rate_info[sfc].syt_interval; | ||
| 102 | return; | ||
| 103 | } | ||
| 104 | WARN_ON(1); | 112 | WARN_ON(1); |
| 113 | return; | ||
| 114 | |||
| 115 | sfc_found: | ||
| 116 | s->dual_wire = (s->flags & CIP_HI_DUALWIRE) && sfc > CIP_SFC_96000; | ||
| 117 | if (s->dual_wire) { | ||
| 118 | sfc -= 2; | ||
| 119 | rate /= 2; | ||
| 120 | pcm_channels *= 2; | ||
| 121 | } | ||
| 122 | s->sfc = sfc; | ||
| 123 | s->data_block_quadlets = pcm_channels + DIV_ROUND_UP(midi_ports, 8); | ||
| 124 | s->pcm_channels = pcm_channels; | ||
| 125 | s->midi_ports = midi_ports; | ||
| 126 | |||
| 127 | s->syt_interval = amdtp_syt_intervals[sfc]; | ||
| 128 | |||
| 129 | /* default buffering in the device */ | ||
| 130 | s->transfer_delay = TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE; | ||
| 131 | if (s->flags & CIP_BLOCKING) | ||
| 132 | /* additional buffering needed to adjust for no-data packets */ | ||
| 133 | s->transfer_delay += TICKS_PER_SECOND * s->syt_interval / rate; | ||
| 105 | } | 134 | } |
| 106 | EXPORT_SYMBOL(amdtp_out_stream_set_rate); | 135 | EXPORT_SYMBOL(amdtp_out_stream_set_parameters); |
| 107 | 136 | ||
| 108 | /** | 137 | /** |
| 109 | * amdtp_out_stream_get_max_payload - get the stream's packet size | 138 | * amdtp_out_stream_get_max_payload - get the stream's packet size |
| 110 | * @s: the AMDTP output stream | 139 | * @s: the AMDTP output stream |
| 111 | * | 140 | * |
| 112 | * This function must not be called before the stream has been configured | 141 | * This function must not be called before the stream has been configured |
| 113 | * with amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and | 142 | * with amdtp_out_stream_set_parameters(). |
| 114 | * amdtp_out_stream_set_midi(). | ||
| 115 | */ | 143 | */ |
| 116 | unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s) | 144 | unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s) |
| 117 | { | 145 | { |
| 118 | static const unsigned int max_data_blocks[] = { | 146 | return 8 + s->syt_interval * s->data_block_quadlets * 4; |
| 119 | [CIP_SFC_32000] = 4, | ||
| 120 | [CIP_SFC_44100] = 6, | ||
| 121 | [CIP_SFC_48000] = 6, | ||
| 122 | [CIP_SFC_88200] = 12, | ||
| 123 | [CIP_SFC_96000] = 12, | ||
| 124 | [CIP_SFC_176400] = 23, | ||
| 125 | [CIP_SFC_192000] = 24, | ||
| 126 | }; | ||
| 127 | |||
| 128 | s->data_block_quadlets = s->pcm_channels; | ||
| 129 | s->data_block_quadlets += DIV_ROUND_UP(s->midi_ports, 8); | ||
| 130 | |||
| 131 | return 8 + max_data_blocks[s->sfc] * 4 * s->data_block_quadlets; | ||
| 132 | } | 147 | } |
| 133 | EXPORT_SYMBOL(amdtp_out_stream_get_max_payload); | 148 | EXPORT_SYMBOL(amdtp_out_stream_get_max_payload); |
| 134 | 149 | ||
| @@ -138,19 +153,26 @@ static void amdtp_write_s16(struct amdtp_out_stream *s, | |||
| 138 | static void amdtp_write_s32(struct amdtp_out_stream *s, | 153 | static void amdtp_write_s32(struct amdtp_out_stream *s, |
| 139 | struct snd_pcm_substream *pcm, | 154 | struct snd_pcm_substream *pcm, |
| 140 | __be32 *buffer, unsigned int frames); | 155 | __be32 *buffer, unsigned int frames); |
| 156 | static void amdtp_write_s16_dualwire(struct amdtp_out_stream *s, | ||
| 157 | struct snd_pcm_substream *pcm, | ||
| 158 | __be32 *buffer, unsigned int frames); | ||
| 159 | static void amdtp_write_s32_dualwire(struct amdtp_out_stream *s, | ||
| 160 | struct snd_pcm_substream *pcm, | ||
| 161 | __be32 *buffer, unsigned int frames); | ||
| 141 | 162 | ||
| 142 | /** | 163 | /** |
| 143 | * amdtp_out_stream_set_pcm_format - set the PCM format | 164 | * amdtp_out_stream_set_pcm_format - set the PCM format |
| 144 | * @s: the AMDTP output stream to configure | 165 | * @s: the AMDTP output stream to configure |
| 145 | * @format: the format of the ALSA PCM device | 166 | * @format: the format of the ALSA PCM device |
| 146 | * | 167 | * |
| 147 | * The sample format must be set before the stream is started, and must not be | 168 | * The sample format must be set after the other paramters (rate/PCM channels/ |
| 148 | * changed while the stream is running. | 169 | * MIDI) and before the stream is started, and must not be changed while the |
| 170 | * stream is running. | ||
| 149 | */ | 171 | */ |
| 150 | void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s, | 172 | void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s, |
| 151 | snd_pcm_format_t format) | 173 | snd_pcm_format_t format) |
| 152 | { | 174 | { |
| 153 | if (WARN_ON(!IS_ERR(s->context))) | 175 | if (WARN_ON(amdtp_out_stream_running(s))) |
| 154 | return; | 176 | return; |
| 155 | 177 | ||
| 156 | switch (format) { | 178 | switch (format) { |
| @@ -158,10 +180,16 @@ void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s, | |||
| 158 | WARN_ON(1); | 180 | WARN_ON(1); |
| 159 | /* fall through */ | 181 | /* fall through */ |
| 160 | case SNDRV_PCM_FORMAT_S16: | 182 | case SNDRV_PCM_FORMAT_S16: |
| 161 | s->transfer_samples = amdtp_write_s16; | 183 | if (s->dual_wire) |
| 184 | s->transfer_samples = amdtp_write_s16_dualwire; | ||
| 185 | else | ||
| 186 | s->transfer_samples = amdtp_write_s16; | ||
| 162 | break; | 187 | break; |
| 163 | case SNDRV_PCM_FORMAT_S32: | 188 | case SNDRV_PCM_FORMAT_S32: |
| 164 | s->transfer_samples = amdtp_write_s32; | 189 | if (s->dual_wire) |
| 190 | s->transfer_samples = amdtp_write_s32_dualwire; | ||
| 191 | else | ||
| 192 | s->transfer_samples = amdtp_write_s32; | ||
| 165 | break; | 193 | break; |
| 166 | } | 194 | } |
| 167 | } | 195 | } |
| @@ -248,7 +276,7 @@ static unsigned int calculate_syt(struct amdtp_out_stream *s, | |||
| 248 | s->last_syt_offset = syt_offset; | 276 | s->last_syt_offset = syt_offset; |
| 249 | 277 | ||
| 250 | if (syt_offset < TICKS_PER_CYCLE) { | 278 | if (syt_offset < TICKS_PER_CYCLE) { |
| 251 | syt_offset += TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE; | 279 | syt_offset += s->transfer_delay; |
| 252 | syt = (cycle + syt_offset / TICKS_PER_CYCLE) << 12; | 280 | syt = (cycle + syt_offset / TICKS_PER_CYCLE) << 12; |
| 253 | syt += syt_offset % TICKS_PER_CYCLE; | 281 | syt += syt_offset % TICKS_PER_CYCLE; |
| 254 | 282 | ||
| @@ -268,7 +296,7 @@ static void amdtp_write_s32(struct amdtp_out_stream *s, | |||
| 268 | 296 | ||
| 269 | channels = s->pcm_channels; | 297 | channels = s->pcm_channels; |
| 270 | src = (void *)runtime->dma_area + | 298 | src = (void *)runtime->dma_area + |
| 271 | s->pcm_buffer_pointer * (runtime->frame_bits / 8); | 299 | frames_to_bytes(runtime, s->pcm_buffer_pointer); |
| 272 | remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer; | 300 | remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer; |
| 273 | frame_step = s->data_block_quadlets - channels; | 301 | frame_step = s->data_block_quadlets - channels; |
| 274 | 302 | ||
| @@ -294,7 +322,7 @@ static void amdtp_write_s16(struct amdtp_out_stream *s, | |||
| 294 | 322 | ||
| 295 | channels = s->pcm_channels; | 323 | channels = s->pcm_channels; |
| 296 | src = (void *)runtime->dma_area + | 324 | src = (void *)runtime->dma_area + |
| 297 | s->pcm_buffer_pointer * (runtime->frame_bits / 8); | 325 | frames_to_bytes(runtime, s->pcm_buffer_pointer); |
| 298 | remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer; | 326 | remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer; |
| 299 | frame_step = s->data_block_quadlets - channels; | 327 | frame_step = s->data_block_quadlets - channels; |
| 300 | 328 | ||
| @@ -310,6 +338,68 @@ static void amdtp_write_s16(struct amdtp_out_stream *s, | |||
| 310 | } | 338 | } |
| 311 | } | 339 | } |
| 312 | 340 | ||
| 341 | static void amdtp_write_s32_dualwire(struct amdtp_out_stream *s, | ||
| 342 | struct snd_pcm_substream *pcm, | ||
| 343 | __be32 *buffer, unsigned int frames) | ||
| 344 | { | ||
| 345 | struct snd_pcm_runtime *runtime = pcm->runtime; | ||
| 346 | unsigned int channels, frame_adjust_1, frame_adjust_2, i, c; | ||
| 347 | const u32 *src; | ||
| 348 | |||
| 349 | channels = s->pcm_channels; | ||
| 350 | src = (void *)runtime->dma_area + | ||
| 351 | s->pcm_buffer_pointer * (runtime->frame_bits / 8); | ||
| 352 | frame_adjust_1 = channels - 1; | ||
| 353 | frame_adjust_2 = 1 - (s->data_block_quadlets - channels); | ||
| 354 | |||
| 355 | channels /= 2; | ||
| 356 | for (i = 0; i < frames; ++i) { | ||
| 357 | for (c = 0; c < channels; ++c) { | ||
| 358 | *buffer = cpu_to_be32((*src >> 8) | 0x40000000); | ||
| 359 | src++; | ||
| 360 | buffer += 2; | ||
| 361 | } | ||
| 362 | buffer -= frame_adjust_1; | ||
| 363 | for (c = 0; c < channels; ++c) { | ||
| 364 | *buffer = cpu_to_be32((*src >> 8) | 0x40000000); | ||
| 365 | src++; | ||
| 366 | buffer += 2; | ||
| 367 | } | ||
| 368 | buffer -= frame_adjust_2; | ||
| 369 | } | ||
| 370 | } | ||
| 371 | |||
| 372 | static void amdtp_write_s16_dualwire(struct amdtp_out_stream *s, | ||
| 373 | struct snd_pcm_substream *pcm, | ||
| 374 | __be32 *buffer, unsigned int frames) | ||
| 375 | { | ||
| 376 | struct snd_pcm_runtime *runtime = pcm->runtime; | ||
| 377 | unsigned int channels, frame_adjust_1, frame_adjust_2, i, c; | ||
| 378 | const u16 *src; | ||
| 379 | |||
| 380 | channels = s->pcm_channels; | ||
| 381 | src = (void *)runtime->dma_area + | ||
| 382 | s->pcm_buffer_pointer * (runtime->frame_bits / 8); | ||
| 383 | frame_adjust_1 = channels - 1; | ||
| 384 | frame_adjust_2 = 1 - (s->data_block_quadlets - channels); | ||
| 385 | |||
| 386 | channels /= 2; | ||
| 387 | for (i = 0; i < frames; ++i) { | ||
| 388 | for (c = 0; c < channels; ++c) { | ||
| 389 | *buffer = cpu_to_be32((*src << 8) | 0x40000000); | ||
| 390 | src++; | ||
| 391 | buffer += 2; | ||
| 392 | } | ||
| 393 | buffer -= frame_adjust_1; | ||
| 394 | for (c = 0; c < channels; ++c) { | ||
| 395 | *buffer = cpu_to_be32((*src << 8) | 0x40000000); | ||
| 396 | src++; | ||
| 397 | buffer += 2; | ||
| 398 | } | ||
| 399 | buffer -= frame_adjust_2; | ||
| 400 | } | ||
| 401 | } | ||
| 402 | |||
| 313 | static void amdtp_fill_pcm_silence(struct amdtp_out_stream *s, | 403 | static void amdtp_fill_pcm_silence(struct amdtp_out_stream *s, |
| 314 | __be32 *buffer, unsigned int frames) | 404 | __be32 *buffer, unsigned int frames) |
| 315 | { | 405 | { |
| @@ -344,8 +434,17 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle) | |||
| 344 | return; | 434 | return; |
| 345 | index = s->packet_index; | 435 | index = s->packet_index; |
| 346 | 436 | ||
| 347 | data_blocks = calculate_data_blocks(s); | ||
| 348 | syt = calculate_syt(s, cycle); | 437 | syt = calculate_syt(s, cycle); |
| 438 | if (!(s->flags & CIP_BLOCKING)) { | ||
| 439 | data_blocks = calculate_data_blocks(s); | ||
| 440 | } else { | ||
| 441 | if (syt != 0xffff) { | ||
| 442 | data_blocks = s->syt_interval; | ||
| 443 | } else { | ||
| 444 | data_blocks = 0; | ||
| 445 | syt = 0xffffff; | ||
| 446 | } | ||
| 447 | } | ||
| 349 | 448 | ||
| 350 | buffer = s->buffer.packets[index].buffer; | 449 | buffer = s->buffer.packets[index].buffer; |
| 351 | buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) | | 450 | buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) | |
| @@ -386,6 +485,9 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle) | |||
| 386 | s->packet_index = index; | 485 | s->packet_index = index; |
| 387 | 486 | ||
| 388 | if (pcm) { | 487 | if (pcm) { |
| 488 | if (s->dual_wire) | ||
| 489 | data_blocks *= 2; | ||
| 490 | |||
| 389 | ptr = s->pcm_buffer_pointer + data_blocks; | 491 | ptr = s->pcm_buffer_pointer + data_blocks; |
| 390 | if (ptr >= pcm->runtime->buffer_size) | 492 | if (ptr >= pcm->runtime->buffer_size) |
| 391 | ptr -= pcm->runtime->buffer_size; | 493 | ptr -= pcm->runtime->buffer_size; |
| @@ -455,9 +557,8 @@ static int queue_initial_skip_packets(struct amdtp_out_stream *s) | |||
| 455 | * @speed: firewire speed code | 557 | * @speed: firewire speed code |
| 456 | * | 558 | * |
| 457 | * The stream cannot be started until it has been configured with | 559 | * The stream cannot be started until it has been configured with |
| 458 | * amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and | 560 | * amdtp_out_stream_set_parameters() and amdtp_out_stream_set_pcm_format(), |
| 459 | * amdtp_out_stream_set_midi(); and it must be started before any | 561 | * and it must be started before any PCM or MIDI device can be started. |
| 460 | * PCM or MIDI device can be started. | ||
| 461 | */ | 562 | */ |
| 462 | int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed) | 563 | int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed) |
| 463 | { | 564 | { |
| @@ -477,7 +578,7 @@ int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed) | |||
| 477 | 578 | ||
| 478 | mutex_lock(&s->mutex); | 579 | mutex_lock(&s->mutex); |
| 479 | 580 | ||
| 480 | if (WARN_ON(!IS_ERR(s->context) || | 581 | if (WARN_ON(amdtp_out_stream_running(s) || |
| 481 | (!s->pcm_channels && !s->midi_ports))) { | 582 | (!s->pcm_channels && !s->midi_ports))) { |
| 482 | err = -EBADFD; | 583 | err = -EBADFD; |
| 483 | goto err_unlock; | 584 | goto err_unlock; |
| @@ -573,7 +674,7 @@ void amdtp_out_stream_stop(struct amdtp_out_stream *s) | |||
| 573 | { | 674 | { |
| 574 | mutex_lock(&s->mutex); | 675 | mutex_lock(&s->mutex); |
| 575 | 676 | ||
| 576 | if (IS_ERR(s->context)) { | 677 | if (!amdtp_out_stream_running(s)) { |
| 577 | mutex_unlock(&s->mutex); | 678 | mutex_unlock(&s->mutex); |
| 578 | return; | 679 | return; |
| 579 | } | 680 | } |
diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h index f6103d68c4b1..2746ecd291af 100644 --- a/sound/firewire/amdtp.h +++ b/sound/firewire/amdtp.h | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | #ifndef SOUND_FIREWIRE_AMDTP_H_INCLUDED | 1 | #ifndef SOUND_FIREWIRE_AMDTP_H_INCLUDED |
| 2 | #define SOUND_FIREWIRE_AMDTP_H_INCLUDED | 2 | #define SOUND_FIREWIRE_AMDTP_H_INCLUDED |
| 3 | 3 | ||
| 4 | #include <linux/err.h> | ||
| 4 | #include <linux/interrupt.h> | 5 | #include <linux/interrupt.h> |
| 5 | #include <linux/mutex.h> | 6 | #include <linux/mutex.h> |
| 7 | #include <sound/asound.h> | ||
| 6 | #include "packets-buffer.h" | 8 | #include "packets-buffer.h" |
| 7 | 9 | ||
| 8 | /** | 10 | /** |
| @@ -11,9 +13,18 @@ | |||
| 11 | * sample_rate/8000 samples, with rounding up or down to adjust | 13 | * sample_rate/8000 samples, with rounding up or down to adjust |
| 12 | * for clock skew and left-over fractional samples. This should | 14 | * for clock skew and left-over fractional samples. This should |
| 13 | * be used if supported by the device. | 15 | * be used if supported by the device. |
| 16 | * @CIP_BLOCKING: In blocking mode, each packet contains either zero or | ||
| 17 | * SYT_INTERVAL samples, with these two types alternating so that | ||
| 18 | * the overall sample rate comes out right. | ||
| 19 | * @CIP_HI_DUALWIRE: At rates above 96 kHz, pretend that the stream runs | ||
| 20 | * at half the actual sample rate with twice the number of channels; | ||
| 21 | * two samples of a channel are stored consecutively in the packet. | ||
| 22 | * Requires blocking mode and SYT_INTERVAL-aligned PCM buffer size. | ||
| 14 | */ | 23 | */ |
| 15 | enum cip_out_flags { | 24 | enum cip_out_flags { |
| 16 | CIP_NONBLOCKING = 0, | 25 | CIP_NONBLOCKING = 0x00, |
| 26 | CIP_BLOCKING = 0x01, | ||
| 27 | CIP_HI_DUALWIRE = 0x02, | ||
| 17 | }; | 28 | }; |
| 18 | 29 | ||
| 19 | /** | 30 | /** |
| @@ -27,6 +38,7 @@ enum cip_sfc { | |||
| 27 | CIP_SFC_96000 = 4, | 38 | CIP_SFC_96000 = 4, |
| 28 | CIP_SFC_176400 = 5, | 39 | CIP_SFC_176400 = 5, |
| 29 | CIP_SFC_192000 = 6, | 40 | CIP_SFC_192000 = 6, |
| 41 | CIP_SFC_COUNT | ||
| 30 | }; | 42 | }; |
| 31 | 43 | ||
| 32 | #define AMDTP_OUT_PCM_FORMAT_BITS (SNDRV_PCM_FMTBIT_S16 | \ | 44 | #define AMDTP_OUT_PCM_FORMAT_BITS (SNDRV_PCM_FMTBIT_S16 | \ |
| @@ -43,6 +55,7 @@ struct amdtp_out_stream { | |||
| 43 | struct mutex mutex; | 55 | struct mutex mutex; |
| 44 | 56 | ||
| 45 | enum cip_sfc sfc; | 57 | enum cip_sfc sfc; |
| 58 | bool dual_wire; | ||
| 46 | unsigned int data_block_quadlets; | 59 | unsigned int data_block_quadlets; |
| 47 | unsigned int pcm_channels; | 60 | unsigned int pcm_channels; |
| 48 | unsigned int midi_ports; | 61 | unsigned int midi_ports; |
| @@ -51,6 +64,7 @@ struct amdtp_out_stream { | |||
| 51 | __be32 *buffer, unsigned int frames); | 64 | __be32 *buffer, unsigned int frames); |
| 52 | 65 | ||
| 53 | unsigned int syt_interval; | 66 | unsigned int syt_interval; |
| 67 | unsigned int transfer_delay; | ||
| 54 | unsigned int source_node_id_field; | 68 | unsigned int source_node_id_field; |
| 55 | struct iso_packets_buffer buffer; | 69 | struct iso_packets_buffer buffer; |
| 56 | 70 | ||
| @@ -74,7 +88,10 @@ int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, | |||
| 74 | enum cip_out_flags flags); | 88 | enum cip_out_flags flags); |
| 75 | void amdtp_out_stream_destroy(struct amdtp_out_stream *s); | 89 | void amdtp_out_stream_destroy(struct amdtp_out_stream *s); |
| 76 | 90 | ||
| 77 | void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate); | 91 | void amdtp_out_stream_set_parameters(struct amdtp_out_stream *s, |
| 92 | unsigned int rate, | ||
| 93 | unsigned int pcm_channels, | ||
| 94 | unsigned int midi_ports); | ||
| 78 | unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s); | 95 | unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s); |
| 79 | 96 | ||
| 80 | int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed); | 97 | int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed); |
| @@ -87,31 +104,11 @@ void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s); | |||
| 87 | unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s); | 104 | unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s); |
| 88 | void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s); | 105 | void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s); |
| 89 | 106 | ||
| 90 | /** | 107 | extern const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT]; |
| 91 | * amdtp_out_stream_set_pcm - configure format of PCM samples | ||
| 92 | * @s: the AMDTP output stream to be configured | ||
| 93 | * @pcm_channels: the number of PCM samples in each data block, to be encoded | ||
| 94 | * as AM824 multi-bit linear audio | ||
| 95 | * | ||
| 96 | * This function must not be called while the stream is running. | ||
| 97 | */ | ||
| 98 | static inline void amdtp_out_stream_set_pcm(struct amdtp_out_stream *s, | ||
| 99 | unsigned int pcm_channels) | ||
| 100 | { | ||
| 101 | s->pcm_channels = pcm_channels; | ||
| 102 | } | ||
| 103 | 108 | ||
| 104 | /** | 109 | static inline bool amdtp_out_stream_running(struct amdtp_out_stream *s) |
| 105 | * amdtp_out_stream_set_midi - configure format of MIDI data | ||
| 106 | * @s: the AMDTP output stream to be configured | ||
| 107 | * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels) | ||
| 108 | * | ||
| 109 | * This function must not be called while the stream is running. | ||
| 110 | */ | ||
| 111 | static inline void amdtp_out_stream_set_midi(struct amdtp_out_stream *s, | ||
| 112 | unsigned int midi_ports) | ||
| 113 | { | 110 | { |
| 114 | s->midi_ports = midi_ports; | 111 | return !IS_ERR(s->context); |
| 115 | } | 112 | } |
| 116 | 113 | ||
| 117 | /** | 114 | /** |
diff --git a/sound/firewire/cmp.c b/sound/firewire/cmp.c index 645cb0ba4293..efdbf585e404 100644 --- a/sound/firewire/cmp.c +++ b/sound/firewire/cmp.c | |||
| @@ -48,9 +48,6 @@ static int pcr_modify(struct cmp_connection *c, | |||
| 48 | int (*check)(struct cmp_connection *c, __be32 pcr), | 48 | int (*check)(struct cmp_connection *c, __be32 pcr), |
| 49 | enum bus_reset_handling bus_reset_handling) | 49 | enum bus_reset_handling bus_reset_handling) |
| 50 | { | 50 | { |
| 51 | struct fw_device *device = fw_parent_device(c->resources.unit); | ||
| 52 | int generation = c->resources.generation; | ||
| 53 | int rcode, errors = 0; | ||
| 54 | __be32 old_arg, buffer[2]; | 51 | __be32 old_arg, buffer[2]; |
| 55 | int err; | 52 | int err; |
| 56 | 53 | ||
| @@ -59,36 +56,31 @@ static int pcr_modify(struct cmp_connection *c, | |||
| 59 | old_arg = buffer[0]; | 56 | old_arg = buffer[0]; |
| 60 | buffer[1] = modify(c, buffer[0]); | 57 | buffer[1] = modify(c, buffer[0]); |
| 61 | 58 | ||
| 62 | rcode = fw_run_transaction( | 59 | err = snd_fw_transaction( |
| 63 | device->card, TCODE_LOCK_COMPARE_SWAP, | 60 | c->resources.unit, TCODE_LOCK_COMPARE_SWAP, |
| 64 | device->node_id, generation, device->max_speed, | ||
| 65 | CSR_REGISTER_BASE + CSR_IPCR(c->pcr_index), | 61 | CSR_REGISTER_BASE + CSR_IPCR(c->pcr_index), |
| 66 | buffer, 8); | 62 | buffer, 8, |
| 67 | 63 | FW_FIXED_GENERATION | c->resources.generation); | |
| 68 | if (rcode == RCODE_COMPLETE) { | 64 | |
| 69 | if (buffer[0] == old_arg) /* success? */ | 65 | if (err < 0) { |
| 70 | break; | 66 | if (err == -EAGAIN && |
| 71 | 67 | bus_reset_handling == SUCCEED_ON_BUS_RESET) | |
| 72 | if (check) { | 68 | err = 0; |
| 73 | err = check(c, buffer[0]); | 69 | return err; |
| 74 | if (err < 0) | 70 | } |
| 75 | return err; | 71 | |
| 76 | } | 72 | if (buffer[0] == old_arg) /* success? */ |
| 77 | } else if (rcode == RCODE_GENERATION) | 73 | break; |
| 78 | goto bus_reset; | 74 | |
| 79 | else if (rcode_is_permanent_error(rcode) || ++errors >= 3) | 75 | if (check) { |
| 80 | goto io_error; | 76 | err = check(c, buffer[0]); |
| 77 | if (err < 0) | ||
| 78 | return err; | ||
| 79 | } | ||
| 81 | } | 80 | } |
| 82 | c->last_pcr_value = buffer[1]; | 81 | c->last_pcr_value = buffer[1]; |
| 83 | 82 | ||
| 84 | return 0; | 83 | return 0; |
| 85 | |||
| 86 | io_error: | ||
| 87 | cmp_error(c, "transaction failed: %s\n", fw_rcode_string(rcode)); | ||
| 88 | return -EIO; | ||
| 89 | |||
| 90 | bus_reset: | ||
| 91 | return bus_reset_handling == ABORT_ON_BUS_RESET ? -EAGAIN : 0; | ||
| 92 | } | 84 | } |
| 93 | 85 | ||
| 94 | 86 | ||
| @@ -108,7 +100,7 @@ int cmp_connection_init(struct cmp_connection *c, | |||
| 108 | 100 | ||
| 109 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, | 101 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, |
| 110 | CSR_REGISTER_BASE + CSR_IMPR, | 102 | CSR_REGISTER_BASE + CSR_IMPR, |
| 111 | &impr_be, 4); | 103 | &impr_be, 4, 0); |
| 112 | if (err < 0) | 104 | if (err < 0) |
| 113 | return err; | 105 | return err; |
| 114 | impr = be32_to_cpu(impr_be); | 106 | impr = be32_to_cpu(impr_be); |
diff --git a/sound/firewire/dice-interface.h b/sound/firewire/dice-interface.h new file mode 100644 index 000000000000..27b044f84c81 --- /dev/null +++ b/sound/firewire/dice-interface.h | |||
| @@ -0,0 +1,371 @@ | |||
| 1 | #ifndef SOUND_FIREWIRE_DICE_INTERFACE_H_INCLUDED | ||
| 2 | #define SOUND_FIREWIRE_DICE_INTERFACE_H_INCLUDED | ||
| 3 | |||
| 4 | /* | ||
| 5 | * DICE device interface definitions | ||
| 6 | */ | ||
| 7 | |||
| 8 | /* | ||
| 9 | * Generally, all registers can be read like memory, i.e., with quadlet read or | ||
| 10 | * block read transactions with at least quadlet-aligned offset and length. | ||
| 11 | * Writes are not allowed except where noted; quadlet-sized registers must be | ||
| 12 | * written with a quadlet write transaction. | ||
| 13 | * | ||
| 14 | * All values are in big endian. The DICE firmware runs on a little-endian CPU | ||
| 15 | * and just byte-swaps _all_ quadlets on the bus, so values without endianness | ||
| 16 | * (e.g. strings) get scrambled and must be byte-swapped again by the driver. | ||
| 17 | */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * Streaming is handled by the "DICE driver" interface. Its registers are | ||
| 21 | * located in this private address space. | ||
| 22 | */ | ||
| 23 | #define DICE_PRIVATE_SPACE 0xffffe0000000uLL | ||
| 24 | |||
| 25 | /* | ||
| 26 | * The registers are organized in several sections, which are organized | ||
| 27 | * separately to allow them to be extended individually. Whether a register is | ||
| 28 | * supported can be detected by checking its offset against its section's size. | ||
| 29 | * | ||
| 30 | * The section offset values are relative to DICE_PRIVATE_SPACE; the offset/ | ||
| 31 | * size values are measured in quadlets. Read-only. | ||
| 32 | */ | ||
| 33 | #define DICE_GLOBAL_OFFSET 0x00 | ||
| 34 | #define DICE_GLOBAL_SIZE 0x04 | ||
| 35 | #define DICE_TX_OFFSET 0x08 | ||
| 36 | #define DICE_TX_SIZE 0x0c | ||
| 37 | #define DICE_RX_OFFSET 0x10 | ||
| 38 | #define DICE_RX_SIZE 0x14 | ||
| 39 | #define DICE_EXT_SYNC_OFFSET 0x18 | ||
| 40 | #define DICE_EXT_SYNC_SIZE 0x1c | ||
| 41 | #define DICE_UNUSED2_OFFSET 0x20 | ||
| 42 | #define DICE_UNUSED2_SIZE 0x24 | ||
| 43 | |||
| 44 | /* | ||
| 45 | * Global settings. | ||
| 46 | */ | ||
| 47 | |||
| 48 | /* | ||
| 49 | * Stores the full 64-bit address (node ID and offset in the node's address | ||
| 50 | * space) where the device will send notifications. Must be changed with | ||
| 51 | * a compare/swap transaction by the owner. This register is automatically | ||
| 52 | * cleared on a bus reset. | ||
| 53 | */ | ||
| 54 | #define GLOBAL_OWNER 0x000 | ||
| 55 | #define OWNER_NO_OWNER 0xffff000000000000uLL | ||
| 56 | #define OWNER_NODE_SHIFT 48 | ||
| 57 | |||
| 58 | /* | ||
| 59 | * A bitmask with asynchronous events; read-only. When any event(s) happen, | ||
| 60 | * the bits of previous events are cleared, and the value of this register is | ||
| 61 | * also written to the address stored in the owner register. | ||
| 62 | */ | ||
| 63 | #define GLOBAL_NOTIFICATION 0x008 | ||
| 64 | /* Some registers in the Rx/Tx sections may have changed. */ | ||
| 65 | #define NOTIFY_RX_CFG_CHG 0x00000001 | ||
| 66 | #define NOTIFY_TX_CFG_CHG 0x00000002 | ||
| 67 | /* Lock status of the current clock source may have changed. */ | ||
| 68 | #define NOTIFY_LOCK_CHG 0x00000010 | ||
| 69 | /* Write to the clock select register has been finished. */ | ||
| 70 | #define NOTIFY_CLOCK_ACCEPTED 0x00000020 | ||
| 71 | /* Lock status of some clock source has changed. */ | ||
| 72 | #define NOTIFY_EXT_STATUS 0x00000040 | ||
| 73 | /* Other bits may be used for device-specific events. */ | ||
| 74 | |||
| 75 | /* | ||
| 76 | * A name that can be customized for each device; read/write. Padded with zero | ||
| 77 | * bytes. Quadlets are byte-swapped. The encoding is whatever the host driver | ||
| 78 | * happens to be using. | ||
| 79 | */ | ||
| 80 | #define GLOBAL_NICK_NAME 0x00c | ||
| 81 | #define NICK_NAME_SIZE 64 | ||
| 82 | |||
| 83 | /* | ||
| 84 | * The current sample rate and clock source; read/write. Whether a clock | ||
| 85 | * source or sample rate is supported is device-specific; the internal clock | ||
| 86 | * source is always available. Low/mid/high = up to 48/96/192 kHz. This | ||
| 87 | * register can be changed even while streams are running. | ||
| 88 | */ | ||
| 89 | #define GLOBAL_CLOCK_SELECT 0x04c | ||
| 90 | #define CLOCK_SOURCE_MASK 0x000000ff | ||
| 91 | #define CLOCK_SOURCE_AES1 0x00000000 | ||
| 92 | #define CLOCK_SOURCE_AES2 0x00000001 | ||
| 93 | #define CLOCK_SOURCE_AES3 0x00000002 | ||
| 94 | #define CLOCK_SOURCE_AES4 0x00000003 | ||
| 95 | #define CLOCK_SOURCE_AES_ANY 0x00000004 | ||
| 96 | #define CLOCK_SOURCE_ADAT 0x00000005 | ||
| 97 | #define CLOCK_SOURCE_TDIF 0x00000006 | ||
| 98 | #define CLOCK_SOURCE_WC 0x00000007 | ||
| 99 | #define CLOCK_SOURCE_ARX1 0x00000008 | ||
| 100 | #define CLOCK_SOURCE_ARX2 0x00000009 | ||
| 101 | #define CLOCK_SOURCE_ARX3 0x0000000a | ||
| 102 | #define CLOCK_SOURCE_ARX4 0x0000000b | ||
| 103 | #define CLOCK_SOURCE_INTERNAL 0x0000000c | ||
| 104 | #define CLOCK_RATE_MASK 0x0000ff00 | ||
| 105 | #define CLOCK_RATE_32000 0x00000000 | ||
| 106 | #define CLOCK_RATE_44100 0x00000100 | ||
| 107 | #define CLOCK_RATE_48000 0x00000200 | ||
| 108 | #define CLOCK_RATE_88200 0x00000300 | ||
| 109 | #define CLOCK_RATE_96000 0x00000400 | ||
| 110 | #define CLOCK_RATE_176400 0x00000500 | ||
| 111 | #define CLOCK_RATE_192000 0x00000600 | ||
| 112 | #define CLOCK_RATE_ANY_LOW 0x00000700 | ||
| 113 | #define CLOCK_RATE_ANY_MID 0x00000800 | ||
| 114 | #define CLOCK_RATE_ANY_HIGH 0x00000900 | ||
| 115 | #define CLOCK_RATE_NONE 0x00000a00 | ||
| 116 | #define CLOCK_RATE_SHIFT 8 | ||
| 117 | |||
| 118 | /* | ||
| 119 | * Enable streaming; read/write. Writing a non-zero value (re)starts all | ||
| 120 | * streams that have a valid iso channel set; zero stops all streams. The | ||
| 121 | * streams' parameters must be configured before starting. This register is | ||
| 122 | * automatically cleared on a bus reset. | ||
| 123 | */ | ||
| 124 | #define GLOBAL_ENABLE 0x050 | ||
| 125 | |||
| 126 | /* | ||
| 127 | * Status of the sample clock; read-only. | ||
| 128 | */ | ||
| 129 | #define GLOBAL_STATUS 0x054 | ||
| 130 | /* The current clock source is locked. */ | ||
| 131 | #define STATUS_SOURCE_LOCKED 0x00000001 | ||
| 132 | /* The actual sample rate; CLOCK_RATE_32000-_192000 or _NONE. */ | ||
| 133 | #define STATUS_NOMINAL_RATE_MASK 0x0000ff00 | ||
| 134 | |||
| 135 | /* | ||
| 136 | * Status of all clock sources; read-only. | ||
| 137 | */ | ||
| 138 | #define GLOBAL_EXTENDED_STATUS 0x058 | ||
| 139 | /* | ||
| 140 | * The _LOCKED bits always show the current status; any change generates | ||
| 141 | * a notification. | ||
| 142 | */ | ||
| 143 | #define EXT_STATUS_AES1_LOCKED 0x00000001 | ||
| 144 | #define EXT_STATUS_AES2_LOCKED 0x00000002 | ||
| 145 | #define EXT_STATUS_AES3_LOCKED 0x00000004 | ||
| 146 | #define EXT_STATUS_AES4_LOCKED 0x00000008 | ||
| 147 | #define EXT_STATUS_ADAT_LOCKED 0x00000010 | ||
| 148 | #define EXT_STATUS_TDIF_LOCKED 0x00000020 | ||
| 149 | #define EXT_STATUS_ARX1_LOCKED 0x00000040 | ||
| 150 | #define EXT_STATUS_ARX2_LOCKED 0x00000080 | ||
| 151 | #define EXT_STATUS_ARX3_LOCKED 0x00000100 | ||
| 152 | #define EXT_STATUS_ARX4_LOCKED 0x00000200 | ||
| 153 | #define EXT_STATUS_WC_LOCKED 0x00000400 | ||
| 154 | /* | ||
| 155 | * The _SLIP bits do not generate notifications; a set bit indicates that an | ||
| 156 | * error occurred since the last time when this register was read with | ||
| 157 | * a quadlet read transaction. | ||
| 158 | */ | ||
| 159 | #define EXT_STATUS_AES1_SLIP 0x00010000 | ||
| 160 | #define EXT_STATUS_AES2_SLIP 0x00020000 | ||
| 161 | #define EXT_STATUS_AES3_SLIP 0x00040000 | ||
| 162 | #define EXT_STATUS_AES4_SLIP 0x00080000 | ||
| 163 | #define EXT_STATUS_ADAT_SLIP 0x00100000 | ||
| 164 | #define EXT_STATUS_TDIF_SLIP 0x00200000 | ||
| 165 | #define EXT_STATUS_ARX1_SLIP 0x00400000 | ||
| 166 | #define EXT_STATUS_ARX2_SLIP 0x00800000 | ||
| 167 | #define EXT_STATUS_ARX3_SLIP 0x01000000 | ||
| 168 | #define EXT_STATUS_ARX4_SLIP 0x02000000 | ||
| 169 | #define EXT_STATUS_WC_SLIP 0x04000000 | ||
| 170 | |||
| 171 | /* | ||
| 172 | * The measured rate of the current clock source, in Hz; read-only. | ||
| 173 | */ | ||
| 174 | #define GLOBAL_SAMPLE_RATE 0x05c | ||
| 175 | |||
| 176 | /* | ||
| 177 | * The version of the DICE driver specification that this device conforms to; | ||
| 178 | * read-only. | ||
| 179 | */ | ||
| 180 | #define GLOBAL_VERSION 0x060 | ||
| 181 | |||
| 182 | /* Some old firmware versions do not have the following global registers: */ | ||
| 183 | |||
| 184 | /* | ||
| 185 | * Supported sample rates and clock sources; read-only. | ||
| 186 | */ | ||
| 187 | #define GLOBAL_CLOCK_CAPABILITIES 0x064 | ||
| 188 | #define CLOCK_CAP_RATE_32000 0x00000001 | ||
| 189 | #define CLOCK_CAP_RATE_44100 0x00000002 | ||
| 190 | #define CLOCK_CAP_RATE_48000 0x00000004 | ||
| 191 | #define CLOCK_CAP_RATE_88200 0x00000008 | ||
| 192 | #define CLOCK_CAP_RATE_96000 0x00000010 | ||
| 193 | #define CLOCK_CAP_RATE_176400 0x00000020 | ||
| 194 | #define CLOCK_CAP_RATE_192000 0x00000040 | ||
| 195 | #define CLOCK_CAP_SOURCE_AES1 0x00010000 | ||
| 196 | #define CLOCK_CAP_SOURCE_AES2 0x00020000 | ||
| 197 | #define CLOCK_CAP_SOURCE_AES3 0x00040000 | ||
| 198 | #define CLOCK_CAP_SOURCE_AES4 0x00080000 | ||
| 199 | #define CLOCK_CAP_SOURCE_AES_ANY 0x00100000 | ||
| 200 | #define CLOCK_CAP_SOURCE_ADAT 0x00200000 | ||
| 201 | #define CLOCK_CAP_SOURCE_TDIF 0x00400000 | ||
| 202 | #define CLOCK_CAP_SOURCE_WC 0x00800000 | ||
| 203 | #define CLOCK_CAP_SOURCE_ARX1 0x01000000 | ||
| 204 | #define CLOCK_CAP_SOURCE_ARX2 0x02000000 | ||
| 205 | #define CLOCK_CAP_SOURCE_ARX3 0x04000000 | ||
| 206 | #define CLOCK_CAP_SOURCE_ARX4 0x08000000 | ||
| 207 | #define CLOCK_CAP_SOURCE_INTERNAL 0x10000000 | ||
| 208 | |||
| 209 | /* | ||
| 210 | * Names of all clock sources; read-only. Quadlets are byte-swapped. Names | ||
| 211 | * are separated with one backslash, the list is terminated with two | ||
| 212 | * backslashes. Unused clock sources are included. | ||
| 213 | */ | ||
| 214 | #define GLOBAL_CLOCK_SOURCE_NAMES 0x068 | ||
| 215 | #define CLOCK_SOURCE_NAMES_SIZE 256 | ||
| 216 | |||
| 217 | /* | ||
| 218 | * Capture stream settings. This section includes the number/size registers | ||
| 219 | * and the registers of all streams. | ||
| 220 | */ | ||
| 221 | |||
| 222 | /* | ||
| 223 | * The number of supported capture streams; read-only. | ||
| 224 | */ | ||
| 225 | #define TX_NUMBER 0x000 | ||
| 226 | |||
| 227 | /* | ||
| 228 | * The size of one stream's register block, in quadlets; read-only. The | ||
| 229 | * registers of the first stream follow immediately afterwards; the registers | ||
| 230 | * of the following streams are offset by this register's value. | ||
| 231 | */ | ||
| 232 | #define TX_SIZE 0x004 | ||
| 233 | |||
| 234 | /* | ||
| 235 | * The isochronous channel number on which packets are sent, or -1 if the | ||
| 236 | * stream is not to be used; read/write. | ||
| 237 | */ | ||
| 238 | #define TX_ISOCHRONOUS 0x008 | ||
| 239 | |||
| 240 | /* | ||
| 241 | * The number of audio channels; read-only. There will be one quadlet per | ||
| 242 | * channel; the first channel is the first quadlet in a data block. | ||
| 243 | */ | ||
| 244 | #define TX_NUMBER_AUDIO 0x00c | ||
| 245 | |||
| 246 | /* | ||
| 247 | * The number of MIDI ports, 0-8; read-only. If > 0, there will be one | ||
| 248 | * additional quadlet in each data block, following the audio quadlets. | ||
| 249 | */ | ||
| 250 | #define TX_NUMBER_MIDI 0x010 | ||
| 251 | |||
| 252 | /* | ||
| 253 | * The speed at which the packets are sent, SCODE_100-_400; read/write. | ||
| 254 | */ | ||
| 255 | #define TX_SPEED 0x014 | ||
| 256 | |||
| 257 | /* | ||
| 258 | * Names of all audio channels; read-only. Quadlets are byte-swapped. Names | ||
| 259 | * are separated with one backslash, the list is terminated with two | ||
| 260 | * backslashes. | ||
| 261 | */ | ||
| 262 | #define TX_NAMES 0x018 | ||
| 263 | #define TX_NAMES_SIZE 256 | ||
| 264 | |||
| 265 | /* | ||
| 266 | * Audio IEC60958 capabilities; read-only. Bitmask with one bit per audio | ||
| 267 | * channel. | ||
| 268 | */ | ||
| 269 | #define TX_AC3_CAPABILITIES 0x118 | ||
| 270 | |||
| 271 | /* | ||
| 272 | * Send audio data with IEC60958 label; read/write. Bitmask with one bit per | ||
| 273 | * audio channel. This register can be changed even while the stream is | ||
| 274 | * running. | ||
| 275 | */ | ||
| 276 | #define TX_AC3_ENABLE 0x11c | ||
| 277 | |||
| 278 | /* | ||
| 279 | * Playback stream settings. This section includes the number/size registers | ||
| 280 | * and the registers of all streams. | ||
| 281 | */ | ||
| 282 | |||
| 283 | /* | ||
| 284 | * The number of supported playback streams; read-only. | ||
| 285 | */ | ||
| 286 | #define RX_NUMBER 0x000 | ||
| 287 | |||
| 288 | /* | ||
| 289 | * The size of one stream's register block, in quadlets; read-only. The | ||
| 290 | * registers of the first stream follow immediately afterwards; the registers | ||
| 291 | * of the following streams are offset by this register's value. | ||
| 292 | */ | ||
| 293 | #define RX_SIZE 0x004 | ||
| 294 | |||
| 295 | /* | ||
| 296 | * The isochronous channel number on which packets are received, or -1 if the | ||
| 297 | * stream is not to be used; read/write. | ||
| 298 | */ | ||
| 299 | #define RX_ISOCHRONOUS 0x008 | ||
| 300 | |||
| 301 | /* | ||
| 302 | * Index of first quadlet to be interpreted; read/write. If > 0, that many | ||
| 303 | * quadlets at the beginning of each data block will be ignored, and all the | ||
| 304 | * audio and MIDI quadlets will follow. | ||
| 305 | */ | ||
| 306 | #define RX_SEQ_START 0x00c | ||
| 307 | |||
| 308 | /* | ||
| 309 | * The number of audio channels; read-only. There will be one quadlet per | ||
| 310 | * channel. | ||
| 311 | */ | ||
| 312 | #define RX_NUMBER_AUDIO 0x010 | ||
| 313 | |||
| 314 | /* | ||
| 315 | * The number of MIDI ports, 0-8; read-only. If > 0, there will be one | ||
| 316 | * additional quadlet in each data block, following the audio quadlets. | ||
| 317 | */ | ||
| 318 | #define RX_NUMBER_MIDI 0x014 | ||
| 319 | |||
| 320 | /* | ||
| 321 | * Names of all audio channels; read-only. Quadlets are byte-swapped. Names | ||
| 322 | * are separated with one backslash, the list is terminated with two | ||
| 323 | * backslashes. | ||
| 324 | */ | ||
| 325 | #define RX_NAMES 0x018 | ||
| 326 | #define RX_NAMES_SIZE 256 | ||
| 327 | |||
| 328 | /* | ||
| 329 | * Audio IEC60958 capabilities; read-only. Bitmask with one bit per audio | ||
| 330 | * channel. | ||
| 331 | */ | ||
| 332 | #define RX_AC3_CAPABILITIES 0x118 | ||
| 333 | |||
| 334 | /* | ||
| 335 | * Receive audio data with IEC60958 label; read/write. Bitmask with one bit | ||
| 336 | * per audio channel. This register can be changed even while the stream is | ||
| 337 | * running. | ||
| 338 | */ | ||
| 339 | #define RX_AC3_ENABLE 0x11c | ||
| 340 | |||
| 341 | /* | ||
| 342 | * Extended synchronization information. | ||
| 343 | * This section can be read completely with a block read request. | ||
| 344 | */ | ||
| 345 | |||
| 346 | /* | ||
| 347 | * Current clock source; read-only. | ||
| 348 | */ | ||
| 349 | #define EXT_SYNC_CLOCK_SOURCE 0x000 | ||
| 350 | |||
| 351 | /* | ||
| 352 | * Clock source is locked (boolean); read-only. | ||
| 353 | */ | ||
| 354 | #define EXT_SYNC_LOCKED 0x004 | ||
| 355 | |||
| 356 | /* | ||
| 357 | * Current sample rate (CLOCK_RATE_* >> CLOCK_RATE_SHIFT), _32000-_192000 or | ||
| 358 | * _NONE; read-only. | ||
| 359 | */ | ||
| 360 | #define EXT_SYNC_RATE 0x008 | ||
| 361 | |||
| 362 | /* | ||
| 363 | * ADAT user data bits; read-only. | ||
| 364 | */ | ||
| 365 | #define EXT_SYNC_ADAT_USER_DATA 0x00c | ||
| 366 | /* The data bits, if available. */ | ||
| 367 | #define ADAT_USER_DATA_MASK 0x0f | ||
| 368 | /* The data bits are not available. */ | ||
| 369 | #define ADAT_USER_DATA_NO_DATA 0x10 | ||
| 370 | |||
| 371 | #endif | ||
diff --git a/sound/firewire/dice.c b/sound/firewire/dice.c new file mode 100644 index 000000000000..6feee6614193 --- /dev/null +++ b/sound/firewire/dice.c | |||
| @@ -0,0 +1,1494 @@ | |||
| 1 | /* | ||
| 2 | * TC Applied Technologies Digital Interface Communications Engine driver | ||
| 3 | * | ||
| 4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
| 5 | * Licensed under the terms of the GNU General Public License, version 2. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <linux/compat.h> | ||
| 9 | #include <linux/completion.h> | ||
| 10 | #include <linux/delay.h> | ||
| 11 | #include <linux/device.h> | ||
| 12 | #include <linux/firewire.h> | ||
| 13 | #include <linux/firewire-constants.h> | ||
| 14 | #include <linux/jiffies.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/mod_devicetable.h> | ||
| 17 | #include <linux/mutex.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | #include <linux/spinlock.h> | ||
| 20 | #include <linux/wait.h> | ||
| 21 | #include <sound/control.h> | ||
| 22 | #include <sound/core.h> | ||
| 23 | #include <sound/firewire.h> | ||
| 24 | #include <sound/hwdep.h> | ||
| 25 | #include <sound/info.h> | ||
| 26 | #include <sound/initval.h> | ||
| 27 | #include <sound/pcm.h> | ||
| 28 | #include <sound/pcm_params.h> | ||
| 29 | #include "amdtp.h" | ||
| 30 | #include "iso-resources.h" | ||
| 31 | #include "lib.h" | ||
| 32 | #include "dice-interface.h" | ||
| 33 | |||
| 34 | |||
| 35 | struct dice { | ||
| 36 | struct snd_card *card; | ||
| 37 | struct fw_unit *unit; | ||
| 38 | spinlock_t lock; | ||
| 39 | struct mutex mutex; | ||
| 40 | unsigned int global_offset; | ||
| 41 | unsigned int rx_offset; | ||
| 42 | unsigned int clock_caps; | ||
| 43 | unsigned int rx_channels[3]; | ||
| 44 | unsigned int rx_midi_ports[3]; | ||
| 45 | struct fw_address_handler notification_handler; | ||
| 46 | int owner_generation; | ||
| 47 | int dev_lock_count; /* > 0 driver, < 0 userspace */ | ||
| 48 | bool dev_lock_changed; | ||
| 49 | bool global_enabled; | ||
| 50 | struct completion clock_accepted; | ||
| 51 | wait_queue_head_t hwdep_wait; | ||
| 52 | u32 notification_bits; | ||
| 53 | struct fw_iso_resources resources; | ||
| 54 | struct amdtp_out_stream stream; | ||
| 55 | }; | ||
| 56 | |||
| 57 | MODULE_DESCRIPTION("DICE driver"); | ||
| 58 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | ||
| 59 | MODULE_LICENSE("GPL v2"); | ||
| 60 | |||
| 61 | static const unsigned int dice_rates[] = { | ||
| 62 | /* mode 0 */ | ||
| 63 | [0] = 32000, | ||
| 64 | [1] = 44100, | ||
| 65 | [2] = 48000, | ||
| 66 | /* mode 1 */ | ||
| 67 | [3] = 88200, | ||
| 68 | [4] = 96000, | ||
| 69 | /* mode 2 */ | ||
| 70 | [5] = 176400, | ||
| 71 | [6] = 192000, | ||
| 72 | }; | ||
| 73 | |||
| 74 | static unsigned int rate_to_index(unsigned int rate) | ||
| 75 | { | ||
| 76 | unsigned int i; | ||
| 77 | |||
| 78 | for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) | ||
| 79 | if (dice_rates[i] == rate) | ||
| 80 | return i; | ||
| 81 | |||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | static unsigned int rate_index_to_mode(unsigned int rate_index) | ||
| 86 | { | ||
| 87 | return ((int)rate_index - 1) / 2; | ||
| 88 | } | ||
| 89 | |||
| 90 | static void dice_lock_changed(struct dice *dice) | ||
| 91 | { | ||
| 92 | dice->dev_lock_changed = true; | ||
| 93 | wake_up(&dice->hwdep_wait); | ||
| 94 | } | ||
| 95 | |||
| 96 | static int dice_try_lock(struct dice *dice) | ||
| 97 | { | ||
| 98 | int err; | ||
| 99 | |||
| 100 | spin_lock_irq(&dice->lock); | ||
| 101 | |||
| 102 | if (dice->dev_lock_count < 0) { | ||
| 103 | err = -EBUSY; | ||
| 104 | goto out; | ||
| 105 | } | ||
| 106 | |||
| 107 | if (dice->dev_lock_count++ == 0) | ||
| 108 | dice_lock_changed(dice); | ||
| 109 | err = 0; | ||
| 110 | |||
| 111 | out: | ||
| 112 | spin_unlock_irq(&dice->lock); | ||
| 113 | |||
| 114 | return err; | ||
| 115 | } | ||
| 116 | |||
| 117 | static void dice_unlock(struct dice *dice) | ||
| 118 | { | ||
| 119 | spin_lock_irq(&dice->lock); | ||
| 120 | |||
| 121 | if (WARN_ON(dice->dev_lock_count <= 0)) | ||
| 122 | goto out; | ||
| 123 | |||
| 124 | if (--dice->dev_lock_count == 0) | ||
| 125 | dice_lock_changed(dice); | ||
| 126 | |||
| 127 | out: | ||
| 128 | spin_unlock_irq(&dice->lock); | ||
| 129 | } | ||
| 130 | |||
| 131 | static inline u64 global_address(struct dice *dice, unsigned int offset) | ||
| 132 | { | ||
| 133 | return DICE_PRIVATE_SPACE + dice->global_offset + offset; | ||
| 134 | } | ||
| 135 | |||
| 136 | // TODO: rx index | ||
| 137 | static inline u64 rx_address(struct dice *dice, unsigned int offset) | ||
| 138 | { | ||
| 139 | return DICE_PRIVATE_SPACE + dice->rx_offset + offset; | ||
| 140 | } | ||
| 141 | |||
| 142 | static int dice_owner_set(struct dice *dice) | ||
| 143 | { | ||
| 144 | struct fw_device *device = fw_parent_device(dice->unit); | ||
| 145 | __be64 *buffer; | ||
| 146 | int err, errors = 0; | ||
| 147 | |||
| 148 | buffer = kmalloc(2 * 8, GFP_KERNEL); | ||
| 149 | if (!buffer) | ||
| 150 | return -ENOMEM; | ||
| 151 | |||
| 152 | for (;;) { | ||
| 153 | buffer[0] = cpu_to_be64(OWNER_NO_OWNER); | ||
| 154 | buffer[1] = cpu_to_be64( | ||
| 155 | ((u64)device->card->node_id << OWNER_NODE_SHIFT) | | ||
| 156 | dice->notification_handler.offset); | ||
| 157 | |||
| 158 | dice->owner_generation = device->generation; | ||
| 159 | smp_rmb(); /* node_id vs. generation */ | ||
| 160 | err = snd_fw_transaction(dice->unit, | ||
| 161 | TCODE_LOCK_COMPARE_SWAP, | ||
| 162 | global_address(dice, GLOBAL_OWNER), | ||
| 163 | buffer, 2 * 8, | ||
| 164 | FW_FIXED_GENERATION | | ||
| 165 | dice->owner_generation); | ||
| 166 | |||
| 167 | if (err == 0) { | ||
| 168 | if (buffer[0] != cpu_to_be64(OWNER_NO_OWNER)) { | ||
| 169 | dev_err(&dice->unit->device, | ||
| 170 | "device is already in use\n"); | ||
| 171 | err = -EBUSY; | ||
| 172 | } | ||
| 173 | break; | ||
| 174 | } | ||
| 175 | if (err != -EAGAIN || ++errors >= 3) | ||
| 176 | break; | ||
| 177 | |||
| 178 | msleep(20); | ||
| 179 | } | ||
| 180 | |||
| 181 | kfree(buffer); | ||
| 182 | |||
| 183 | return err; | ||
| 184 | } | ||
| 185 | |||
| 186 | static int dice_owner_update(struct dice *dice) | ||
| 187 | { | ||
| 188 | struct fw_device *device = fw_parent_device(dice->unit); | ||
| 189 | __be64 *buffer; | ||
| 190 | int err; | ||
| 191 | |||
| 192 | if (dice->owner_generation == -1) | ||
| 193 | return 0; | ||
| 194 | |||
| 195 | buffer = kmalloc(2 * 8, GFP_KERNEL); | ||
| 196 | if (!buffer) | ||
| 197 | return -ENOMEM; | ||
| 198 | |||
| 199 | buffer[0] = cpu_to_be64(OWNER_NO_OWNER); | ||
| 200 | buffer[1] = cpu_to_be64( | ||
| 201 | ((u64)device->card->node_id << OWNER_NODE_SHIFT) | | ||
| 202 | dice->notification_handler.offset); | ||
| 203 | |||
| 204 | dice->owner_generation = device->generation; | ||
| 205 | smp_rmb(); /* node_id vs. generation */ | ||
| 206 | err = snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP, | ||
| 207 | global_address(dice, GLOBAL_OWNER), | ||
| 208 | buffer, 2 * 8, | ||
| 209 | FW_FIXED_GENERATION | dice->owner_generation); | ||
| 210 | |||
| 211 | if (err == 0) { | ||
| 212 | if (buffer[0] != cpu_to_be64(OWNER_NO_OWNER)) { | ||
| 213 | dev_err(&dice->unit->device, | ||
| 214 | "device is already in use\n"); | ||
| 215 | err = -EBUSY; | ||
| 216 | } | ||
| 217 | } else if (err == -EAGAIN) { | ||
| 218 | err = 0; /* try again later */ | ||
| 219 | } | ||
| 220 | |||
| 221 | kfree(buffer); | ||
| 222 | |||
| 223 | if (err < 0) | ||
| 224 | dice->owner_generation = -1; | ||
| 225 | |||
| 226 | return err; | ||
| 227 | } | ||
| 228 | |||
| 229 | static void dice_owner_clear(struct dice *dice) | ||
| 230 | { | ||
| 231 | struct fw_device *device = fw_parent_device(dice->unit); | ||
| 232 | __be64 *buffer; | ||
| 233 | |||
| 234 | buffer = kmalloc(2 * 8, GFP_KERNEL); | ||
| 235 | if (!buffer) | ||
| 236 | return; | ||
| 237 | |||
| 238 | buffer[0] = cpu_to_be64( | ||
| 239 | ((u64)device->card->node_id << OWNER_NODE_SHIFT) | | ||
| 240 | dice->notification_handler.offset); | ||
| 241 | buffer[1] = cpu_to_be64(OWNER_NO_OWNER); | ||
| 242 | snd_fw_transaction(dice->unit, TCODE_LOCK_COMPARE_SWAP, | ||
| 243 | global_address(dice, GLOBAL_OWNER), | ||
| 244 | buffer, 2 * 8, FW_QUIET | | ||
| 245 | FW_FIXED_GENERATION | dice->owner_generation); | ||
| 246 | |||
| 247 | kfree(buffer); | ||
| 248 | |||
| 249 | dice->owner_generation = -1; | ||
| 250 | } | ||
| 251 | |||
| 252 | static int dice_enable_set(struct dice *dice) | ||
| 253 | { | ||
| 254 | __be32 value; | ||
| 255 | int err; | ||
| 256 | |||
| 257 | value = cpu_to_be32(1); | ||
| 258 | err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 259 | global_address(dice, GLOBAL_ENABLE), | ||
| 260 | &value, 4, | ||
| 261 | FW_FIXED_GENERATION | dice->owner_generation); | ||
| 262 | if (err < 0) | ||
| 263 | return err; | ||
| 264 | |||
| 265 | dice->global_enabled = true; | ||
| 266 | |||
| 267 | return 0; | ||
| 268 | } | ||
| 269 | |||
| 270 | static void dice_enable_clear(struct dice *dice) | ||
| 271 | { | ||
| 272 | __be32 value; | ||
| 273 | |||
| 274 | if (!dice->global_enabled) | ||
| 275 | return; | ||
| 276 | |||
| 277 | value = 0; | ||
| 278 | snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 279 | global_address(dice, GLOBAL_ENABLE), | ||
| 280 | &value, 4, FW_QUIET | | ||
| 281 | FW_FIXED_GENERATION | dice->owner_generation); | ||
| 282 | |||
| 283 | dice->global_enabled = false; | ||
| 284 | } | ||
| 285 | |||
| 286 | static void dice_notification(struct fw_card *card, struct fw_request *request, | ||
| 287 | int tcode, int destination, int source, | ||
| 288 | int generation, unsigned long long offset, | ||
| 289 | void *data, size_t length, void *callback_data) | ||
| 290 | { | ||
| 291 | struct dice *dice = callback_data; | ||
| 292 | u32 bits; | ||
| 293 | unsigned long flags; | ||
| 294 | |||
| 295 | if (tcode != TCODE_WRITE_QUADLET_REQUEST) { | ||
| 296 | fw_send_response(card, request, RCODE_TYPE_ERROR); | ||
| 297 | return; | ||
| 298 | } | ||
| 299 | if ((offset & 3) != 0) { | ||
| 300 | fw_send_response(card, request, RCODE_ADDRESS_ERROR); | ||
| 301 | return; | ||
| 302 | } | ||
| 303 | |||
| 304 | bits = be32_to_cpup(data); | ||
| 305 | |||
| 306 | spin_lock_irqsave(&dice->lock, flags); | ||
| 307 | dice->notification_bits |= bits; | ||
| 308 | spin_unlock_irqrestore(&dice->lock, flags); | ||
| 309 | |||
| 310 | fw_send_response(card, request, RCODE_COMPLETE); | ||
| 311 | |||
| 312 | if (bits & NOTIFY_CLOCK_ACCEPTED) | ||
| 313 | complete(&dice->clock_accepted); | ||
| 314 | wake_up(&dice->hwdep_wait); | ||
| 315 | } | ||
| 316 | |||
| 317 | static int dice_rate_constraint(struct snd_pcm_hw_params *params, | ||
| 318 | struct snd_pcm_hw_rule *rule) | ||
| 319 | { | ||
| 320 | struct dice *dice = rule->private; | ||
| 321 | const struct snd_interval *channels = | ||
| 322 | hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
| 323 | struct snd_interval *rate = | ||
| 324 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | ||
| 325 | struct snd_interval allowed_rates = { | ||
| 326 | .min = UINT_MAX, .max = 0, .integer = 1 | ||
| 327 | }; | ||
| 328 | unsigned int i, mode; | ||
| 329 | |||
| 330 | for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) { | ||
| 331 | mode = rate_index_to_mode(i); | ||
| 332 | if ((dice->clock_caps & (1 << i)) && | ||
| 333 | snd_interval_test(channels, dice->rx_channels[mode])) { | ||
| 334 | allowed_rates.min = min(allowed_rates.min, | ||
| 335 | dice_rates[i]); | ||
| 336 | allowed_rates.max = max(allowed_rates.max, | ||
| 337 | dice_rates[i]); | ||
| 338 | } | ||
| 339 | } | ||
| 340 | |||
| 341 | return snd_interval_refine(rate, &allowed_rates); | ||
| 342 | } | ||
| 343 | |||
| 344 | static int dice_channels_constraint(struct snd_pcm_hw_params *params, | ||
| 345 | struct snd_pcm_hw_rule *rule) | ||
| 346 | { | ||
| 347 | struct dice *dice = rule->private; | ||
| 348 | const struct snd_interval *rate = | ||
| 349 | hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_RATE); | ||
| 350 | struct snd_interval *channels = | ||
| 351 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
| 352 | struct snd_interval allowed_channels = { | ||
| 353 | .min = UINT_MAX, .max = 0, .integer = 1 | ||
| 354 | }; | ||
| 355 | unsigned int i, mode; | ||
| 356 | |||
| 357 | for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) | ||
| 358 | if ((dice->clock_caps & (1 << i)) && | ||
| 359 | snd_interval_test(rate, dice_rates[i])) { | ||
| 360 | mode = rate_index_to_mode(i); | ||
| 361 | allowed_channels.min = min(allowed_channels.min, | ||
| 362 | dice->rx_channels[mode]); | ||
| 363 | allowed_channels.max = max(allowed_channels.max, | ||
| 364 | dice->rx_channels[mode]); | ||
| 365 | } | ||
| 366 | |||
| 367 | return snd_interval_refine(channels, &allowed_channels); | ||
| 368 | } | ||
| 369 | |||
| 370 | static int dice_open(struct snd_pcm_substream *substream) | ||
| 371 | { | ||
| 372 | static const struct snd_pcm_hardware hardware = { | ||
| 373 | .info = SNDRV_PCM_INFO_MMAP | | ||
| 374 | SNDRV_PCM_INFO_MMAP_VALID | | ||
| 375 | SNDRV_PCM_INFO_BATCH | | ||
| 376 | SNDRV_PCM_INFO_INTERLEAVED | | ||
| 377 | SNDRV_PCM_INFO_BLOCK_TRANSFER, | ||
| 378 | .formats = AMDTP_OUT_PCM_FORMAT_BITS, | ||
| 379 | .channels_min = UINT_MAX, | ||
| 380 | .channels_max = 0, | ||
| 381 | .buffer_bytes_max = 16 * 1024 * 1024, | ||
| 382 | .period_bytes_min = 1, | ||
| 383 | .period_bytes_max = UINT_MAX, | ||
| 384 | .periods_min = 1, | ||
| 385 | .periods_max = UINT_MAX, | ||
| 386 | }; | ||
| 387 | struct dice *dice = substream->private_data; | ||
| 388 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 389 | unsigned int i; | ||
| 390 | int err; | ||
| 391 | |||
| 392 | err = dice_try_lock(dice); | ||
| 393 | if (err < 0) | ||
| 394 | goto error; | ||
| 395 | |||
| 396 | runtime->hw = hardware; | ||
| 397 | |||
| 398 | for (i = 0; i < ARRAY_SIZE(dice_rates); ++i) | ||
| 399 | if (dice->clock_caps & (1 << i)) | ||
| 400 | runtime->hw.rates |= | ||
| 401 | snd_pcm_rate_to_rate_bit(dice_rates[i]); | ||
| 402 | snd_pcm_limit_hw_rates(runtime); | ||
| 403 | |||
| 404 | for (i = 0; i < 3; ++i) | ||
| 405 | if (dice->rx_channels[i]) { | ||
| 406 | runtime->hw.channels_min = min(runtime->hw.channels_min, | ||
| 407 | dice->rx_channels[i]); | ||
| 408 | runtime->hw.channels_max = max(runtime->hw.channels_max, | ||
| 409 | dice->rx_channels[i]); | ||
| 410 | } | ||
| 411 | |||
| 412 | err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
| 413 | dice_rate_constraint, dice, | ||
| 414 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); | ||
| 415 | if (err < 0) | ||
| 416 | goto err_lock; | ||
| 417 | err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | ||
| 418 | dice_channels_constraint, dice, | ||
| 419 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
| 420 | if (err < 0) | ||
| 421 | goto err_lock; | ||
| 422 | |||
| 423 | err = snd_pcm_hw_constraint_step(runtime, 0, | ||
| 424 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32); | ||
| 425 | if (err < 0) | ||
| 426 | goto err_lock; | ||
| 427 | err = snd_pcm_hw_constraint_step(runtime, 0, | ||
| 428 | SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32); | ||
| 429 | if (err < 0) | ||
| 430 | goto err_lock; | ||
| 431 | |||
| 432 | err = snd_pcm_hw_constraint_minmax(runtime, | ||
| 433 | SNDRV_PCM_HW_PARAM_PERIOD_TIME, | ||
| 434 | 5000, UINT_MAX); | ||
| 435 | if (err < 0) | ||
| 436 | goto err_lock; | ||
| 437 | |||
| 438 | err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); | ||
| 439 | if (err < 0) | ||
| 440 | goto err_lock; | ||
| 441 | |||
| 442 | return 0; | ||
| 443 | |||
| 444 | err_lock: | ||
| 445 | dice_unlock(dice); | ||
| 446 | error: | ||
| 447 | return err; | ||
| 448 | } | ||
| 449 | |||
| 450 | static int dice_close(struct snd_pcm_substream *substream) | ||
| 451 | { | ||
| 452 | struct dice *dice = substream->private_data; | ||
| 453 | |||
| 454 | dice_unlock(dice); | ||
| 455 | |||
| 456 | return 0; | ||
| 457 | } | ||
| 458 | |||
| 459 | static int dice_stream_start_packets(struct dice *dice) | ||
| 460 | { | ||
| 461 | int err; | ||
| 462 | |||
| 463 | if (amdtp_out_stream_running(&dice->stream)) | ||
| 464 | return 0; | ||
| 465 | |||
| 466 | err = amdtp_out_stream_start(&dice->stream, dice->resources.channel, | ||
| 467 | fw_parent_device(dice->unit)->max_speed); | ||
| 468 | if (err < 0) | ||
| 469 | return err; | ||
| 470 | |||
| 471 | err = dice_enable_set(dice); | ||
| 472 | if (err < 0) { | ||
| 473 | amdtp_out_stream_stop(&dice->stream); | ||
| 474 | return err; | ||
| 475 | } | ||
| 476 | |||
| 477 | return 0; | ||
| 478 | } | ||
| 479 | |||
| 480 | static int dice_stream_start(struct dice *dice) | ||
| 481 | { | ||
| 482 | __be32 channel; | ||
| 483 | int err; | ||
| 484 | |||
| 485 | if (!dice->resources.allocated) { | ||
| 486 | err = fw_iso_resources_allocate(&dice->resources, | ||
| 487 | amdtp_out_stream_get_max_payload(&dice->stream), | ||
| 488 | fw_parent_device(dice->unit)->max_speed); | ||
| 489 | if (err < 0) | ||
| 490 | goto error; | ||
| 491 | |||
| 492 | channel = cpu_to_be32(dice->resources.channel); | ||
| 493 | err = snd_fw_transaction(dice->unit, | ||
| 494 | TCODE_WRITE_QUADLET_REQUEST, | ||
| 495 | rx_address(dice, RX_ISOCHRONOUS), | ||
| 496 | &channel, 4, 0); | ||
| 497 | if (err < 0) | ||
| 498 | goto err_resources; | ||
| 499 | } | ||
| 500 | |||
| 501 | err = dice_stream_start_packets(dice); | ||
| 502 | if (err < 0) | ||
| 503 | goto err_rx_channel; | ||
| 504 | |||
| 505 | return 0; | ||
| 506 | |||
| 507 | err_rx_channel: | ||
| 508 | channel = cpu_to_be32((u32)-1); | ||
| 509 | snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 510 | rx_address(dice, RX_ISOCHRONOUS), &channel, 4, 0); | ||
| 511 | err_resources: | ||
| 512 | fw_iso_resources_free(&dice->resources); | ||
| 513 | error: | ||
| 514 | return err; | ||
| 515 | } | ||
| 516 | |||
| 517 | static void dice_stream_stop_packets(struct dice *dice) | ||
| 518 | { | ||
| 519 | if (amdtp_out_stream_running(&dice->stream)) { | ||
| 520 | dice_enable_clear(dice); | ||
| 521 | amdtp_out_stream_stop(&dice->stream); | ||
| 522 | } | ||
| 523 | } | ||
| 524 | |||
| 525 | static void dice_stream_stop(struct dice *dice) | ||
| 526 | { | ||
| 527 | __be32 channel; | ||
| 528 | |||
| 529 | dice_stream_stop_packets(dice); | ||
| 530 | |||
| 531 | if (!dice->resources.allocated) | ||
| 532 | return; | ||
| 533 | |||
| 534 | channel = cpu_to_be32((u32)-1); | ||
| 535 | snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 536 | rx_address(dice, RX_ISOCHRONOUS), &channel, 4, 0); | ||
| 537 | |||
| 538 | fw_iso_resources_free(&dice->resources); | ||
| 539 | } | ||
| 540 | |||
| 541 | static int dice_change_rate(struct dice *dice, unsigned int clock_rate) | ||
| 542 | { | ||
| 543 | __be32 value; | ||
| 544 | int err; | ||
| 545 | |||
| 546 | INIT_COMPLETION(dice->clock_accepted); | ||
| 547 | |||
| 548 | value = cpu_to_be32(clock_rate | CLOCK_SOURCE_ARX1); | ||
| 549 | err = snd_fw_transaction(dice->unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 550 | global_address(dice, GLOBAL_CLOCK_SELECT), | ||
| 551 | &value, 4, 0); | ||
| 552 | if (err < 0) | ||
| 553 | return err; | ||
| 554 | |||
| 555 | if (!wait_for_completion_timeout(&dice->clock_accepted, | ||
| 556 | msecs_to_jiffies(100))) | ||
| 557 | dev_warn(&dice->unit->device, "clock change timed out\n"); | ||
| 558 | |||
| 559 | return 0; | ||
| 560 | } | ||
| 561 | |||
| 562 | static int dice_hw_params(struct snd_pcm_substream *substream, | ||
| 563 | struct snd_pcm_hw_params *hw_params) | ||
| 564 | { | ||
| 565 | struct dice *dice = substream->private_data; | ||
| 566 | unsigned int rate_index, mode; | ||
| 567 | int err; | ||
| 568 | |||
| 569 | mutex_lock(&dice->mutex); | ||
| 570 | dice_stream_stop(dice); | ||
| 571 | mutex_unlock(&dice->mutex); | ||
| 572 | |||
| 573 | err = snd_pcm_lib_alloc_vmalloc_buffer(substream, | ||
| 574 | params_buffer_bytes(hw_params)); | ||
| 575 | if (err < 0) | ||
| 576 | return err; | ||
| 577 | |||
| 578 | rate_index = rate_to_index(params_rate(hw_params)); | ||
| 579 | err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT); | ||
| 580 | if (err < 0) | ||
| 581 | return err; | ||
| 582 | |||
| 583 | mode = rate_index_to_mode(rate_index); | ||
| 584 | amdtp_out_stream_set_parameters(&dice->stream, | ||
| 585 | params_rate(hw_params), | ||
| 586 | params_channels(hw_params), | ||
| 587 | dice->rx_midi_ports[mode]); | ||
| 588 | amdtp_out_stream_set_pcm_format(&dice->stream, | ||
| 589 | params_format(hw_params)); | ||
| 590 | |||
| 591 | return 0; | ||
| 592 | } | ||
| 593 | |||
| 594 | static int dice_hw_free(struct snd_pcm_substream *substream) | ||
| 595 | { | ||
| 596 | struct dice *dice = substream->private_data; | ||
| 597 | |||
| 598 | mutex_lock(&dice->mutex); | ||
| 599 | dice_stream_stop(dice); | ||
| 600 | mutex_unlock(&dice->mutex); | ||
| 601 | |||
| 602 | return snd_pcm_lib_free_vmalloc_buffer(substream); | ||
| 603 | } | ||
| 604 | |||
| 605 | static int dice_prepare(struct snd_pcm_substream *substream) | ||
| 606 | { | ||
| 607 | struct dice *dice = substream->private_data; | ||
| 608 | int err; | ||
| 609 | |||
| 610 | mutex_lock(&dice->mutex); | ||
| 611 | |||
| 612 | if (amdtp_out_streaming_error(&dice->stream)) | ||
| 613 | dice_stream_stop_packets(dice); | ||
| 614 | |||
| 615 | err = dice_stream_start(dice); | ||
| 616 | if (err < 0) { | ||
| 617 | mutex_unlock(&dice->mutex); | ||
| 618 | return err; | ||
| 619 | } | ||
| 620 | |||
| 621 | mutex_unlock(&dice->mutex); | ||
| 622 | |||
| 623 | amdtp_out_stream_pcm_prepare(&dice->stream); | ||
| 624 | |||
| 625 | return 0; | ||
| 626 | } | ||
| 627 | |||
| 628 | static int dice_trigger(struct snd_pcm_substream *substream, int cmd) | ||
| 629 | { | ||
| 630 | struct dice *dice = substream->private_data; | ||
| 631 | struct snd_pcm_substream *pcm; | ||
| 632 | |||
| 633 | switch (cmd) { | ||
| 634 | case SNDRV_PCM_TRIGGER_START: | ||
| 635 | pcm = substream; | ||
| 636 | break; | ||
| 637 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 638 | pcm = NULL; | ||
| 639 | break; | ||
| 640 | default: | ||
| 641 | return -EINVAL; | ||
| 642 | } | ||
| 643 | amdtp_out_stream_pcm_trigger(&dice->stream, pcm); | ||
| 644 | |||
| 645 | return 0; | ||
| 646 | } | ||
| 647 | |||
| 648 | static snd_pcm_uframes_t dice_pointer(struct snd_pcm_substream *substream) | ||
| 649 | { | ||
| 650 | struct dice *dice = substream->private_data; | ||
| 651 | |||
| 652 | return amdtp_out_stream_pcm_pointer(&dice->stream); | ||
| 653 | } | ||
| 654 | |||
| 655 | static int dice_create_pcm(struct dice *dice) | ||
| 656 | { | ||
| 657 | static struct snd_pcm_ops ops = { | ||
| 658 | .open = dice_open, | ||
| 659 | .close = dice_close, | ||
| 660 | .ioctl = snd_pcm_lib_ioctl, | ||
| 661 | .hw_params = dice_hw_params, | ||
| 662 | .hw_free = dice_hw_free, | ||
| 663 | .prepare = dice_prepare, | ||
| 664 | .trigger = dice_trigger, | ||
| 665 | .pointer = dice_pointer, | ||
| 666 | .page = snd_pcm_lib_get_vmalloc_page, | ||
| 667 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
| 668 | }; | ||
| 669 | struct snd_pcm *pcm; | ||
| 670 | int err; | ||
| 671 | |||
| 672 | err = snd_pcm_new(dice->card, "DICE", 0, 1, 0, &pcm); | ||
| 673 | if (err < 0) | ||
| 674 | return err; | ||
| 675 | pcm->private_data = dice; | ||
| 676 | strcpy(pcm->name, dice->card->shortname); | ||
| 677 | pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->ops = &ops; | ||
| 678 | |||
| 679 | return 0; | ||
| 680 | } | ||
| 681 | |||
| 682 | static long dice_hwdep_read(struct snd_hwdep *hwdep, char __user *buf, | ||
| 683 | long count, loff_t *offset) | ||
| 684 | { | ||
| 685 | struct dice *dice = hwdep->private_data; | ||
| 686 | DEFINE_WAIT(wait); | ||
| 687 | union snd_firewire_event event; | ||
| 688 | |||
| 689 | spin_lock_irq(&dice->lock); | ||
| 690 | |||
| 691 | while (!dice->dev_lock_changed && dice->notification_bits == 0) { | ||
| 692 | prepare_to_wait(&dice->hwdep_wait, &wait, TASK_INTERRUPTIBLE); | ||
| 693 | spin_unlock_irq(&dice->lock); | ||
| 694 | schedule(); | ||
| 695 | finish_wait(&dice->hwdep_wait, &wait); | ||
| 696 | if (signal_pending(current)) | ||
| 697 | return -ERESTARTSYS; | ||
| 698 | spin_lock_irq(&dice->lock); | ||
| 699 | } | ||
| 700 | |||
| 701 | memset(&event, 0, sizeof(event)); | ||
| 702 | if (dice->dev_lock_changed) { | ||
| 703 | event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; | ||
| 704 | event.lock_status.status = dice->dev_lock_count > 0; | ||
| 705 | dice->dev_lock_changed = false; | ||
| 706 | |||
| 707 | count = min(count, (long)sizeof(event.lock_status)); | ||
| 708 | } else { | ||
| 709 | event.dice_notification.type = SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION; | ||
| 710 | event.dice_notification.notification = dice->notification_bits; | ||
| 711 | dice->notification_bits = 0; | ||
| 712 | |||
| 713 | count = min(count, (long)sizeof(event.dice_notification)); | ||
| 714 | } | ||
| 715 | |||
| 716 | spin_unlock_irq(&dice->lock); | ||
| 717 | |||
| 718 | if (copy_to_user(buf, &event, count)) | ||
| 719 | return -EFAULT; | ||
| 720 | |||
| 721 | return count; | ||
| 722 | } | ||
| 723 | |||
| 724 | static unsigned int dice_hwdep_poll(struct snd_hwdep *hwdep, struct file *file, | ||
| 725 | poll_table *wait) | ||
| 726 | { | ||
| 727 | struct dice *dice = hwdep->private_data; | ||
| 728 | unsigned int events; | ||
| 729 | |||
| 730 | poll_wait(file, &dice->hwdep_wait, wait); | ||
| 731 | |||
| 732 | spin_lock_irq(&dice->lock); | ||
| 733 | if (dice->dev_lock_changed || dice->notification_bits != 0) | ||
| 734 | events = POLLIN | POLLRDNORM; | ||
| 735 | else | ||
| 736 | events = 0; | ||
| 737 | spin_unlock_irq(&dice->lock); | ||
| 738 | |||
| 739 | return events; | ||
| 740 | } | ||
| 741 | |||
| 742 | static int dice_hwdep_get_info(struct dice *dice, void __user *arg) | ||
| 743 | { | ||
| 744 | struct fw_device *dev = fw_parent_device(dice->unit); | ||
| 745 | struct snd_firewire_get_info info; | ||
| 746 | |||
| 747 | memset(&info, 0, sizeof(info)); | ||
| 748 | info.type = SNDRV_FIREWIRE_TYPE_DICE; | ||
| 749 | info.card = dev->card->index; | ||
| 750 | *(__be32 *)&info.guid[0] = cpu_to_be32(dev->config_rom[3]); | ||
| 751 | *(__be32 *)&info.guid[4] = cpu_to_be32(dev->config_rom[4]); | ||
| 752 | strlcpy(info.device_name, dev_name(&dev->device), | ||
| 753 | sizeof(info.device_name)); | ||
| 754 | |||
| 755 | if (copy_to_user(arg, &info, sizeof(info))) | ||
| 756 | return -EFAULT; | ||
| 757 | |||
| 758 | return 0; | ||
| 759 | } | ||
| 760 | |||
| 761 | static int dice_hwdep_lock(struct dice *dice) | ||
| 762 | { | ||
| 763 | int err; | ||
| 764 | |||
| 765 | spin_lock_irq(&dice->lock); | ||
| 766 | |||
| 767 | if (dice->dev_lock_count == 0) { | ||
| 768 | dice->dev_lock_count = -1; | ||
| 769 | err = 0; | ||
| 770 | } else { | ||
| 771 | err = -EBUSY; | ||
| 772 | } | ||
| 773 | |||
| 774 | spin_unlock_irq(&dice->lock); | ||
| 775 | |||
| 776 | return err; | ||
| 777 | } | ||
| 778 | |||
| 779 | static int dice_hwdep_unlock(struct dice *dice) | ||
| 780 | { | ||
| 781 | int err; | ||
| 782 | |||
| 783 | spin_lock_irq(&dice->lock); | ||
| 784 | |||
| 785 | if (dice->dev_lock_count == -1) { | ||
| 786 | dice->dev_lock_count = 0; | ||
| 787 | err = 0; | ||
| 788 | } else { | ||
| 789 | err = -EBADFD; | ||
| 790 | } | ||
| 791 | |||
| 792 | spin_unlock_irq(&dice->lock); | ||
| 793 | |||
| 794 | return err; | ||
| 795 | } | ||
| 796 | |||
| 797 | static int dice_hwdep_release(struct snd_hwdep *hwdep, struct file *file) | ||
| 798 | { | ||
| 799 | struct dice *dice = hwdep->private_data; | ||
| 800 | |||
| 801 | spin_lock_irq(&dice->lock); | ||
| 802 | if (dice->dev_lock_count == -1) | ||
| 803 | dice->dev_lock_count = 0; | ||
| 804 | spin_unlock_irq(&dice->lock); | ||
| 805 | |||
| 806 | return 0; | ||
| 807 | } | ||
| 808 | |||
| 809 | static int dice_hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file, | ||
| 810 | unsigned int cmd, unsigned long arg) | ||
| 811 | { | ||
| 812 | struct dice *dice = hwdep->private_data; | ||
| 813 | |||
| 814 | switch (cmd) { | ||
| 815 | case SNDRV_FIREWIRE_IOCTL_GET_INFO: | ||
| 816 | return dice_hwdep_get_info(dice, (void __user *)arg); | ||
| 817 | case SNDRV_FIREWIRE_IOCTL_LOCK: | ||
| 818 | return dice_hwdep_lock(dice); | ||
| 819 | case SNDRV_FIREWIRE_IOCTL_UNLOCK: | ||
| 820 | return dice_hwdep_unlock(dice); | ||
| 821 | default: | ||
| 822 | return -ENOIOCTLCMD; | ||
| 823 | } | ||
| 824 | } | ||
| 825 | |||
| 826 | #ifdef CONFIG_COMPAT | ||
| 827 | static int dice_hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file, | ||
| 828 | unsigned int cmd, unsigned long arg) | ||
| 829 | { | ||
| 830 | return dice_hwdep_ioctl(hwdep, file, cmd, | ||
| 831 | (unsigned long)compat_ptr(arg)); | ||
| 832 | } | ||
| 833 | #else | ||
| 834 | #define dice_hwdep_compat_ioctl NULL | ||
| 835 | #endif | ||
| 836 | |||
| 837 | static int dice_create_hwdep(struct dice *dice) | ||
| 838 | { | ||
| 839 | static const struct snd_hwdep_ops ops = { | ||
| 840 | .read = dice_hwdep_read, | ||
| 841 | .release = dice_hwdep_release, | ||
| 842 | .poll = dice_hwdep_poll, | ||
| 843 | .ioctl = dice_hwdep_ioctl, | ||
| 844 | .ioctl_compat = dice_hwdep_compat_ioctl, | ||
| 845 | }; | ||
| 846 | struct snd_hwdep *hwdep; | ||
| 847 | int err; | ||
| 848 | |||
| 849 | err = snd_hwdep_new(dice->card, "DICE", 0, &hwdep); | ||
| 850 | if (err < 0) | ||
| 851 | return err; | ||
| 852 | strcpy(hwdep->name, "DICE"); | ||
| 853 | hwdep->iface = SNDRV_HWDEP_IFACE_FW_DICE; | ||
| 854 | hwdep->ops = ops; | ||
| 855 | hwdep->private_data = dice; | ||
| 856 | hwdep->exclusive = true; | ||
| 857 | |||
| 858 | return 0; | ||
| 859 | } | ||
| 860 | |||
| 861 | static int dice_proc_read_mem(struct dice *dice, void *buffer, | ||
| 862 | unsigned int offset_q, unsigned int quadlets) | ||
| 863 | { | ||
| 864 | unsigned int i; | ||
| 865 | int err; | ||
| 866 | |||
| 867 | err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, | ||
| 868 | DICE_PRIVATE_SPACE + 4 * offset_q, | ||
| 869 | buffer, 4 * quadlets, 0); | ||
| 870 | if (err < 0) | ||
| 871 | return err; | ||
| 872 | |||
| 873 | for (i = 0; i < quadlets; ++i) | ||
| 874 | be32_to_cpus(&((u32 *)buffer)[i]); | ||
| 875 | |||
| 876 | return 0; | ||
| 877 | } | ||
| 878 | |||
| 879 | static const char *str_from_array(const char *const strs[], unsigned int count, | ||
| 880 | unsigned int i) | ||
| 881 | { | ||
| 882 | if (i < count) | ||
| 883 | return strs[i]; | ||
| 884 | else | ||
| 885 | return "(unknown)"; | ||
| 886 | } | ||
| 887 | |||
| 888 | static void dice_proc_fixup_string(char *s, unsigned int size) | ||
| 889 | { | ||
| 890 | unsigned int i; | ||
| 891 | |||
| 892 | for (i = 0; i < size; i += 4) | ||
| 893 | cpu_to_le32s((u32 *)(s + i)); | ||
| 894 | |||
| 895 | for (i = 0; i < size - 2; ++i) { | ||
| 896 | if (s[i] == '\0') | ||
| 897 | return; | ||
| 898 | if (s[i] == '\\' && s[i + 1] == '\\') { | ||
| 899 | s[i + 2] = '\0'; | ||
| 900 | return; | ||
| 901 | } | ||
| 902 | } | ||
| 903 | s[size - 1] = '\0'; | ||
| 904 | } | ||
| 905 | |||
| 906 | static void dice_proc_read(struct snd_info_entry *entry, | ||
| 907 | struct snd_info_buffer *buffer) | ||
| 908 | { | ||
| 909 | static const char *const section_names[5] = { | ||
| 910 | "global", "tx", "rx", "ext_sync", "unused2" | ||
| 911 | }; | ||
| 912 | static const char *const clock_sources[] = { | ||
| 913 | "aes1", "aes2", "aes3", "aes4", "aes", "adat", "tdif", | ||
| 914 | "wc", "arx1", "arx2", "arx3", "arx4", "internal" | ||
| 915 | }; | ||
| 916 | static const char *const rates[] = { | ||
| 917 | "32000", "44100", "48000", "88200", "96000", "176400", "192000", | ||
| 918 | "any low", "any mid", "any high", "none" | ||
| 919 | }; | ||
| 920 | struct dice *dice = entry->private_data; | ||
| 921 | u32 sections[ARRAY_SIZE(section_names) * 2]; | ||
| 922 | struct { | ||
| 923 | u32 number; | ||
| 924 | u32 size; | ||
| 925 | } tx_rx_header; | ||
| 926 | union { | ||
| 927 | struct { | ||
| 928 | u32 owner_hi, owner_lo; | ||
| 929 | u32 notification; | ||
| 930 | char nick_name[NICK_NAME_SIZE]; | ||
| 931 | u32 clock_select; | ||
| 932 | u32 enable; | ||
| 933 | u32 status; | ||
| 934 | u32 extended_status; | ||
| 935 | u32 sample_rate; | ||
| 936 | u32 version; | ||
| 937 | u32 clock_caps; | ||
| 938 | char clock_source_names[CLOCK_SOURCE_NAMES_SIZE]; | ||
| 939 | } global; | ||
| 940 | struct { | ||
| 941 | u32 iso; | ||
| 942 | u32 number_audio; | ||
| 943 | u32 number_midi; | ||
| 944 | u32 speed; | ||
| 945 | char names[TX_NAMES_SIZE]; | ||
| 946 | u32 ac3_caps; | ||
| 947 | u32 ac3_enable; | ||
| 948 | } tx; | ||
| 949 | struct { | ||
| 950 | u32 iso; | ||
| 951 | u32 seq_start; | ||
| 952 | u32 number_audio; | ||
| 953 | u32 number_midi; | ||
| 954 | char names[RX_NAMES_SIZE]; | ||
| 955 | u32 ac3_caps; | ||
| 956 | u32 ac3_enable; | ||
| 957 | } rx; | ||
| 958 | struct { | ||
| 959 | u32 clock_source; | ||
| 960 | u32 locked; | ||
| 961 | u32 rate; | ||
| 962 | u32 adat_user_data; | ||
| 963 | } ext_sync; | ||
| 964 | } buf; | ||
| 965 | unsigned int quadlets, stream, i; | ||
| 966 | |||
| 967 | if (dice_proc_read_mem(dice, sections, 0, ARRAY_SIZE(sections)) < 0) | ||
| 968 | return; | ||
| 969 | snd_iprintf(buffer, "sections:\n"); | ||
| 970 | for (i = 0; i < ARRAY_SIZE(section_names); ++i) | ||
| 971 | snd_iprintf(buffer, " %s: offset %u, size %u\n", | ||
| 972 | section_names[i], | ||
| 973 | sections[i * 2], sections[i * 2 + 1]); | ||
| 974 | |||
| 975 | quadlets = min_t(u32, sections[1], sizeof(buf.global) / 4); | ||
| 976 | if (dice_proc_read_mem(dice, &buf.global, sections[0], quadlets) < 0) | ||
| 977 | return; | ||
| 978 | snd_iprintf(buffer, "global:\n"); | ||
| 979 | snd_iprintf(buffer, " owner: %04x:%04x%08x\n", | ||
| 980 | buf.global.owner_hi >> 16, | ||
| 981 | buf.global.owner_hi & 0xffff, buf.global.owner_lo); | ||
| 982 | snd_iprintf(buffer, " notification: %08x\n", buf.global.notification); | ||
| 983 | dice_proc_fixup_string(buf.global.nick_name, NICK_NAME_SIZE); | ||
| 984 | snd_iprintf(buffer, " nick name: %s\n", buf.global.nick_name); | ||
| 985 | snd_iprintf(buffer, " clock select: %s %s\n", | ||
| 986 | str_from_array(clock_sources, ARRAY_SIZE(clock_sources), | ||
| 987 | buf.global.clock_select & CLOCK_SOURCE_MASK), | ||
| 988 | str_from_array(rates, ARRAY_SIZE(rates), | ||
| 989 | (buf.global.clock_select & CLOCK_RATE_MASK) | ||
| 990 | >> CLOCK_RATE_SHIFT)); | ||
| 991 | snd_iprintf(buffer, " enable: %u\n", buf.global.enable); | ||
| 992 | snd_iprintf(buffer, " status: %slocked %s\n", | ||
| 993 | buf.global.status & STATUS_SOURCE_LOCKED ? "" : "un", | ||
| 994 | str_from_array(rates, ARRAY_SIZE(rates), | ||
| 995 | (buf.global.status & | ||
| 996 | STATUS_NOMINAL_RATE_MASK) | ||
| 997 | >> CLOCK_RATE_SHIFT)); | ||
| 998 | snd_iprintf(buffer, " ext status: %08x\n", buf.global.extended_status); | ||
| 999 | snd_iprintf(buffer, " sample rate: %u\n", buf.global.sample_rate); | ||
| 1000 | snd_iprintf(buffer, " version: %u.%u.%u.%u\n", | ||
| 1001 | (buf.global.version >> 24) & 0xff, | ||
| 1002 | (buf.global.version >> 16) & 0xff, | ||
| 1003 | (buf.global.version >> 8) & 0xff, | ||
| 1004 | (buf.global.version >> 0) & 0xff); | ||
| 1005 | if (quadlets >= 90) { | ||
| 1006 | snd_iprintf(buffer, " clock caps:"); | ||
| 1007 | for (i = 0; i <= 6; ++i) | ||
| 1008 | if (buf.global.clock_caps & (1 << i)) | ||
| 1009 | snd_iprintf(buffer, " %s", rates[i]); | ||
| 1010 | for (i = 0; i <= 12; ++i) | ||
| 1011 | if (buf.global.clock_caps & (1 << (16 + i))) | ||
| 1012 | snd_iprintf(buffer, " %s", clock_sources[i]); | ||
| 1013 | snd_iprintf(buffer, "\n"); | ||
| 1014 | dice_proc_fixup_string(buf.global.clock_source_names, | ||
| 1015 | CLOCK_SOURCE_NAMES_SIZE); | ||
| 1016 | snd_iprintf(buffer, " clock source names: %s\n", | ||
| 1017 | buf.global.clock_source_names); | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | if (dice_proc_read_mem(dice, &tx_rx_header, sections[2], 2) < 0) | ||
| 1021 | return; | ||
| 1022 | quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.tx)); | ||
| 1023 | for (stream = 0; stream < tx_rx_header.number; ++stream) { | ||
| 1024 | if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 + | ||
| 1025 | stream * tx_rx_header.size, | ||
| 1026 | quadlets) < 0) | ||
| 1027 | break; | ||
| 1028 | snd_iprintf(buffer, "tx %u:\n", stream); | ||
| 1029 | snd_iprintf(buffer, " iso channel: %d\n", (int)buf.tx.iso); | ||
| 1030 | snd_iprintf(buffer, " audio channels: %u\n", | ||
| 1031 | buf.tx.number_audio); | ||
| 1032 | snd_iprintf(buffer, " midi ports: %u\n", buf.tx.number_midi); | ||
| 1033 | snd_iprintf(buffer, " speed: S%u\n", 100u << buf.tx.speed); | ||
| 1034 | if (quadlets >= 68) { | ||
| 1035 | dice_proc_fixup_string(buf.tx.names, TX_NAMES_SIZE); | ||
| 1036 | snd_iprintf(buffer, " names: %s\n", buf.tx.names); | ||
| 1037 | } | ||
| 1038 | if (quadlets >= 70) { | ||
| 1039 | snd_iprintf(buffer, " ac3 caps: %08x\n", | ||
| 1040 | buf.tx.ac3_caps); | ||
| 1041 | snd_iprintf(buffer, " ac3 enable: %08x\n", | ||
| 1042 | buf.tx.ac3_enable); | ||
| 1043 | } | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | if (dice_proc_read_mem(dice, &tx_rx_header, sections[4], 2) < 0) | ||
| 1047 | return; | ||
| 1048 | quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.rx)); | ||
| 1049 | for (stream = 0; stream < tx_rx_header.number; ++stream) { | ||
| 1050 | if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 + | ||
| 1051 | stream * tx_rx_header.size, | ||
| 1052 | quadlets) < 0) | ||
| 1053 | break; | ||
| 1054 | snd_iprintf(buffer, "rx %u:\n", stream); | ||
| 1055 | snd_iprintf(buffer, " iso channel: %d\n", (int)buf.rx.iso); | ||
| 1056 | snd_iprintf(buffer, " sequence start: %u\n", buf.rx.seq_start); | ||
| 1057 | snd_iprintf(buffer, " audio channels: %u\n", | ||
| 1058 | buf.rx.number_audio); | ||
| 1059 | snd_iprintf(buffer, " midi ports: %u\n", buf.rx.number_midi); | ||
| 1060 | if (quadlets >= 68) { | ||
| 1061 | dice_proc_fixup_string(buf.rx.names, RX_NAMES_SIZE); | ||
| 1062 | snd_iprintf(buffer, " names: %s\n", buf.rx.names); | ||
| 1063 | } | ||
| 1064 | if (quadlets >= 70) { | ||
| 1065 | snd_iprintf(buffer, " ac3 caps: %08x\n", | ||
| 1066 | buf.rx.ac3_caps); | ||
| 1067 | snd_iprintf(buffer, " ac3 enable: %08x\n", | ||
| 1068 | buf.rx.ac3_enable); | ||
| 1069 | } | ||
| 1070 | } | ||
| 1071 | |||
| 1072 | quadlets = min_t(u32, sections[7], sizeof(buf.ext_sync) / 4); | ||
| 1073 | if (quadlets >= 4) { | ||
| 1074 | if (dice_proc_read_mem(dice, &buf.ext_sync, | ||
| 1075 | sections[6], 4) < 0) | ||
| 1076 | return; | ||
| 1077 | snd_iprintf(buffer, "ext status:\n"); | ||
| 1078 | snd_iprintf(buffer, " clock source: %s\n", | ||
| 1079 | str_from_array(clock_sources, | ||
| 1080 | ARRAY_SIZE(clock_sources), | ||
| 1081 | buf.ext_sync.clock_source)); | ||
| 1082 | snd_iprintf(buffer, " locked: %u\n", buf.ext_sync.locked); | ||
| 1083 | snd_iprintf(buffer, " rate: %s\n", | ||
| 1084 | str_from_array(rates, ARRAY_SIZE(rates), | ||
| 1085 | buf.ext_sync.rate)); | ||
| 1086 | snd_iprintf(buffer, " adat user data: "); | ||
| 1087 | if (buf.ext_sync.adat_user_data & ADAT_USER_DATA_NO_DATA) | ||
| 1088 | snd_iprintf(buffer, "-\n"); | ||
| 1089 | else | ||
| 1090 | snd_iprintf(buffer, "%x\n", | ||
| 1091 | buf.ext_sync.adat_user_data); | ||
| 1092 | } | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | static void dice_create_proc(struct dice *dice) | ||
| 1096 | { | ||
| 1097 | struct snd_info_entry *entry; | ||
| 1098 | |||
| 1099 | if (!snd_card_proc_new(dice->card, "dice", &entry)) | ||
| 1100 | snd_info_set_text_ops(entry, dice, dice_proc_read); | ||
| 1101 | } | ||
| 1102 | |||
| 1103 | static void dice_card_free(struct snd_card *card) | ||
| 1104 | { | ||
| 1105 | struct dice *dice = card->private_data; | ||
| 1106 | |||
| 1107 | amdtp_out_stream_destroy(&dice->stream); | ||
| 1108 | fw_core_remove_address_handler(&dice->notification_handler); | ||
| 1109 | mutex_destroy(&dice->mutex); | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | #define OUI_WEISS 0x001c6a | ||
| 1113 | |||
| 1114 | #define DICE_CATEGORY_ID 0x04 | ||
| 1115 | #define WEISS_CATEGORY_ID 0x00 | ||
| 1116 | |||
| 1117 | static int dice_interface_check(struct fw_unit *unit) | ||
| 1118 | { | ||
| 1119 | static const int min_values[10] = { | ||
| 1120 | 10, 0x64 / 4, | ||
| 1121 | 10, 0x18 / 4, | ||
| 1122 | 10, 0x18 / 4, | ||
| 1123 | 0, 0, | ||
| 1124 | 0, 0, | ||
| 1125 | }; | ||
| 1126 | struct fw_device *device = fw_parent_device(unit); | ||
| 1127 | struct fw_csr_iterator it; | ||
| 1128 | int key, value, vendor = -1, model = -1, err; | ||
| 1129 | unsigned int category, i; | ||
| 1130 | __be32 pointers[ARRAY_SIZE(min_values)]; | ||
| 1131 | __be32 tx_data[4]; | ||
| 1132 | __be32 version; | ||
| 1133 | |||
| 1134 | /* | ||
| 1135 | * Check that GUID and unit directory are constructed according to DICE | ||
| 1136 | * rules, i.e., that the specifier ID is the GUID's OUI, and that the | ||
| 1137 | * GUID chip ID consists of the 8-bit category ID, the 10-bit product | ||
| 1138 | * ID, and a 22-bit serial number. | ||
| 1139 | */ | ||
| 1140 | fw_csr_iterator_init(&it, unit->directory); | ||
| 1141 | while (fw_csr_iterator_next(&it, &key, &value)) { | ||
| 1142 | switch (key) { | ||
| 1143 | case CSR_SPECIFIER_ID: | ||
| 1144 | vendor = value; | ||
| 1145 | break; | ||
| 1146 | case CSR_MODEL: | ||
| 1147 | model = value; | ||
| 1148 | break; | ||
| 1149 | } | ||
| 1150 | } | ||
| 1151 | if (vendor == OUI_WEISS) | ||
| 1152 | category = WEISS_CATEGORY_ID; | ||
| 1153 | else | ||
| 1154 | category = DICE_CATEGORY_ID; | ||
| 1155 | if (device->config_rom[3] != ((vendor << 8) | category) || | ||
| 1156 | device->config_rom[4] >> 22 != model) | ||
| 1157 | return -ENODEV; | ||
| 1158 | |||
| 1159 | /* | ||
| 1160 | * Check that the sub address spaces exist and are located inside the | ||
| 1161 | * private address space. The minimum values are chosen so that all | ||
| 1162 | * minimally required registers are included. | ||
| 1163 | */ | ||
| 1164 | err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST, | ||
| 1165 | DICE_PRIVATE_SPACE, | ||
| 1166 | pointers, sizeof(pointers), 0); | ||
| 1167 | if (err < 0) | ||
| 1168 | return -ENODEV; | ||
| 1169 | for (i = 0; i < ARRAY_SIZE(pointers); ++i) { | ||
| 1170 | value = be32_to_cpu(pointers[i]); | ||
| 1171 | if (value < min_values[i] || value >= 0x40000) | ||
| 1172 | return -ENODEV; | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | /* We support playback only. Let capture devices be handled by FFADO. */ | ||
| 1176 | err = snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST, | ||
| 1177 | DICE_PRIVATE_SPACE + | ||
| 1178 | be32_to_cpu(pointers[2]) * 4, | ||
| 1179 | tx_data, sizeof(tx_data), 0); | ||
| 1180 | if (err < 0 || (tx_data[0] && tx_data[3])) | ||
| 1181 | return -ENODEV; | ||
| 1182 | |||
| 1183 | /* | ||
| 1184 | * Check that the implemented DICE driver specification major version | ||
| 1185 | * number matches. | ||
| 1186 | */ | ||
| 1187 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, | ||
| 1188 | DICE_PRIVATE_SPACE + | ||
| 1189 | be32_to_cpu(pointers[0]) * 4 + GLOBAL_VERSION, | ||
| 1190 | &version, 4, 0); | ||
| 1191 | if (err < 0) | ||
| 1192 | return -ENODEV; | ||
| 1193 | if ((version & cpu_to_be32(0xff000000)) != cpu_to_be32(0x01000000)) { | ||
| 1194 | dev_err(&unit->device, | ||
| 1195 | "unknown DICE version: 0x%08x\n", be32_to_cpu(version)); | ||
| 1196 | return -ENODEV; | ||
| 1197 | } | ||
| 1198 | |||
| 1199 | return 0; | ||
| 1200 | } | ||
| 1201 | |||
| 1202 | static int highest_supported_mode_rate(struct dice *dice, unsigned int mode) | ||
| 1203 | { | ||
| 1204 | int i; | ||
| 1205 | |||
| 1206 | for (i = ARRAY_SIZE(dice_rates) - 1; i >= 0; --i) | ||
| 1207 | if ((dice->clock_caps & (1 << i)) && | ||
| 1208 | rate_index_to_mode(i) == mode) | ||
| 1209 | return i; | ||
| 1210 | |||
| 1211 | return -1; | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | static int dice_read_mode_params(struct dice *dice, unsigned int mode) | ||
| 1215 | { | ||
| 1216 | __be32 values[2]; | ||
| 1217 | int rate_index, err; | ||
| 1218 | |||
| 1219 | rate_index = highest_supported_mode_rate(dice, mode); | ||
| 1220 | if (rate_index < 0) { | ||
| 1221 | dice->rx_channels[mode] = 0; | ||
| 1222 | dice->rx_midi_ports[mode] = 0; | ||
| 1223 | return 0; | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | err = dice_change_rate(dice, rate_index << CLOCK_RATE_SHIFT); | ||
| 1227 | if (err < 0) | ||
| 1228 | return err; | ||
| 1229 | |||
| 1230 | err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, | ||
| 1231 | rx_address(dice, RX_NUMBER_AUDIO), | ||
| 1232 | values, 2 * 4, 0); | ||
| 1233 | if (err < 0) | ||
| 1234 | return err; | ||
| 1235 | |||
| 1236 | dice->rx_channels[mode] = be32_to_cpu(values[0]); | ||
| 1237 | dice->rx_midi_ports[mode] = be32_to_cpu(values[1]); | ||
| 1238 | |||
| 1239 | return 0; | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | static int dice_read_params(struct dice *dice) | ||
| 1243 | { | ||
| 1244 | __be32 pointers[6]; | ||
| 1245 | __be32 value; | ||
| 1246 | int mode, err; | ||
| 1247 | |||
| 1248 | err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, | ||
| 1249 | DICE_PRIVATE_SPACE, | ||
| 1250 | pointers, sizeof(pointers), 0); | ||
| 1251 | if (err < 0) | ||
| 1252 | return err; | ||
| 1253 | |||
| 1254 | dice->global_offset = be32_to_cpu(pointers[0]) * 4; | ||
| 1255 | dice->rx_offset = be32_to_cpu(pointers[4]) * 4; | ||
| 1256 | |||
| 1257 | /* some very old firmwares don't tell about their clock support */ | ||
| 1258 | if (be32_to_cpu(pointers[1]) * 4 >= GLOBAL_CLOCK_CAPABILITIES + 4) { | ||
| 1259 | err = snd_fw_transaction( | ||
| 1260 | dice->unit, TCODE_READ_QUADLET_REQUEST, | ||
| 1261 | global_address(dice, GLOBAL_CLOCK_CAPABILITIES), | ||
| 1262 | &value, 4, 0); | ||
| 1263 | if (err < 0) | ||
| 1264 | return err; | ||
| 1265 | dice->clock_caps = be32_to_cpu(value); | ||
| 1266 | } else { | ||
| 1267 | /* this should be supported by any device */ | ||
| 1268 | dice->clock_caps = CLOCK_CAP_RATE_44100 | | ||
| 1269 | CLOCK_CAP_RATE_48000 | | ||
| 1270 | CLOCK_CAP_SOURCE_ARX1 | | ||
| 1271 | CLOCK_CAP_SOURCE_INTERNAL; | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | for (mode = 2; mode >= 0; --mode) { | ||
| 1275 | err = dice_read_mode_params(dice, mode); | ||
| 1276 | if (err < 0) | ||
| 1277 | return err; | ||
| 1278 | } | ||
| 1279 | |||
| 1280 | return 0; | ||
| 1281 | } | ||
| 1282 | |||
| 1283 | static void dice_card_strings(struct dice *dice) | ||
| 1284 | { | ||
| 1285 | struct snd_card *card = dice->card; | ||
| 1286 | struct fw_device *dev = fw_parent_device(dice->unit); | ||
| 1287 | char vendor[32], model[32]; | ||
| 1288 | unsigned int i; | ||
| 1289 | int err; | ||
| 1290 | |||
| 1291 | strcpy(card->driver, "DICE"); | ||
| 1292 | |||
| 1293 | strcpy(card->shortname, "DICE"); | ||
| 1294 | BUILD_BUG_ON(NICK_NAME_SIZE < sizeof(card->shortname)); | ||
| 1295 | err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST, | ||
| 1296 | global_address(dice, GLOBAL_NICK_NAME), | ||
| 1297 | card->shortname, sizeof(card->shortname), 0); | ||
| 1298 | if (err >= 0) { | ||
| 1299 | /* DICE strings are returned in "always-wrong" endianness */ | ||
| 1300 | BUILD_BUG_ON(sizeof(card->shortname) % 4 != 0); | ||
| 1301 | for (i = 0; i < sizeof(card->shortname); i += 4) | ||
| 1302 | swab32s((u32 *)&card->shortname[i]); | ||
| 1303 | card->shortname[sizeof(card->shortname) - 1] = '\0'; | ||
| 1304 | } | ||
| 1305 | |||
| 1306 | strcpy(vendor, "?"); | ||
| 1307 | fw_csr_string(dev->config_rom + 5, CSR_VENDOR, vendor, sizeof(vendor)); | ||
| 1308 | strcpy(model, "?"); | ||
| 1309 | fw_csr_string(dice->unit->directory, CSR_MODEL, model, sizeof(model)); | ||
| 1310 | snprintf(card->longname, sizeof(card->longname), | ||
| 1311 | "%s %s (serial %u) at %s, S%d", | ||
| 1312 | vendor, model, dev->config_rom[4] & 0x3fffff, | ||
| 1313 | dev_name(&dice->unit->device), 100 << dev->max_speed); | ||
| 1314 | |||
| 1315 | strcpy(card->mixername, "DICE"); | ||
| 1316 | } | ||
| 1317 | |||
| 1318 | static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) | ||
| 1319 | { | ||
| 1320 | struct snd_card *card; | ||
| 1321 | struct dice *dice; | ||
| 1322 | __be32 clock_sel; | ||
| 1323 | int err; | ||
| 1324 | |||
| 1325 | err = dice_interface_check(unit); | ||
| 1326 | if (err < 0) | ||
| 1327 | return err; | ||
| 1328 | |||
| 1329 | err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*dice), &card); | ||
| 1330 | if (err < 0) | ||
| 1331 | return err; | ||
| 1332 | snd_card_set_dev(card, &unit->device); | ||
| 1333 | |||
| 1334 | dice = card->private_data; | ||
| 1335 | dice->card = card; | ||
| 1336 | spin_lock_init(&dice->lock); | ||
| 1337 | mutex_init(&dice->mutex); | ||
| 1338 | dice->unit = unit; | ||
| 1339 | init_completion(&dice->clock_accepted); | ||
| 1340 | init_waitqueue_head(&dice->hwdep_wait); | ||
| 1341 | |||
| 1342 | dice->notification_handler.length = 4; | ||
| 1343 | dice->notification_handler.address_callback = dice_notification; | ||
| 1344 | dice->notification_handler.callback_data = dice; | ||
| 1345 | err = fw_core_add_address_handler(&dice->notification_handler, | ||
| 1346 | &fw_high_memory_region); | ||
| 1347 | if (err < 0) | ||
| 1348 | goto err_mutex; | ||
| 1349 | |||
| 1350 | err = dice_owner_set(dice); | ||
| 1351 | if (err < 0) | ||
| 1352 | goto err_notification_handler; | ||
| 1353 | |||
| 1354 | err = dice_read_params(dice); | ||
| 1355 | if (err < 0) | ||
| 1356 | goto err_owner; | ||
| 1357 | |||
| 1358 | err = fw_iso_resources_init(&dice->resources, unit); | ||
| 1359 | if (err < 0) | ||
| 1360 | goto err_owner; | ||
| 1361 | dice->resources.channels_mask = 0x00000000ffffffffuLL; | ||
| 1362 | |||
| 1363 | err = amdtp_out_stream_init(&dice->stream, unit, | ||
| 1364 | CIP_BLOCKING | CIP_HI_DUALWIRE); | ||
| 1365 | if (err < 0) | ||
| 1366 | goto err_resources; | ||
| 1367 | |||
| 1368 | card->private_free = dice_card_free; | ||
| 1369 | |||
| 1370 | dice_card_strings(dice); | ||
| 1371 | |||
| 1372 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, | ||
| 1373 | global_address(dice, GLOBAL_CLOCK_SELECT), | ||
| 1374 | &clock_sel, 4, 0); | ||
| 1375 | if (err < 0) | ||
| 1376 | goto error; | ||
| 1377 | clock_sel &= cpu_to_be32(~CLOCK_SOURCE_MASK); | ||
| 1378 | clock_sel |= cpu_to_be32(CLOCK_SOURCE_ARX1); | ||
| 1379 | err = snd_fw_transaction(unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 1380 | global_address(dice, GLOBAL_CLOCK_SELECT), | ||
| 1381 | &clock_sel, 4, 0); | ||
| 1382 | if (err < 0) | ||
| 1383 | goto error; | ||
| 1384 | |||
| 1385 | err = dice_create_pcm(dice); | ||
| 1386 | if (err < 0) | ||
| 1387 | goto error; | ||
| 1388 | |||
| 1389 | err = dice_create_hwdep(dice); | ||
| 1390 | if (err < 0) | ||
| 1391 | goto error; | ||
| 1392 | |||
| 1393 | dice_create_proc(dice); | ||
| 1394 | |||
| 1395 | err = snd_card_register(card); | ||
| 1396 | if (err < 0) | ||
| 1397 | goto error; | ||
| 1398 | |||
| 1399 | dev_set_drvdata(&unit->device, dice); | ||
| 1400 | |||
| 1401 | return 0; | ||
| 1402 | |||
| 1403 | err_resources: | ||
| 1404 | fw_iso_resources_destroy(&dice->resources); | ||
| 1405 | err_owner: | ||
| 1406 | dice_owner_clear(dice); | ||
| 1407 | err_notification_handler: | ||
| 1408 | fw_core_remove_address_handler(&dice->notification_handler); | ||
| 1409 | err_mutex: | ||
| 1410 | mutex_destroy(&dice->mutex); | ||
| 1411 | error: | ||
| 1412 | snd_card_free(card); | ||
| 1413 | return err; | ||
| 1414 | } | ||
| 1415 | |||
| 1416 | static void dice_remove(struct fw_unit *unit) | ||
| 1417 | { | ||
| 1418 | struct dice *dice = dev_get_drvdata(&unit->device); | ||
| 1419 | |||
| 1420 | amdtp_out_stream_pcm_abort(&dice->stream); | ||
| 1421 | |||
| 1422 | snd_card_disconnect(dice->card); | ||
| 1423 | |||
| 1424 | mutex_lock(&dice->mutex); | ||
| 1425 | |||
| 1426 | dice_stream_stop(dice); | ||
| 1427 | dice_owner_clear(dice); | ||
| 1428 | |||
| 1429 | mutex_unlock(&dice->mutex); | ||
| 1430 | |||
| 1431 | snd_card_free_when_closed(dice->card); | ||
| 1432 | } | ||
| 1433 | |||
| 1434 | static void dice_bus_reset(struct fw_unit *unit) | ||
| 1435 | { | ||
| 1436 | struct dice *dice = dev_get_drvdata(&unit->device); | ||
| 1437 | |||
| 1438 | /* | ||
| 1439 | * On a bus reset, the DICE firmware disables streaming and then goes | ||
| 1440 | * off contemplating its own navel for hundreds of milliseconds before | ||
| 1441 | * it can react to any of our attempts to reenable streaming. This | ||
| 1442 | * means that we lose synchronization anyway, so we force our streams | ||
| 1443 | * to stop so that the application can restart them in an orderly | ||
| 1444 | * manner. | ||
| 1445 | */ | ||
| 1446 | amdtp_out_stream_pcm_abort(&dice->stream); | ||
| 1447 | |||
| 1448 | mutex_lock(&dice->mutex); | ||
| 1449 | |||
| 1450 | dice->global_enabled = false; | ||
| 1451 | dice_stream_stop_packets(dice); | ||
| 1452 | |||
| 1453 | dice_owner_update(dice); | ||
| 1454 | |||
| 1455 | fw_iso_resources_update(&dice->resources); | ||
| 1456 | |||
| 1457 | mutex_unlock(&dice->mutex); | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | #define DICE_INTERFACE 0x000001 | ||
| 1461 | |||
| 1462 | static const struct ieee1394_device_id dice_id_table[] = { | ||
| 1463 | { | ||
| 1464 | .match_flags = IEEE1394_MATCH_VERSION, | ||
| 1465 | .version = DICE_INTERFACE, | ||
| 1466 | }, | ||
| 1467 | { } | ||
| 1468 | }; | ||
| 1469 | MODULE_DEVICE_TABLE(ieee1394, dice_id_table); | ||
| 1470 | |||
| 1471 | static struct fw_driver dice_driver = { | ||
| 1472 | .driver = { | ||
| 1473 | .owner = THIS_MODULE, | ||
| 1474 | .name = KBUILD_MODNAME, | ||
| 1475 | .bus = &fw_bus_type, | ||
| 1476 | }, | ||
| 1477 | .probe = dice_probe, | ||
| 1478 | .update = dice_bus_reset, | ||
| 1479 | .remove = dice_remove, | ||
| 1480 | .id_table = dice_id_table, | ||
| 1481 | }; | ||
| 1482 | |||
| 1483 | static int __init alsa_dice_init(void) | ||
| 1484 | { | ||
| 1485 | return driver_register(&dice_driver.driver); | ||
| 1486 | } | ||
| 1487 | |||
| 1488 | static void __exit alsa_dice_exit(void) | ||
| 1489 | { | ||
| 1490 | driver_unregister(&dice_driver.driver); | ||
| 1491 | } | ||
| 1492 | |||
| 1493 | module_init(alsa_dice_init); | ||
| 1494 | module_exit(alsa_dice_exit); | ||
diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c index ec578b5ad8da..860c08073c59 100644 --- a/sound/firewire/fcp.c +++ b/sound/firewire/fcp.c | |||
| @@ -90,7 +90,7 @@ int fcp_avc_transaction(struct fw_unit *unit, | |||
| 90 | : TCODE_WRITE_BLOCK_REQUEST; | 90 | : TCODE_WRITE_BLOCK_REQUEST; |
| 91 | ret = snd_fw_transaction(t.unit, tcode, | 91 | ret = snd_fw_transaction(t.unit, tcode, |
| 92 | CSR_REGISTER_BASE + CSR_FCP_COMMAND, | 92 | CSR_REGISTER_BASE + CSR_FCP_COMMAND, |
| 93 | (void *)command, command_size); | 93 | (void *)command, command_size, 0); |
| 94 | if (ret < 0) | 94 | if (ret < 0) |
| 95 | break; | 95 | break; |
| 96 | 96 | ||
diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index 58a5afefdc69..fd42e6b315e6 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c | |||
| @@ -217,7 +217,7 @@ static void isight_packet(struct fw_iso_context *context, u32 cycle, | |||
| 217 | 217 | ||
| 218 | static int isight_connect(struct isight *isight) | 218 | static int isight_connect(struct isight *isight) |
| 219 | { | 219 | { |
| 220 | int ch, err, rcode, errors = 0; | 220 | int ch, err; |
| 221 | __be32 value; | 221 | __be32 value; |
| 222 | 222 | ||
| 223 | retry_after_bus_reset: | 223 | retry_after_bus_reset: |
| @@ -230,27 +230,19 @@ retry_after_bus_reset: | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | value = cpu_to_be32(ch | (isight->device->max_speed << SPEED_SHIFT)); | 232 | value = cpu_to_be32(ch | (isight->device->max_speed << SPEED_SHIFT)); |
| 233 | for (;;) { | 233 | err = snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, |
| 234 | rcode = fw_run_transaction( | 234 | isight->audio_base + REG_ISO_TX_CONFIG, |
| 235 | isight->device->card, | 235 | &value, 4, FW_FIXED_GENERATION | |
| 236 | TCODE_WRITE_QUADLET_REQUEST, | 236 | isight->resources.generation); |
| 237 | isight->device->node_id, | 237 | if (err == -EAGAIN) { |
| 238 | isight->resources.generation, | 238 | fw_iso_resources_free(&isight->resources); |
| 239 | isight->device->max_speed, | 239 | goto retry_after_bus_reset; |
| 240 | isight->audio_base + REG_ISO_TX_CONFIG, | 240 | } else if (err < 0) { |
| 241 | &value, 4); | 241 | goto err_resources; |
| 242 | if (rcode == RCODE_COMPLETE) { | ||
| 243 | return 0; | ||
| 244 | } else if (rcode == RCODE_GENERATION) { | ||
| 245 | fw_iso_resources_free(&isight->resources); | ||
| 246 | goto retry_after_bus_reset; | ||
| 247 | } else if (rcode_is_permanent_error(rcode) || ++errors >= 3) { | ||
| 248 | err = -EIO; | ||
| 249 | goto err_resources; | ||
| 250 | } | ||
| 251 | msleep(5); | ||
| 252 | } | 242 | } |
| 253 | 243 | ||
| 244 | return 0; | ||
| 245 | |||
| 254 | err_resources: | 246 | err_resources: |
| 255 | fw_iso_resources_free(&isight->resources); | 247 | fw_iso_resources_free(&isight->resources); |
| 256 | error: | 248 | error: |
| @@ -315,17 +307,19 @@ static int isight_hw_params(struct snd_pcm_substream *substream, | |||
| 315 | static int reg_read(struct isight *isight, int offset, __be32 *value) | 307 | static int reg_read(struct isight *isight, int offset, __be32 *value) |
| 316 | { | 308 | { |
| 317 | return snd_fw_transaction(isight->unit, TCODE_READ_QUADLET_REQUEST, | 309 | return snd_fw_transaction(isight->unit, TCODE_READ_QUADLET_REQUEST, |
| 318 | isight->audio_base + offset, value, 4); | 310 | isight->audio_base + offset, value, 4, 0); |
| 319 | } | 311 | } |
| 320 | 312 | ||
| 321 | static int reg_write(struct isight *isight, int offset, __be32 value) | 313 | static int reg_write(struct isight *isight, int offset, __be32 value) |
| 322 | { | 314 | { |
| 323 | return snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, | 315 | return snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, |
| 324 | isight->audio_base + offset, &value, 4); | 316 | isight->audio_base + offset, &value, 4, 0); |
| 325 | } | 317 | } |
| 326 | 318 | ||
| 327 | static void isight_stop_streaming(struct isight *isight) | 319 | static void isight_stop_streaming(struct isight *isight) |
| 328 | { | 320 | { |
| 321 | __be32 value; | ||
| 322 | |||
| 329 | if (!isight->context) | 323 | if (!isight->context) |
| 330 | return; | 324 | return; |
| 331 | 325 | ||
| @@ -333,7 +327,10 @@ static void isight_stop_streaming(struct isight *isight) | |||
| 333 | fw_iso_context_destroy(isight->context); | 327 | fw_iso_context_destroy(isight->context); |
| 334 | isight->context = NULL; | 328 | isight->context = NULL; |
| 335 | fw_iso_resources_free(&isight->resources); | 329 | fw_iso_resources_free(&isight->resources); |
| 336 | reg_write(isight, REG_AUDIO_ENABLE, 0); | 330 | value = 0; |
| 331 | snd_fw_transaction(isight->unit, TCODE_WRITE_QUADLET_REQUEST, | ||
| 332 | isight->audio_base + REG_AUDIO_ENABLE, | ||
| 333 | &value, 4, FW_QUIET); | ||
| 337 | } | 334 | } |
| 338 | 335 | ||
| 339 | static int isight_hw_free(struct snd_pcm_substream *substream) | 336 | static int isight_hw_free(struct snd_pcm_substream *substream) |
diff --git a/sound/firewire/lib.c b/sound/firewire/lib.c index 14eb41498372..7409edba9f06 100644 --- a/sound/firewire/lib.c +++ b/sound/firewire/lib.c | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include "lib.h" | 12 | #include "lib.h" |
| 13 | 13 | ||
| 14 | #define ERROR_RETRY_DELAY_MS 5 | 14 | #define ERROR_RETRY_DELAY_MS 20 |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | * snd_fw_transaction - send a request and wait for its completion | 17 | * snd_fw_transaction - send a request and wait for its completion |
| @@ -20,6 +20,9 @@ | |||
| 20 | * @offset: the address in the target's address space | 20 | * @offset: the address in the target's address space |
| 21 | * @buffer: input/output data | 21 | * @buffer: input/output data |
| 22 | * @length: length of @buffer | 22 | * @length: length of @buffer |
| 23 | * @flags: use %FW_FIXED_GENERATION and add the generation value to attempt the | ||
| 24 | * request only in that generation; use %FW_QUIET to suppress error | ||
| 25 | * messages | ||
| 23 | * | 26 | * |
| 24 | * Submits an asynchronous request to the target device, and waits for the | 27 | * Submits an asynchronous request to the target device, and waits for the |
| 25 | * response. The node ID and the current generation are derived from @unit. | 28 | * response. The node ID and the current generation are derived from @unit. |
| @@ -27,14 +30,18 @@ | |||
| 27 | * Returns zero on success, or a negative error code. | 30 | * Returns zero on success, or a negative error code. |
| 28 | */ | 31 | */ |
| 29 | int snd_fw_transaction(struct fw_unit *unit, int tcode, | 32 | int snd_fw_transaction(struct fw_unit *unit, int tcode, |
| 30 | u64 offset, void *buffer, size_t length) | 33 | u64 offset, void *buffer, size_t length, |
| 34 | unsigned int flags) | ||
| 31 | { | 35 | { |
| 32 | struct fw_device *device = fw_parent_device(unit); | 36 | struct fw_device *device = fw_parent_device(unit); |
| 33 | int generation, rcode, tries = 0; | 37 | int generation, rcode, tries = 0; |
| 34 | 38 | ||
| 39 | generation = flags & FW_GENERATION_MASK; | ||
| 35 | for (;;) { | 40 | for (;;) { |
| 36 | generation = device->generation; | 41 | if (!(flags & FW_FIXED_GENERATION)) { |
| 37 | smp_rmb(); /* node_id vs. generation */ | 42 | generation = device->generation; |
| 43 | smp_rmb(); /* node_id vs. generation */ | ||
| 44 | } | ||
| 38 | rcode = fw_run_transaction(device->card, tcode, | 45 | rcode = fw_run_transaction(device->card, tcode, |
| 39 | device->node_id, generation, | 46 | device->node_id, generation, |
| 40 | device->max_speed, offset, | 47 | device->max_speed, offset, |
| @@ -43,9 +50,14 @@ int snd_fw_transaction(struct fw_unit *unit, int tcode, | |||
| 43 | if (rcode == RCODE_COMPLETE) | 50 | if (rcode == RCODE_COMPLETE) |
| 44 | return 0; | 51 | return 0; |
| 45 | 52 | ||
| 53 | if (rcode == RCODE_GENERATION && (flags & FW_FIXED_GENERATION)) | ||
| 54 | return -EAGAIN; | ||
| 55 | |||
| 46 | if (rcode_is_permanent_error(rcode) || ++tries >= 3) { | 56 | if (rcode_is_permanent_error(rcode) || ++tries >= 3) { |
| 47 | dev_err(&unit->device, "transaction failed: %s\n", | 57 | if (!(flags & FW_QUIET)) |
| 48 | fw_rcode_string(rcode)); | 58 | dev_err(&unit->device, |
| 59 | "transaction failed: %s\n", | ||
| 60 | fw_rcode_string(rcode)); | ||
| 49 | return -EIO; | 61 | return -EIO; |
| 50 | } | 62 | } |
| 51 | 63 | ||
diff --git a/sound/firewire/lib.h b/sound/firewire/lib.h index aef301476ea9..02cfabc9c3c4 100644 --- a/sound/firewire/lib.h +++ b/sound/firewire/lib.h | |||
| @@ -6,8 +6,13 @@ | |||
| 6 | 6 | ||
| 7 | struct fw_unit; | 7 | struct fw_unit; |
| 8 | 8 | ||
| 9 | #define FW_GENERATION_MASK 0x00ff | ||
| 10 | #define FW_FIXED_GENERATION 0x0100 | ||
| 11 | #define FW_QUIET 0x0200 | ||
| 12 | |||
| 9 | int snd_fw_transaction(struct fw_unit *unit, int tcode, | 13 | int snd_fw_transaction(struct fw_unit *unit, int tcode, |
| 10 | u64 offset, void *buffer, size_t length); | 14 | u64 offset, void *buffer, size_t length, |
| 15 | unsigned int flags); | ||
| 11 | 16 | ||
| 12 | /* returns true if retrying the transaction would not make sense */ | 17 | /* returns true if retrying the transaction would not make sense */ |
| 13 | static inline bool rcode_is_permanent_error(int rcode) | 18 | static inline bool rcode_is_permanent_error(int rcode) |
diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c index 505fc8123199..858023cf4298 100644 --- a/sound/firewire/scs1x.c +++ b/sound/firewire/scs1x.c | |||
| @@ -369,7 +369,7 @@ static int scs_init_hss_address(struct scs *scs) | |||
| 369 | data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | | 369 | data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | |
| 370 | scs->hss_handler.offset); | 370 | scs->hss_handler.offset); |
| 371 | err = snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, | 371 | err = snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, |
| 372 | HSS1394_ADDRESS, &data, 8); | 372 | HSS1394_ADDRESS, &data, 8, 0); |
| 373 | if (err < 0) | 373 | if (err < 0) |
| 374 | dev_err(&scs->unit->device, "HSS1394 communication failed\n"); | 374 | dev_err(&scs->unit->device, "HSS1394 communication failed\n"); |
| 375 | 375 | ||
| @@ -455,12 +455,16 @@ err_card: | |||
| 455 | static void scs_update(struct fw_unit *unit) | 455 | static void scs_update(struct fw_unit *unit) |
| 456 | { | 456 | { |
| 457 | struct scs *scs = dev_get_drvdata(&unit->device); | 457 | struct scs *scs = dev_get_drvdata(&unit->device); |
| 458 | int generation; | ||
| 458 | __be64 data; | 459 | __be64 data; |
| 459 | 460 | ||
| 460 | data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | | 461 | data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | |
| 461 | scs->hss_handler.offset); | 462 | scs->hss_handler.offset); |
| 463 | generation = fw_parent_device(unit)->generation; | ||
| 464 | smp_rmb(); /* node_id vs. generation */ | ||
| 462 | snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, | 465 | snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST, |
| 463 | HSS1394_ADDRESS, &data, 8); | 466 | HSS1394_ADDRESS, &data, 8, |
| 467 | FW_FIXED_GENERATION | generation); | ||
| 464 | } | 468 | } |
| 465 | 469 | ||
| 466 | static void scs_remove(struct fw_unit *unit) | 470 | static void scs_remove(struct fw_unit *unit) |
diff --git a/sound/firewire/speakers.c b/sound/firewire/speakers.c index fe9e6e2f2c5b..cc8bc3a51bc1 100644 --- a/sound/firewire/speakers.c +++ b/sound/firewire/speakers.c | |||
| @@ -52,7 +52,6 @@ struct fwspk { | |||
| 52 | struct mutex mutex; | 52 | struct mutex mutex; |
| 53 | struct cmp_connection connection; | 53 | struct cmp_connection connection; |
| 54 | struct amdtp_out_stream stream; | 54 | struct amdtp_out_stream stream; |
| 55 | bool stream_running; | ||
| 56 | bool mute; | 55 | bool mute; |
| 57 | s16 volume[6]; | 56 | s16 volume[6]; |
| 58 | s16 volume_min; | 57 | s16 volume_min; |
| @@ -188,10 +187,9 @@ static int fwspk_close(struct snd_pcm_substream *substream) | |||
| 188 | 187 | ||
| 189 | static void fwspk_stop_stream(struct fwspk *fwspk) | 188 | static void fwspk_stop_stream(struct fwspk *fwspk) |
| 190 | { | 189 | { |
| 191 | if (fwspk->stream_running) { | 190 | if (amdtp_out_stream_running(&fwspk->stream)) { |
| 192 | amdtp_out_stream_stop(&fwspk->stream); | 191 | amdtp_out_stream_stop(&fwspk->stream); |
| 193 | cmp_connection_break(&fwspk->connection); | 192 | cmp_connection_break(&fwspk->connection); |
| 194 | fwspk->stream_running = false; | ||
| 195 | } | 193 | } |
| 196 | } | 194 | } |
| 197 | 195 | ||
| @@ -246,8 +244,10 @@ static int fwspk_hw_params(struct snd_pcm_substream *substream, | |||
| 246 | if (err < 0) | 244 | if (err < 0) |
| 247 | goto error; | 245 | goto error; |
| 248 | 246 | ||
| 249 | amdtp_out_stream_set_rate(&fwspk->stream, params_rate(hw_params)); | 247 | amdtp_out_stream_set_parameters(&fwspk->stream, |
| 250 | amdtp_out_stream_set_pcm(&fwspk->stream, params_channels(hw_params)); | 248 | params_rate(hw_params), |
| 249 | params_channels(hw_params), | ||
| 250 | 0); | ||
| 251 | 251 | ||
| 252 | amdtp_out_stream_set_pcm_format(&fwspk->stream, | 252 | amdtp_out_stream_set_pcm_format(&fwspk->stream, |
| 253 | params_format(hw_params)); | 253 | params_format(hw_params)); |
| @@ -285,7 +285,7 @@ static int fwspk_prepare(struct snd_pcm_substream *substream) | |||
| 285 | if (amdtp_out_streaming_error(&fwspk->stream)) | 285 | if (amdtp_out_streaming_error(&fwspk->stream)) |
| 286 | fwspk_stop_stream(fwspk); | 286 | fwspk_stop_stream(fwspk); |
| 287 | 287 | ||
| 288 | if (!fwspk->stream_running) { | 288 | if (!amdtp_out_stream_running(&fwspk->stream)) { |
| 289 | err = cmp_connection_establish(&fwspk->connection, | 289 | err = cmp_connection_establish(&fwspk->connection, |
| 290 | amdtp_out_stream_get_max_payload(&fwspk->stream)); | 290 | amdtp_out_stream_get_max_payload(&fwspk->stream)); |
| 291 | if (err < 0) | 291 | if (err < 0) |
| @@ -296,8 +296,6 @@ static int fwspk_prepare(struct snd_pcm_substream *substream) | |||
| 296 | fwspk->connection.speed); | 296 | fwspk->connection.speed); |
| 297 | if (err < 0) | 297 | if (err < 0) |
| 298 | goto err_connection; | 298 | goto err_connection; |
| 299 | |||
| 300 | fwspk->stream_running = true; | ||
| 301 | } | 299 | } |
| 302 | 300 | ||
| 303 | mutex_unlock(&fwspk->mutex); | 301 | mutex_unlock(&fwspk->mutex); |
| @@ -647,7 +645,7 @@ static u32 fwspk_read_firmware_version(struct fw_unit *unit) | |||
| 647 | int err; | 645 | int err; |
| 648 | 646 | ||
| 649 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, | 647 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, |
| 650 | OXFORD_FIRMWARE_ID_ADDRESS, &data, 4); | 648 | OXFORD_FIRMWARE_ID_ADDRESS, &data, 4, 0); |
| 651 | return err >= 0 ? be32_to_cpu(data) : 0; | 649 | return err >= 0 ? be32_to_cpu(data) : 0; |
| 652 | } | 650 | } |
| 653 | 651 | ||
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 5bf4fca19e48..15ae0250eace 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c | |||
| @@ -60,7 +60,7 @@ static void reg_dump(struct ak4114 *ak4114) | |||
| 60 | 60 | ||
| 61 | printk(KERN_DEBUG "AK4114 REG DUMP:\n"); | 61 | printk(KERN_DEBUG "AK4114 REG DUMP:\n"); |
| 62 | for (i = 0; i < 0x20; i++) | 62 | for (i = 0; i < 0x20; i++) |
| 63 | printk(KERN_DEBUG "reg[%02x] = %02x (%02x)\n", i, reg_read(ak4114, i), i < sizeof(ak4114->regmap) ? ak4114->regmap[i] : 0); | 63 | printk(KERN_DEBUG "reg[%02x] = %02x (%02x)\n", i, reg_read(ak4114, i), i < ARRAY_SIZE(ak4114->regmap) ? ak4114->regmap[i] : 0); |
| 64 | } | 64 | } |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| @@ -81,7 +81,7 @@ static int snd_ak4114_dev_free(struct snd_device *device) | |||
| 81 | 81 | ||
| 82 | int snd_ak4114_create(struct snd_card *card, | 82 | int snd_ak4114_create(struct snd_card *card, |
| 83 | ak4114_read_t *read, ak4114_write_t *write, | 83 | ak4114_read_t *read, ak4114_write_t *write, |
| 84 | const unsigned char pgm[7], const unsigned char txcsb[5], | 84 | const unsigned char pgm[6], const unsigned char txcsb[5], |
| 85 | void *private_data, struct ak4114 **r_ak4114) | 85 | void *private_data, struct ak4114 **r_ak4114) |
| 86 | { | 86 | { |
| 87 | struct ak4114 *chip; | 87 | struct ak4114 *chip; |
| @@ -101,7 +101,7 @@ int snd_ak4114_create(struct snd_card *card, | |||
| 101 | chip->private_data = private_data; | 101 | chip->private_data = private_data; |
| 102 | INIT_DELAYED_WORK(&chip->work, ak4114_stats); | 102 | INIT_DELAYED_WORK(&chip->work, ak4114_stats); |
| 103 | 103 | ||
| 104 | for (reg = 0; reg < 7; reg++) | 104 | for (reg = 0; reg < 6; reg++) |
| 105 | chip->regmap[reg] = pgm[reg]; | 105 | chip->regmap[reg] = pgm[reg]; |
| 106 | for (reg = 0; reg < 5; reg++) | 106 | for (reg = 0; reg < 5; reg++) |
| 107 | chip->txcsb[reg] = txcsb[reg]; | 107 | chip->txcsb[reg] = txcsb[reg]; |
| @@ -142,7 +142,7 @@ static void ak4114_init_regs(struct ak4114 *chip) | |||
| 142 | /* release reset, but leave powerdown */ | 142 | /* release reset, but leave powerdown */ |
| 143 | reg_write(chip, AK4114_REG_PWRDN, (old | AK4114_RST) & ~AK4114_PWN); | 143 | reg_write(chip, AK4114_REG_PWRDN, (old | AK4114_RST) & ~AK4114_PWN); |
| 144 | udelay(200); | 144 | udelay(200); |
| 145 | for (reg = 1; reg < 7; reg++) | 145 | for (reg = 1; reg < 6; reg++) |
| 146 | reg_write(chip, reg, chip->regmap[reg]); | 146 | reg_write(chip, reg, chip->regmap[reg]); |
| 147 | for (reg = 0; reg < 5; reg++) | 147 | for (reg = 0; reg < 5; reg++) |
| 148 | reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]); | 148 | reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]); |
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index ed726d1569e8..f3735e64791c 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c | |||
| @@ -583,7 +583,7 @@ static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol, | |||
| 583 | if (idx >= num_names) | 583 | if (idx >= num_names) |
| 584 | return -EINVAL; | 584 | return -EINVAL; |
| 585 | input_names = ak->adc_info[mixer_ch].input_names; | 585 | input_names = ak->adc_info[mixer_ch].input_names; |
| 586 | strncpy(uinfo->value.enumerated.name, input_names[idx], | 586 | strlcpy(uinfo->value.enumerated.name, input_names[idx], |
| 587 | sizeof(uinfo->value.enumerated.name)); | 587 | sizeof(uinfo->value.enumerated.name)); |
| 588 | return 0; | 588 | return 0; |
| 589 | } | 589 | } |
diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c index f84f073fc1e8..ab6b2dc043f1 100644 --- a/sound/isa/cmi8328.c +++ b/sound/isa/cmi8328.c | |||
| @@ -126,6 +126,7 @@ static void snd_cmi8328_cfg_write(u16 port, u8 reg, u8 val) | |||
| 126 | outb(val, port + 3); /* yes, value goes to the same port as index */ | 126 | outb(val, port + 3); /* yes, value goes to the same port as index */ |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | #ifdef CONFIG_PM | ||
| 129 | static void snd_cmi8328_cfg_save(u16 port, u8 cfg[]) | 130 | static void snd_cmi8328_cfg_save(u16 port, u8 cfg[]) |
| 130 | { | 131 | { |
| 131 | cfg[0] = snd_cmi8328_cfg_read(port, CFG1); | 132 | cfg[0] = snd_cmi8328_cfg_read(port, CFG1); |
| @@ -139,6 +140,7 @@ static void snd_cmi8328_cfg_restore(u16 port, u8 cfg[]) | |||
| 139 | snd_cmi8328_cfg_write(port, CFG2, cfg[1]); | 140 | snd_cmi8328_cfg_write(port, CFG2, cfg[1]); |
| 140 | snd_cmi8328_cfg_write(port, CFG3, cfg[2]); | 141 | snd_cmi8328_cfg_write(port, CFG3, cfg[2]); |
| 141 | } | 142 | } |
| 143 | #endif /* CONFIG_PM */ | ||
| 142 | 144 | ||
| 143 | static int snd_cmi8328_mixer(struct snd_wss *chip) | 145 | static int snd_cmi8328_mixer(struct snd_wss *chip) |
| 144 | { | 146 | { |
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index 81aeb934261a..0a90bd6ae232 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c | |||
| @@ -73,9 +73,11 @@ | |||
| 73 | #ifdef MSND_CLASSIC | 73 | #ifdef MSND_CLASSIC |
| 74 | # include "msnd_classic.h" | 74 | # include "msnd_classic.h" |
| 75 | # define LOGNAME "msnd_classic" | 75 | # define LOGNAME "msnd_classic" |
| 76 | # define DEV_NAME "msnd-classic" | ||
| 76 | #else | 77 | #else |
| 77 | # include "msnd_pinnacle.h" | 78 | # include "msnd_pinnacle.h" |
| 78 | # define LOGNAME "snd_msnd_pinnacle" | 79 | # define LOGNAME "snd_msnd_pinnacle" |
| 80 | # define DEV_NAME "msnd-pinnacle" | ||
| 79 | #endif | 81 | #endif |
| 80 | 82 | ||
| 81 | static void set_default_audio_parameters(struct snd_msnd *chip) | 83 | static void set_default_audio_parameters(struct snd_msnd *chip) |
| @@ -1067,8 +1069,6 @@ static int snd_msnd_isa_remove(struct device *pdev, unsigned int dev) | |||
| 1067 | return 0; | 1069 | return 0; |
| 1068 | } | 1070 | } |
| 1069 | 1071 | ||
| 1070 | #define DEV_NAME "msnd-pinnacle" | ||
| 1071 | |||
| 1072 | static struct isa_driver snd_msnd_driver = { | 1072 | static struct isa_driver snd_msnd_driver = { |
| 1073 | .match = snd_msnd_isa_match, | 1073 | .match = snd_msnd_isa_match, |
| 1074 | .probe = snd_msnd_isa_probe, | 1074 | .probe = snd_msnd_isa_probe, |
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index c1aa21edcb65..48da2276683d 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c | |||
| @@ -208,6 +208,7 @@ static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned i | |||
| 208 | switch (cmd) { | 208 | switch (cmd) { |
| 209 | /* get information */ | 209 | /* get information */ |
| 210 | case SNDRV_SB_CSP_IOCTL_INFO: | 210 | case SNDRV_SB_CSP_IOCTL_INFO: |
| 211 | memset(&info, 0, sizeof(info)); | ||
| 211 | *info.codec_name = *p->codec_name; | 212 | *info.codec_name = *p->codec_name; |
| 212 | info.func_nr = p->func_nr; | 213 | info.func_nr = p->func_nr; |
| 213 | info.acc_format = p->acc_format; | 214 | info.acc_format = p->acc_format; |
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index a2f87f9488ee..e5db001363ee 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c | |||
| @@ -1196,7 +1196,7 @@ wavefront_send_multisample (snd_wavefront_t *dev, wavefront_patch_info *header) | |||
| 1196 | int num_samples; | 1196 | int num_samples; |
| 1197 | unsigned char *msample_hdr; | 1197 | unsigned char *msample_hdr; |
| 1198 | 1198 | ||
| 1199 | msample_hdr = kmalloc(sizeof(WF_MSAMPLE_BYTES), GFP_KERNEL); | 1199 | msample_hdr = kmalloc(WF_MSAMPLE_BYTES, GFP_KERNEL); |
| 1200 | if (! msample_hdr) | 1200 | if (! msample_hdr) |
| 1201 | return -ENOMEM; | 1201 | return -ENOMEM; |
| 1202 | 1202 | ||
diff --git a/sound/mips/ad1843.c b/sound/mips/ad1843.c index c624510ec374..586907500ca5 100644 --- a/sound/mips/ad1843.c +++ b/sound/mips/ad1843.c | |||
| @@ -276,7 +276,7 @@ static void ad1843_write_multi(struct snd_ad1843 *ad1843, int argcount, ...) | |||
| 276 | if (reg == -1) | 276 | if (reg == -1) |
| 277 | reg = fp->reg; | 277 | reg = fp->reg; |
| 278 | else | 278 | else |
| 279 | BUG_ON(reg != fp->reg); | 279 | WARN_ON(reg != fp->reg); |
| 280 | m = ((1 << fp->nbits) - 1) << fp->lo_bit; | 280 | m = ((1 << fp->nbits) - 1) << fp->lo_bit; |
| 281 | mask |= m; | 281 | mask |= m; |
| 282 | bits |= (value << fp->lo_bit) & m; | 282 | bits |= (value << fp->lo_bit) & m; |
diff --git a/sound/oss/sb_ess.c b/sound/oss/sb_ess.c index c0be085e4a20..0e7254bde4c2 100644 --- a/sound/oss/sb_ess.c +++ b/sound/oss/sb_ess.c | |||
| @@ -1544,7 +1544,7 @@ static int ess_has_rec_mixer (int submodel) | |||
| 1544 | return 1; | 1544 | return 1; |
| 1545 | default: | 1545 | default: |
| 1546 | return 0; | 1546 | return 0; |
| 1547 | }; | 1547 | } |
| 1548 | }; | 1548 | }; |
| 1549 | 1549 | ||
| 1550 | #ifdef FKS_LOGGING | 1550 | #ifdef FKS_LOGGING |
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index d2b9d617aee5..b680d03e2419 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c | |||
| @@ -739,7 +739,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe | |||
| 739 | reg = ad1889_readw(chip, AD_DS_WADA); | 739 | reg = ad1889_readw(chip, AD_DS_WADA); |
| 740 | snd_iprintf(buffer, "Right: %s, -%d dB\n", | 740 | snd_iprintf(buffer, "Right: %s, -%d dB\n", |
| 741 | (reg & AD_DS_WADA_RWAM) ? "mute" : "unmute", | 741 | (reg & AD_DS_WADA_RWAM) ? "mute" : "unmute", |
| 742 | ((reg & AD_DS_WADA_RWAA) >> 8) * 3); | 742 | (reg & AD_DS_WADA_RWAA) * 3); |
| 743 | 743 | ||
| 744 | reg = ad1889_readw(chip, AD_DS_WAS); | 744 | reg = ad1889_readw(chip, AD_DS_WAS); |
| 745 | snd_iprintf(buffer, "Wave samplerate: %u Hz\n", reg); | 745 | snd_iprintf(buffer, "Wave samplerate: %u Hz\n", reg); |
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 3dfa12b670eb..c6835a3d64fb 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c | |||
| @@ -855,7 +855,6 @@ static void snd_ali_disable_spdif_out(struct snd_ali *codec) | |||
| 855 | static void snd_ali_update_ptr(struct snd_ali *codec, int channel) | 855 | static void snd_ali_update_ptr(struct snd_ali *codec, int channel) |
| 856 | { | 856 | { |
| 857 | struct snd_ali_voice *pvoice; | 857 | struct snd_ali_voice *pvoice; |
| 858 | struct snd_pcm_runtime *runtime; | ||
| 859 | struct snd_ali_channel_control *pchregs; | 858 | struct snd_ali_channel_control *pchregs; |
| 860 | unsigned int old, mask; | 859 | unsigned int old, mask; |
| 861 | #ifdef ALI_DEBUG | 860 | #ifdef ALI_DEBUG |
| @@ -872,7 +871,6 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel) | |||
| 872 | return; | 871 | return; |
| 873 | 872 | ||
| 874 | pvoice = &codec->synth.voices[channel]; | 873 | pvoice = &codec->synth.voices[channel]; |
| 875 | runtime = pvoice->substream->runtime; | ||
| 876 | 874 | ||
| 877 | udelay(100); | 875 | udelay(100); |
| 878 | spin_lock(&codec->reg_lock); | 876 | spin_lock(&codec->reg_lock); |
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index dc632cdc3870..5f2acd35dcb9 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
| @@ -1913,6 +1913,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, | |||
| 1913 | struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); | 1913 | struct snd_card_asihpi *asihpi = snd_kcontrol_chip(kcontrol); |
| 1914 | */ | 1914 | */ |
| 1915 | u32 h_control = kcontrol->private_value; | 1915 | u32 h_control = kcontrol->private_value; |
| 1916 | unsigned int idx; | ||
| 1916 | u16 band; | 1917 | u16 band; |
| 1917 | u16 tuner_bands[HPI_TUNER_BAND_LAST]; | 1918 | u16 tuner_bands[HPI_TUNER_BAND_LAST]; |
| 1918 | u32 num_bands = 0; | 1919 | u32 num_bands = 0; |
| @@ -1920,7 +1921,10 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, | |||
| 1920 | num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, | 1921 | num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands, |
| 1921 | HPI_TUNER_BAND_LAST); | 1922 | HPI_TUNER_BAND_LAST); |
| 1922 | 1923 | ||
| 1923 | band = tuner_bands[ucontrol->value.enumerated.item[0]]; | 1924 | idx = ucontrol->value.enumerated.item[0]; |
| 1925 | if (idx >= ARRAY_SIZE(tuner_bands)) | ||
| 1926 | idx = ARRAY_SIZE(tuner_bands) - 1; | ||
| 1927 | band = tuner_bands[idx]; | ||
| 1924 | hpi_handle_error(hpi_tuner_set_band(h_control, band)); | 1928 | hpi_handle_error(hpi_tuner_set_band(h_control, band)); |
| 1925 | 1929 | ||
| 1926 | return 1; | 1930 | return 1; |
| @@ -2383,7 +2387,8 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol, | |||
| 2383 | struct snd_card_asihpi *asihpi = | 2387 | struct snd_card_asihpi *asihpi = |
| 2384 | (struct snd_card_asihpi *)(kcontrol->private_data); | 2388 | (struct snd_card_asihpi *)(kcontrol->private_data); |
| 2385 | struct clk_cache *clkcache = &asihpi->cc; | 2389 | struct clk_cache *clkcache = &asihpi->cc; |
| 2386 | int change, item; | 2390 | unsigned int item; |
| 2391 | int change; | ||
| 2387 | u32 h_control = kcontrol->private_value; | 2392 | u32 h_control = kcontrol->private_value; |
| 2388 | 2393 | ||
| 2389 | change = 1; | 2394 | change = 1; |
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index b46dc9b24dbd..9fb03b4ea925 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c | |||
| @@ -671,7 +671,7 @@ static int snd_vortex_new_pcm(vortex_t *chip, int idx, int nr) | |||
| 671 | return err; | 671 | return err; |
| 672 | break; | 672 | break; |
| 673 | #endif | 673 | #endif |
| 674 | }; | 674 | } |
| 675 | 675 | ||
| 676 | if (VORTEX_PCM_TYPE(pcm) == VORTEX_PCM_SPDIF) { | 676 | if (VORTEX_PCM_TYPE(pcm) == VORTEX_PCM_SPDIF) { |
| 677 | for (i = 0; i < ARRAY_SIZE(snd_vortex_mixer_spdif); i++) { | 677 | for (i = 0; i < ARRAY_SIZE(snd_vortex_mixer_spdif); i++) { |
diff --git a/sound/pci/au88x0/au88x0_synth.c b/sound/pci/au88x0/au88x0_synth.c index 8bef47311e45..922a84bba2ef 100644 --- a/sound/pci/au88x0/au88x0_synth.c +++ b/sound/pci/au88x0/au88x0_synth.c | |||
| @@ -219,7 +219,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 219 | */ | 219 | */ |
| 220 | hwwrite(vortex->mmio, WT_RUN(wt), val); | 220 | hwwrite(vortex->mmio, WT_RUN(wt), val); |
| 221 | return 0xc; | 221 | return 0xc; |
| 222 | break; | ||
| 223 | case 1: /* param 0 */ | 222 | case 1: /* param 0 */ |
| 224 | /* | 223 | /* |
| 225 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", | 224 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", |
| @@ -227,7 +226,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 227 | */ | 226 | */ |
| 228 | hwwrite(vortex->mmio, WT_PARM(wt, 0), val); | 227 | hwwrite(vortex->mmio, WT_PARM(wt, 0), val); |
| 229 | return 0xc; | 228 | return 0xc; |
| 230 | break; | ||
| 231 | case 2: /* param 1 */ | 229 | case 2: /* param 1 */ |
| 232 | /* | 230 | /* |
| 233 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", | 231 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", |
| @@ -235,7 +233,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 235 | */ | 233 | */ |
| 236 | hwwrite(vortex->mmio, WT_PARM(wt, 1), val); | 234 | hwwrite(vortex->mmio, WT_PARM(wt, 1), val); |
| 237 | return 0xc; | 235 | return 0xc; |
| 238 | break; | ||
| 239 | case 3: /* param 2 */ | 236 | case 3: /* param 2 */ |
| 240 | /* | 237 | /* |
| 241 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", | 238 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", |
| @@ -243,7 +240,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 243 | */ | 240 | */ |
| 244 | hwwrite(vortex->mmio, WT_PARM(wt, 2), val); | 241 | hwwrite(vortex->mmio, WT_PARM(wt, 2), val); |
| 245 | return 0xc; | 242 | return 0xc; |
| 246 | break; | ||
| 247 | case 4: /* param 3 */ | 243 | case 4: /* param 3 */ |
| 248 | /* | 244 | /* |
| 249 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", | 245 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", |
| @@ -251,7 +247,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 251 | */ | 247 | */ |
| 252 | hwwrite(vortex->mmio, WT_PARM(wt, 3), val); | 248 | hwwrite(vortex->mmio, WT_PARM(wt, 3), val); |
| 253 | return 0xc; | 249 | return 0xc; |
| 254 | break; | ||
| 255 | case 6: /* mute */ | 250 | case 6: /* mute */ |
| 256 | /* | 251 | /* |
| 257 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", | 252 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", |
| @@ -259,20 +254,17 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 259 | */ | 254 | */ |
| 260 | hwwrite(vortex->mmio, WT_MUTE(wt), val); | 255 | hwwrite(vortex->mmio, WT_MUTE(wt), val); |
| 261 | return 0xc; | 256 | return 0xc; |
| 262 | break; | ||
| 263 | case 0xb: | 257 | case 0xb: |
| 264 | { /* delay */ | 258 | /* delay */ |
| 265 | /* | 259 | /* |
| 266 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", | 260 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", |
| 267 | WT_DELAY(wt,0), (int)val); | 261 | WT_DELAY(wt,0), (int)val); |
| 268 | */ | 262 | */ |
| 269 | hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); | 263 | hwwrite(vortex->mmio, WT_DELAY(wt, 3), val); |
| 270 | hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); | 264 | hwwrite(vortex->mmio, WT_DELAY(wt, 2), val); |
| 271 | hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); | 265 | hwwrite(vortex->mmio, WT_DELAY(wt, 1), val); |
| 272 | hwwrite(vortex->mmio, WT_DELAY(wt, 0), val); | 266 | hwwrite(vortex->mmio, WT_DELAY(wt, 0), val); |
| 273 | return 0xc; | 267 | return 0xc; |
| 274 | } | ||
| 275 | break; | ||
| 276 | /* Global WT block parameters */ | 268 | /* Global WT block parameters */ |
| 277 | case 5: /* sramp */ | 269 | case 5: /* sramp */ |
| 278 | ecx = WT_SRAMP(wt); | 270 | ecx = WT_SRAMP(wt); |
| @@ -291,7 +283,6 @@ vortex_wt_SetReg(vortex_t * vortex, unsigned char reg, int wt, | |||
| 291 | break; | 283 | break; |
| 292 | default: | 284 | default: |
| 293 | return 0; | 285 | return 0; |
| 294 | break; | ||
| 295 | } | 286 | } |
| 296 | /* | 287 | /* |
| 297 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val); | 288 | printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n", ecx, (int)val); |
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index c8e121611593..1aef7128f7ca 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c | |||
| @@ -715,14 +715,14 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97) | |||
| 715 | const struct snd_azf3328 *chip = ac97->private_data; | 715 | const struct snd_azf3328 *chip = ac97->private_data; |
| 716 | unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); | 716 | unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); |
| 717 | unsigned short reg_val = 0; | 717 | unsigned short reg_val = 0; |
| 718 | bool unsupported = 0; | 718 | bool unsupported = false; |
| 719 | 719 | ||
| 720 | snd_azf3328_dbgmixer( | 720 | snd_azf3328_dbgmixer( |
| 721 | "snd_azf3328_mixer_ac97_read reg_ac97 %u\n", | 721 | "snd_azf3328_mixer_ac97_read reg_ac97 %u\n", |
| 722 | reg_ac97 | 722 | reg_ac97 |
| 723 | ); | 723 | ); |
| 724 | if (reg_azf & AZF_AC97_REG_UNSUPPORTED) | 724 | if (reg_azf & AZF_AC97_REG_UNSUPPORTED) |
| 725 | unsupported = 1; | 725 | unsupported = true; |
| 726 | else { | 726 | else { |
| 727 | if (reg_azf & AZF_AC97_REG_REAL_IO_READ) | 727 | if (reg_azf & AZF_AC97_REG_REAL_IO_READ) |
| 728 | reg_val = snd_azf3328_mixer_inw(chip, | 728 | reg_val = snd_azf3328_mixer_inw(chip, |
| @@ -759,7 +759,7 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97) | |||
| 759 | reg_val = azf_emulated_ac97_vendor_id & 0xffff; | 759 | reg_val = azf_emulated_ac97_vendor_id & 0xffff; |
| 760 | break; | 760 | break; |
| 761 | default: | 761 | default: |
| 762 | unsupported = 1; | 762 | unsupported = true; |
| 763 | break; | 763 | break; |
| 764 | } | 764 | } |
| 765 | } | 765 | } |
| @@ -776,14 +776,14 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97, | |||
| 776 | { | 776 | { |
| 777 | const struct snd_azf3328 *chip = ac97->private_data; | 777 | const struct snd_azf3328 *chip = ac97->private_data; |
| 778 | unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); | 778 | unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); |
| 779 | bool unsupported = 0; | 779 | bool unsupported = false; |
| 780 | 780 | ||
| 781 | snd_azf3328_dbgmixer( | 781 | snd_azf3328_dbgmixer( |
| 782 | "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n", | 782 | "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n", |
| 783 | reg_ac97, val | 783 | reg_ac97, val |
| 784 | ); | 784 | ); |
| 785 | if (reg_azf & AZF_AC97_REG_UNSUPPORTED) | 785 | if (reg_azf & AZF_AC97_REG_UNSUPPORTED) |
| 786 | unsupported = 1; | 786 | unsupported = true; |
| 787 | else { | 787 | else { |
| 788 | if (reg_azf & AZF_AC97_REG_REAL_IO_WRITE) | 788 | if (reg_azf & AZF_AC97_REG_REAL_IO_WRITE) |
| 789 | snd_azf3328_mixer_outw( | 789 | snd_azf3328_mixer_outw( |
| @@ -808,7 +808,7 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97, | |||
| 808 | */ | 808 | */ |
| 809 | break; | 809 | break; |
| 810 | default: | 810 | default: |
| 811 | unsupported = 1; | 811 | unsupported = true; |
| 812 | break; | 812 | break; |
| 813 | } | 813 | } |
| 814 | } | 814 | } |
| @@ -1559,7 +1559,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
| 1559 | struct snd_azf3328_codec_data *codec = runtime->private_data; | 1559 | struct snd_azf3328_codec_data *codec = runtime->private_data; |
| 1560 | int result = 0; | 1560 | int result = 0; |
| 1561 | u16 flags1; | 1561 | u16 flags1; |
| 1562 | bool previously_muted = 0; | 1562 | bool previously_muted = false; |
| 1563 | bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type); | 1563 | bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type); |
| 1564 | 1564 | ||
| 1565 | snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd); | 1565 | snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd); |
diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index da1cb9c4c76c..e6a44507d557 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c | |||
| @@ -161,13 +161,13 @@ int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | |||
| 161 | /* drop the original AD1888 HPF control */ | 161 | /* drop the original AD1888 HPF control */ |
| 162 | memset(&elem, 0, sizeof(elem)); | 162 | memset(&elem, 0, sizeof(elem)); |
| 163 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 163 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 164 | strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); | 164 | strlcpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); |
| 165 | snd_ctl_remove_id(card, &elem); | 165 | snd_ctl_remove_id(card, &elem); |
| 166 | 166 | ||
| 167 | /* drop the original V_REFOUT control */ | 167 | /* drop the original V_REFOUT control */ |
| 168 | memset(&elem, 0, sizeof(elem)); | 168 | memset(&elem, 0, sizeof(elem)); |
| 169 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 169 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 170 | strncpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); | 170 | strlcpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); |
| 171 | snd_ctl_remove_id(card, &elem); | 171 | snd_ctl_remove_id(card, &elem); |
| 172 | 172 | ||
| 173 | /* add the OLPC-specific controls */ | 173 | /* add the OLPC-specific controls */ |
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 0c00eb4088ef..84f86bf63b8f 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c | |||
| @@ -33,7 +33,7 @@ struct daio_rsc_idx { | |||
| 33 | unsigned short right; | 33 | unsigned short right; |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { | 36 | static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { |
| 37 | [LINEO1] = {.left = 0x00, .right = 0x01}, | 37 | [LINEO1] = {.left = 0x00, .right = 0x01}, |
| 38 | [LINEO2] = {.left = 0x18, .right = 0x19}, | 38 | [LINEO2] = {.left = 0x18, .right = 0x19}, |
| 39 | [LINEO3] = {.left = 0x08, .right = 0x09}, | 39 | [LINEO3] = {.left = 0x08, .right = 0x09}, |
| @@ -44,7 +44,7 @@ struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { | |||
| 44 | [SPDIFI1] = {.left = 0x95, .right = 0x9d}, | 44 | [SPDIFI1] = {.left = 0x95, .right = 0x9d}, |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { | 47 | static struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { |
| 48 | [LINEO1] = {.left = 0x40, .right = 0x41}, | 48 | [LINEO1] = {.left = 0x40, .right = 0x41}, |
| 49 | [LINEO2] = {.left = 0x60, .right = 0x61}, | 49 | [LINEO2] = {.left = 0x60, .right = 0x61}, |
| 50 | [LINEO3] = {.left = 0x50, .right = 0x51}, | 50 | [LINEO3] = {.left = 0x50, .right = 0x51}, |
diff --git a/sound/pci/ctxfi/cthardware.c b/sound/pci/ctxfi/cthardware.c index 110b8ace6d8a..a689f2552706 100644 --- a/sound/pci/ctxfi/cthardware.c +++ b/sound/pci/ctxfi/cthardware.c | |||
| @@ -69,7 +69,8 @@ unsigned int get_field(unsigned int data, unsigned int field) | |||
| 69 | { | 69 | { |
| 70 | int i; | 70 | int i; |
| 71 | 71 | ||
| 72 | BUG_ON(!field); | 72 | if (WARN_ON(!field)) |
| 73 | return 0; | ||
| 73 | /* @field should always be greater than 0 */ | 74 | /* @field should always be greater than 0 */ |
| 74 | for (i = 0; !(field & (1 << i)); ) | 75 | for (i = 0; !(field & (1 << i)); ) |
| 75 | i++; | 76 | i++; |
| @@ -81,7 +82,8 @@ void set_field(unsigned int *data, unsigned int field, unsigned int value) | |||
| 81 | { | 82 | { |
| 82 | int i; | 83 | int i; |
| 83 | 84 | ||
| 84 | BUG_ON(!field); | 85 | if (WARN_ON(!field)) |
| 86 | return; | ||
| 85 | /* @field should always be greater than 0 */ | 87 | /* @field should always be greater than 0 */ |
| 86 | for (i = 0; !(field & (1 << i)); ) | 88 | for (i = 0; !(field & (1 << i)); ) |
| 87 | i++; | 89 | i++; |
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 0275209ca82e..1f9c7c4bbcd8 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
| @@ -1182,15 +1182,20 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) | |||
| 1182 | u32 *gpr_map; | 1182 | u32 *gpr_map; |
| 1183 | mm_segment_t seg; | 1183 | mm_segment_t seg; |
| 1184 | 1184 | ||
| 1185 | if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || | 1185 | err = -ENOMEM; |
| 1186 | (icode->gpr_map = (u_int32_t __user *) | 1186 | icode = kzalloc(sizeof(*icode), GFP_KERNEL); |
| 1187 | kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), | 1187 | if (!icode) |
| 1188 | GFP_KERNEL)) == NULL || | 1188 | return err; |
| 1189 | (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, | 1189 | |
| 1190 | sizeof(*controls), GFP_KERNEL)) == NULL) { | 1190 | icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024, |
| 1191 | err = -ENOMEM; | 1191 | sizeof(u_int32_t), GFP_KERNEL); |
| 1192 | goto __err; | 1192 | if (!icode->gpr_map) |
| 1193 | } | 1193 | goto __err_gpr; |
| 1194 | controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, | ||
| 1195 | sizeof(*controls), GFP_KERNEL); | ||
| 1196 | if (!controls) | ||
| 1197 | goto __err_ctrls; | ||
| 1198 | |||
| 1194 | gpr_map = (u32 __force *)icode->gpr_map; | 1199 | gpr_map = (u32 __force *)icode->gpr_map; |
| 1195 | 1200 | ||
| 1196 | icode->tram_data_map = icode->gpr_map + 512; | 1201 | icode->tram_data_map = icode->gpr_map + 512; |
| @@ -1741,12 +1746,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
| 1741 | emu->support_tlv = 0; /* clear again */ | 1746 | emu->support_tlv = 0; /* clear again */ |
| 1742 | snd_leave_user(seg); | 1747 | snd_leave_user(seg); |
| 1743 | 1748 | ||
| 1744 | __err: | 1749 | __err: |
| 1745 | kfree(controls); | 1750 | kfree(controls); |
| 1746 | if (icode != NULL) { | 1751 | __err_ctrls: |
| 1747 | kfree((void __force *)icode->gpr_map); | 1752 | kfree((void __force *)icode->gpr_map); |
| 1748 | kfree(icode); | 1753 | __err_gpr: |
| 1749 | } | 1754 | kfree(icode); |
| 1750 | return err; | 1755 | return err; |
| 1751 | } | 1756 | } |
| 1752 | 1757 | ||
| @@ -1813,18 +1818,26 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) | |||
| 1813 | u32 *gpr_map; | 1818 | u32 *gpr_map; |
| 1814 | mm_segment_t seg; | 1819 | mm_segment_t seg; |
| 1815 | 1820 | ||
| 1816 | if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) | 1821 | err = -ENOMEM; |
| 1817 | return -ENOMEM; | 1822 | icode = kzalloc(sizeof(*icode), GFP_KERNEL); |
| 1818 | if ((icode->gpr_map = (u_int32_t __user *) | 1823 | if (!icode) |
| 1819 | kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), | 1824 | return err; |
| 1820 | GFP_KERNEL)) == NULL || | 1825 | |
| 1821 | (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, | 1826 | icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512, |
| 1822 | sizeof(struct snd_emu10k1_fx8010_control_gpr), | 1827 | sizeof(u_int32_t), GFP_KERNEL); |
| 1823 | GFP_KERNEL)) == NULL || | 1828 | if (!icode->gpr_map) |
| 1824 | (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { | 1829 | goto __err_gpr; |
| 1825 | err = -ENOMEM; | 1830 | |
| 1826 | goto __err; | 1831 | controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, |
| 1827 | } | 1832 | sizeof(struct snd_emu10k1_fx8010_control_gpr), |
| 1833 | GFP_KERNEL); | ||
| 1834 | if (!controls) | ||
| 1835 | goto __err_ctrls; | ||
| 1836 | |||
| 1837 | ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); | ||
| 1838 | if (!ipcm) | ||
| 1839 | goto __err_ipcm; | ||
| 1840 | |||
| 1828 | gpr_map = (u32 __force *)icode->gpr_map; | 1841 | gpr_map = (u32 __force *)icode->gpr_map; |
| 1829 | 1842 | ||
| 1830 | icode->tram_data_map = icode->gpr_map + 256; | 1843 | icode->tram_data_map = icode->gpr_map + 256; |
| @@ -2363,13 +2376,14 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) | |||
| 2363 | snd_leave_user(seg); | 2376 | snd_leave_user(seg); |
| 2364 | if (err >= 0) | 2377 | if (err >= 0) |
| 2365 | err = snd_emu10k1_ipcm_poke(emu, ipcm); | 2378 | err = snd_emu10k1_ipcm_poke(emu, ipcm); |
| 2366 | __err: | 2379 | __err: |
| 2367 | kfree(ipcm); | 2380 | kfree(ipcm); |
| 2381 | __err_ipcm: | ||
| 2368 | kfree(controls); | 2382 | kfree(controls); |
| 2369 | if (icode != NULL) { | 2383 | __err_ctrls: |
| 2370 | kfree((void __force *)icode->gpr_map); | 2384 | kfree((void __force *)icode->gpr_map); |
| 2371 | kfree(icode); | 2385 | __err_gpr: |
| 2372 | } | 2386 | kfree(icode); |
| 2373 | return err; | 2387 | return err; |
| 2374 | } | 2388 | } |
| 2375 | 2389 | ||
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 8de66ccd7279..4cdd9ded4563 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
| @@ -209,8 +209,9 @@ config SND_HDA_CODEC_CA0132 | |||
| 209 | 209 | ||
| 210 | config SND_HDA_CODEC_CA0132_DSP | 210 | config SND_HDA_CODEC_CA0132_DSP |
| 211 | bool "Support new DSP code for CA0132 codec" | 211 | bool "Support new DSP code for CA0132 codec" |
| 212 | depends on SND_HDA_CODEC_CA0132 && FW_LOADER | 212 | depends on SND_HDA_CODEC_CA0132 |
| 213 | select SND_HDA_DSP_LOADER | 213 | select SND_HDA_DSP_LOADER |
| 214 | select FW_LOADER | ||
| 214 | help | 215 | help |
| 215 | Say Y here to enable the DSP for Creative CA0132 for extended | 216 | Say Y here to enable the DSP for Creative CA0132 for extended |
| 216 | features like equalizer or echo cancellation. | 217 | features like equalizer or echo cancellation. |
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 48a9d004d6d9..853c6a69e29e 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c | |||
| @@ -638,7 +638,7 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, | |||
| 638 | /* don't add channel suffix for Headphone controls */ | 638 | /* don't add channel suffix for Headphone controls */ |
| 639 | int idx = get_hp_label_index(codec, nid, cfg->hp_pins, | 639 | int idx = get_hp_label_index(codec, nid, cfg->hp_pins, |
| 640 | cfg->hp_outs); | 640 | cfg->hp_outs); |
| 641 | if (idx >= 0) | 641 | if (idx >= 0 && indexp) |
| 642 | *indexp = idx; | 642 | *indexp = idx; |
| 643 | sfx = ""; | 643 | sfx = ""; |
| 644 | } | 644 | } |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 63c99090a4ec..98bce9830be0 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
| @@ -110,6 +110,7 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, | |||
| 110 | case SND_BELL: | 110 | case SND_BELL: |
| 111 | if (hz) | 111 | if (hz) |
| 112 | hz = 1000; | 112 | hz = 1000; |
| 113 | /* fallthru */ | ||
| 113 | case SND_TONE: | 114 | case SND_TONE: |
| 114 | if (beep->linear_tone) | 115 | if (beep->linear_tone) |
| 115 | beep->tone = beep_linear_tone(beep, hz); | 116 | beep->tone = beep_linear_tone(beep, hz); |
| @@ -151,10 +152,8 @@ static int snd_hda_do_attach(struct hda_beep *beep) | |||
| 151 | int err; | 152 | int err; |
| 152 | 153 | ||
| 153 | input_dev = input_allocate_device(); | 154 | input_dev = input_allocate_device(); |
| 154 | if (!input_dev) { | 155 | if (!input_dev) |
| 155 | printk(KERN_INFO "hda_beep: unable to allocate input device\n"); | ||
| 156 | return -ENOMEM; | 156 | return -ENOMEM; |
| 157 | } | ||
| 158 | 157 | ||
| 159 | /* setup digital beep device */ | 158 | /* setup digital beep device */ |
| 160 | input_dev->name = "HDA Digital PCBeep"; | 159 | input_dev->name = "HDA Digital PCBeep"; |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 748c6a941963..69178c4f4113 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
| @@ -565,7 +565,7 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid, | |||
| 565 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ | 565 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ |
| 566 | val = parm & mask; | 566 | val = parm & mask; |
| 567 | if (val == 0 && null_count++) { /* no second chance */ | 567 | if (val == 0 && null_count++) { /* no second chance */ |
| 568 | snd_printk(KERN_WARNING "hda_codec: " | 568 | snd_printdd("hda_codec: " |
| 569 | "invalid CONNECT_LIST verb %x[%i]:%x\n", | 569 | "invalid CONNECT_LIST verb %x[%i]:%x\n", |
| 570 | nid, i, parm); | 570 | nid, i, parm); |
| 571 | return 0; | 571 | return 0; |
| @@ -2579,9 +2579,6 @@ int snd_hda_codec_reset(struct hda_codec *codec) | |||
| 2579 | cancel_delayed_work_sync(&codec->jackpoll_work); | 2579 | cancel_delayed_work_sync(&codec->jackpoll_work); |
| 2580 | #ifdef CONFIG_PM | 2580 | #ifdef CONFIG_PM |
| 2581 | cancel_delayed_work_sync(&codec->power_work); | 2581 | cancel_delayed_work_sync(&codec->power_work); |
| 2582 | codec->power_on = 0; | ||
| 2583 | codec->power_transition = 0; | ||
| 2584 | codec->power_jiffies = jiffies; | ||
| 2585 | flush_workqueue(bus->workq); | 2582 | flush_workqueue(bus->workq); |
| 2586 | #endif | 2583 | #endif |
| 2587 | snd_hda_ctls_clear(codec); | 2584 | snd_hda_ctls_clear(codec); |
| @@ -2634,8 +2631,7 @@ static int map_slaves(struct hda_codec *codec, const char * const *slaves, | |||
| 2634 | items = codec->mixers.list; | 2631 | items = codec->mixers.list; |
| 2635 | for (i = 0; i < codec->mixers.used; i++) { | 2632 | for (i = 0; i < codec->mixers.used; i++) { |
| 2636 | struct snd_kcontrol *sctl = items[i].kctl; | 2633 | struct snd_kcontrol *sctl = items[i].kctl; |
| 2637 | if (!sctl || !sctl->id.name || | 2634 | if (!sctl || sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) |
| 2638 | sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) | ||
| 2639 | continue; | 2635 | continue; |
| 2640 | for (s = slaves; *s; s++) { | 2636 | for (s = slaves; *s; s++) { |
| 2641 | char tmpname[sizeof(sctl->id.name)]; | 2637 | char tmpname[sizeof(sctl->id.name)]; |
| @@ -2662,7 +2658,7 @@ static int check_slave_present(void *data, struct snd_kcontrol *sctl) | |||
| 2662 | } | 2658 | } |
| 2663 | 2659 | ||
| 2664 | /* guess the value corresponding to 0dB */ | 2660 | /* guess the value corresponding to 0dB */ |
| 2665 | static int get_kctl_0dB_offset(struct snd_kcontrol *kctl) | 2661 | static int get_kctl_0dB_offset(struct snd_kcontrol *kctl, int *step_to_check) |
| 2666 | { | 2662 | { |
| 2667 | int _tlv[4]; | 2663 | int _tlv[4]; |
| 2668 | const int *tlv = NULL; | 2664 | const int *tlv = NULL; |
| @@ -2677,8 +2673,19 @@ static int get_kctl_0dB_offset(struct snd_kcontrol *kctl) | |||
| 2677 | set_fs(fs); | 2673 | set_fs(fs); |
| 2678 | } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) | 2674 | } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) |
| 2679 | tlv = kctl->tlv.p; | 2675 | tlv = kctl->tlv.p; |
| 2680 | if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) | 2676 | if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) { |
| 2681 | val = -tlv[2] / tlv[3]; | 2677 | int step = tlv[3]; |
| 2678 | step &= ~TLV_DB_SCALE_MUTE; | ||
| 2679 | if (!step) | ||
| 2680 | return -1; | ||
| 2681 | if (*step_to_check && *step_to_check != step) { | ||
| 2682 | snd_printk(KERN_ERR "hda_codec: Mismatching dB step for vmaster slave (%d!=%d)\n", | ||
| 2683 | *step_to_check, step); | ||
| 2684 | return -1; | ||
| 2685 | } | ||
| 2686 | *step_to_check = step; | ||
| 2687 | val = -tlv[2] / step; | ||
| 2688 | } | ||
| 2682 | return val; | 2689 | return val; |
| 2683 | } | 2690 | } |
| 2684 | 2691 | ||
| @@ -2699,7 +2706,7 @@ static int put_kctl_with_value(struct snd_kcontrol *kctl, int val) | |||
| 2699 | /* initialize the slave volume with 0dB */ | 2706 | /* initialize the slave volume with 0dB */ |
| 2700 | static int init_slave_0dB(void *data, struct snd_kcontrol *slave) | 2707 | static int init_slave_0dB(void *data, struct snd_kcontrol *slave) |
| 2701 | { | 2708 | { |
| 2702 | int offset = get_kctl_0dB_offset(slave); | 2709 | int offset = get_kctl_0dB_offset(slave, data); |
| 2703 | if (offset > 0) | 2710 | if (offset > 0) |
| 2704 | put_kctl_with_value(slave, offset); | 2711 | put_kctl_with_value(slave, offset); |
| 2705 | return 0; | 2712 | return 0; |
| @@ -2760,9 +2767,11 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, | |||
| 2760 | 2767 | ||
| 2761 | /* init with master mute & zero volume */ | 2768 | /* init with master mute & zero volume */ |
| 2762 | put_kctl_with_value(kctl, 0); | 2769 | put_kctl_with_value(kctl, 0); |
| 2763 | if (init_slave_vol) | 2770 | if (init_slave_vol) { |
| 2771 | int step = 0; | ||
| 2764 | map_slaves(codec, slaves, suffix, | 2772 | map_slaves(codec, slaves, suffix, |
| 2765 | tlv ? init_slave_0dB : init_slave_unmute, kctl); | 2773 | tlv ? init_slave_0dB : init_slave_unmute, &step); |
| 2774 | } | ||
| 2766 | 2775 | ||
| 2767 | if (ctl_ret) | 2776 | if (ctl_ret) |
| 2768 | *ctl_ret = kctl; | 2777 | *ctl_ret = kctl; |
| @@ -3991,6 +4000,10 @@ static void hda_call_codec_resume(struct hda_codec *codec) | |||
| 3991 | * in the resume / power-save sequence | 4000 | * in the resume / power-save sequence |
| 3992 | */ | 4001 | */ |
| 3993 | hda_keep_power_on(codec); | 4002 | hda_keep_power_on(codec); |
| 4003 | if (codec->pm_down_notified) { | ||
| 4004 | codec->pm_down_notified = 0; | ||
| 4005 | hda_call_pm_notify(codec->bus, true); | ||
| 4006 | } | ||
| 3994 | hda_set_power_state(codec, AC_PWRST_D0); | 4007 | hda_set_power_state(codec, AC_PWRST_D0); |
| 3995 | restore_shutup_pins(codec); | 4008 | restore_shutup_pins(codec); |
| 3996 | hda_exec_init_verbs(codec); | 4009 | hda_exec_init_verbs(codec); |
| @@ -5395,11 +5408,6 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, | |||
| 5395 | snd_hda_codec_setup_stream(codec, | 5408 | snd_hda_codec_setup_stream(codec, |
| 5396 | mout->hp_out_nid[i], | 5409 | mout->hp_out_nid[i], |
| 5397 | stream_tag, 0, format); | 5410 | stream_tag, 0, format); |
| 5398 | for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) | ||
| 5399 | if (!mout->no_share_stream && mout->extra_out_nid[i]) | ||
| 5400 | snd_hda_codec_setup_stream(codec, | ||
| 5401 | mout->extra_out_nid[i], | ||
| 5402 | stream_tag, 0, format); | ||
| 5403 | 5411 | ||
| 5404 | /* surrounds */ | 5412 | /* surrounds */ |
| 5405 | for (i = 1; i < mout->num_dacs; i++) { | 5413 | for (i = 1; i < mout->num_dacs; i++) { |
| @@ -5410,6 +5418,20 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, | |||
| 5410 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, | 5418 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, |
| 5411 | 0, format); | 5419 | 0, format); |
| 5412 | } | 5420 | } |
| 5421 | |||
| 5422 | /* extra surrounds */ | ||
| 5423 | for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) { | ||
| 5424 | int ch = 0; | ||
| 5425 | if (!mout->extra_out_nid[i]) | ||
| 5426 | break; | ||
| 5427 | if (chs >= (i + 1) * 2) | ||
| 5428 | ch = i * 2; | ||
| 5429 | else if (!mout->no_share_stream) | ||
| 5430 | break; | ||
| 5431 | snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i], | ||
| 5432 | stream_tag, ch, format); | ||
| 5433 | } | ||
| 5434 | |||
| 5413 | return 0; | 5435 | return 0; |
| 5414 | } | 5436 | } |
| 5415 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare); | 5437 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_prepare); |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 7aa9870040c1..77db69480c19 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
| @@ -698,6 +698,7 @@ struct hda_bus { | |||
| 698 | unsigned int in_reset:1; /* during reset operation */ | 698 | unsigned int in_reset:1; /* during reset operation */ |
| 699 | unsigned int power_keep_link_on:1; /* don't power off HDA link */ | 699 | unsigned int power_keep_link_on:1; /* don't power off HDA link */ |
| 700 | unsigned int no_response_fallback:1; /* don't fallback at RIRB error */ | 700 | unsigned int no_response_fallback:1; /* don't fallback at RIRB error */ |
| 701 | unsigned int avoid_link_reset:1; /* don't reset link at runtime PM */ | ||
| 701 | 702 | ||
| 702 | int primary_dig_out_type; /* primary digital out PCM type */ | 703 | int primary_dig_out_type; /* primary digital out PCM type */ |
| 703 | }; | 704 | }; |
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index d0d7ac1e99d2..79ca80f6c77a 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | * Generic routines and proc interface for ELD(EDID Like Data) information | 2 | * Generic routines and proc interface for ELD(EDID Like Data) information |
| 3 | * | 3 | * |
| 4 | * Copyright(c) 2008 Intel Corporation. | 4 | * Copyright(c) 2008 Intel Corporation. |
| 5 | * Copyright (c) 2013 Anssi Hannula <anssi.hannula@iki.fi> | ||
| 5 | * | 6 | * |
| 6 | * Authors: | 7 | * Authors: |
| 7 | * Wu Fengguang <wfg@linux.intel.com> | 8 | * Wu Fengguang <wfg@linux.intel.com> |
| @@ -478,10 +479,9 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a, | |||
| 478 | snd_iprintf(buffer, "sad%d_profile\t\t%d\n", i, a->profile); | 479 | snd_iprintf(buffer, "sad%d_profile\t\t%d\n", i, a->profile); |
| 479 | } | 480 | } |
| 480 | 481 | ||
| 481 | static void hdmi_print_eld_info(struct snd_info_entry *entry, | 482 | void snd_hdmi_print_eld_info(struct hdmi_eld *eld, |
| 482 | struct snd_info_buffer *buffer) | 483 | struct snd_info_buffer *buffer) |
| 483 | { | 484 | { |
| 484 | struct hdmi_eld *eld = entry->private_data; | ||
| 485 | struct parsed_hdmi_eld *e = &eld->info; | 485 | struct parsed_hdmi_eld *e = &eld->info; |
| 486 | char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; | 486 | char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; |
| 487 | int i; | 487 | int i; |
| @@ -500,13 +500,10 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry, | |||
| 500 | [4 ... 7] = "reserved" | 500 | [4 ... 7] = "reserved" |
| 501 | }; | 501 | }; |
| 502 | 502 | ||
| 503 | mutex_lock(&eld->lock); | ||
| 504 | snd_iprintf(buffer, "monitor_present\t\t%d\n", eld->monitor_present); | 503 | snd_iprintf(buffer, "monitor_present\t\t%d\n", eld->monitor_present); |
| 505 | snd_iprintf(buffer, "eld_valid\t\t%d\n", eld->eld_valid); | 504 | snd_iprintf(buffer, "eld_valid\t\t%d\n", eld->eld_valid); |
| 506 | if (!eld->eld_valid) { | 505 | if (!eld->eld_valid) |
| 507 | mutex_unlock(&eld->lock); | ||
| 508 | return; | 506 | return; |
| 509 | } | ||
| 510 | snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name); | 507 | snd_iprintf(buffer, "monitor_name\t\t%s\n", e->monitor_name); |
| 511 | snd_iprintf(buffer, "connection_type\t\t%s\n", | 508 | snd_iprintf(buffer, "connection_type\t\t%s\n", |
| 512 | eld_connection_type_names[e->conn_type]); | 509 | eld_connection_type_names[e->conn_type]); |
| @@ -528,13 +525,11 @@ static void hdmi_print_eld_info(struct snd_info_entry *entry, | |||
| 528 | 525 | ||
| 529 | for (i = 0; i < e->sad_count; i++) | 526 | for (i = 0; i < e->sad_count; i++) |
| 530 | hdmi_print_sad_info(i, e->sad + i, buffer); | 527 | hdmi_print_sad_info(i, e->sad + i, buffer); |
| 531 | mutex_unlock(&eld->lock); | ||
| 532 | } | 528 | } |
| 533 | 529 | ||
| 534 | static void hdmi_write_eld_info(struct snd_info_entry *entry, | 530 | void snd_hdmi_write_eld_info(struct hdmi_eld *eld, |
| 535 | struct snd_info_buffer *buffer) | 531 | struct snd_info_buffer *buffer) |
| 536 | { | 532 | { |
| 537 | struct hdmi_eld *eld = entry->private_data; | ||
| 538 | struct parsed_hdmi_eld *e = &eld->info; | 533 | struct parsed_hdmi_eld *e = &eld->info; |
| 539 | char line[64]; | 534 | char line[64]; |
| 540 | char name[64]; | 535 | char name[64]; |
| @@ -542,7 +537,6 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, | |||
| 542 | long long val; | 537 | long long val; |
| 543 | unsigned int n; | 538 | unsigned int n; |
| 544 | 539 | ||
| 545 | mutex_lock(&eld->lock); | ||
| 546 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 540 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
| 547 | if (sscanf(line, "%s %llx", name, &val) != 2) | 541 | if (sscanf(line, "%s %llx", name, &val) != 2) |
| 548 | continue; | 542 | continue; |
| @@ -594,38 +588,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, | |||
| 594 | e->sad_count = n + 1; | 588 | e->sad_count = n + 1; |
| 595 | } | 589 | } |
| 596 | } | 590 | } |
| 597 | mutex_unlock(&eld->lock); | ||
| 598 | } | ||
| 599 | |||
| 600 | |||
| 601 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, | ||
| 602 | int index) | ||
| 603 | { | ||
| 604 | char name[32]; | ||
| 605 | struct snd_info_entry *entry; | ||
| 606 | int err; | ||
| 607 | |||
| 608 | snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); | ||
| 609 | err = snd_card_proc_new(codec->bus->card, name, &entry); | ||
| 610 | if (err < 0) | ||
| 611 | return err; | ||
| 612 | |||
| 613 | snd_info_set_text_ops(entry, eld, hdmi_print_eld_info); | ||
| 614 | entry->c.text.write = hdmi_write_eld_info; | ||
| 615 | entry->mode |= S_IWUSR; | ||
| 616 | eld->proc_entry = entry; | ||
| 617 | |||
| 618 | return 0; | ||
| 619 | } | ||
| 620 | |||
| 621 | void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) | ||
| 622 | { | ||
| 623 | if (!codec->bus->shutdown && eld->proc_entry) { | ||
| 624 | snd_device_free(codec->bus->card, eld->proc_entry); | ||
| 625 | eld->proc_entry = NULL; | ||
| 626 | } | ||
| 627 | } | 591 | } |
| 628 | |||
| 629 | #endif /* CONFIG_PROC_FS */ | 592 | #endif /* CONFIG_PROC_FS */ |
| 630 | 593 | ||
| 631 | /* update PCM info based on ELD */ | 594 | /* update PCM info based on ELD */ |
| @@ -671,3 +634,174 @@ void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e, | |||
| 671 | hinfo->maxbps = min(hinfo->maxbps, maxbps); | 634 | hinfo->maxbps = min(hinfo->maxbps, maxbps); |
| 672 | hinfo->channels_max = min(hinfo->channels_max, channels_max); | 635 | hinfo->channels_max = min(hinfo->channels_max, channels_max); |
| 673 | } | 636 | } |
| 637 | |||
| 638 | |||
| 639 | /* ATI/AMD specific stuff (ELD emulation) */ | ||
| 640 | |||
| 641 | #define ATI_VERB_SET_AUDIO_DESCRIPTOR 0x776 | ||
| 642 | #define ATI_VERB_SET_SINK_INFO_INDEX 0x780 | ||
| 643 | #define ATI_VERB_GET_SPEAKER_ALLOCATION 0xf70 | ||
| 644 | #define ATI_VERB_GET_AUDIO_DESCRIPTOR 0xf76 | ||
| 645 | #define ATI_VERB_GET_AUDIO_VIDEO_DELAY 0xf7b | ||
| 646 | #define ATI_VERB_GET_SINK_INFO_INDEX 0xf80 | ||
| 647 | #define ATI_VERB_GET_SINK_INFO_DATA 0xf81 | ||
| 648 | |||
| 649 | #define ATI_SPKALLOC_SPKALLOC 0x007f | ||
| 650 | #define ATI_SPKALLOC_TYPE_HDMI 0x0100 | ||
| 651 | #define ATI_SPKALLOC_TYPE_DISPLAYPORT 0x0200 | ||
| 652 | |||
| 653 | /* first three bytes are just standard SAD */ | ||
| 654 | #define ATI_AUDIODESC_CHANNELS 0x00000007 | ||
| 655 | #define ATI_AUDIODESC_RATES 0x0000ff00 | ||
| 656 | #define ATI_AUDIODESC_LPCM_STEREO_RATES 0xff000000 | ||
| 657 | |||
| 658 | /* in standard HDMI VSDB format */ | ||
| 659 | #define ATI_DELAY_VIDEO_LATENCY 0x000000ff | ||
| 660 | #define ATI_DELAY_AUDIO_LATENCY 0x0000ff00 | ||
| 661 | |||
| 662 | enum ati_sink_info_idx { | ||
| 663 | ATI_INFO_IDX_MANUFACTURER_ID = 0, | ||
| 664 | ATI_INFO_IDX_PRODUCT_ID = 1, | ||
| 665 | ATI_INFO_IDX_SINK_DESC_LEN = 2, | ||
| 666 | ATI_INFO_IDX_PORT_ID_LOW = 3, | ||
| 667 | ATI_INFO_IDX_PORT_ID_HIGH = 4, | ||
| 668 | ATI_INFO_IDX_SINK_DESC_FIRST = 5, | ||
| 669 | ATI_INFO_IDX_SINK_DESC_LAST = 22, /* max len 18 bytes */ | ||
| 670 | }; | ||
| 671 | |||
| 672 | int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, | ||
| 673 | unsigned char *buf, int *eld_size, bool rev3_or_later) | ||
| 674 | { | ||
| 675 | int spkalloc, ati_sad, aud_synch; | ||
| 676 | int sink_desc_len = 0; | ||
| 677 | int pos, i; | ||
| 678 | |||
| 679 | /* ATI/AMD does not have ELD, emulate it */ | ||
| 680 | |||
| 681 | spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0); | ||
| 682 | |||
| 683 | if (spkalloc <= 0) { | ||
| 684 | snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n"); | ||
| 685 | return -EINVAL; | ||
| 686 | } | ||
| 687 | |||
| 688 | memset(buf, 0, ELD_FIXED_BYTES + ELD_MAX_MNL + ELD_MAX_SAD * 3); | ||
| 689 | |||
| 690 | /* version */ | ||
| 691 | buf[0] = ELD_VER_CEA_861D << 3; | ||
| 692 | |||
| 693 | /* speaker allocation from EDID */ | ||
| 694 | buf[7] = spkalloc & ATI_SPKALLOC_SPKALLOC; | ||
| 695 | |||
| 696 | /* is DisplayPort? */ | ||
| 697 | if (spkalloc & ATI_SPKALLOC_TYPE_DISPLAYPORT) | ||
| 698 | buf[5] |= 0x04; | ||
| 699 | |||
| 700 | pos = ELD_FIXED_BYTES; | ||
| 701 | |||
| 702 | if (rev3_or_later) { | ||
| 703 | int sink_info; | ||
| 704 | |||
| 705 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_LOW); | ||
| 706 | sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); | ||
| 707 | put_unaligned_le32(sink_info, buf + 8); | ||
| 708 | |||
| 709 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PORT_ID_HIGH); | ||
| 710 | sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); | ||
| 711 | put_unaligned_le32(sink_info, buf + 12); | ||
| 712 | |||
| 713 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_MANUFACTURER_ID); | ||
| 714 | sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); | ||
| 715 | put_unaligned_le16(sink_info, buf + 16); | ||
| 716 | |||
| 717 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_PRODUCT_ID); | ||
| 718 | sink_info = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); | ||
| 719 | put_unaligned_le16(sink_info, buf + 18); | ||
| 720 | |||
| 721 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_LEN); | ||
| 722 | sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); | ||
| 723 | |||
| 724 | if (sink_desc_len > ELD_MAX_MNL) { | ||
| 725 | snd_printd(KERN_INFO "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n", | ||
| 726 | sink_desc_len); | ||
| 727 | sink_desc_len = ELD_MAX_MNL; | ||
| 728 | } | ||
| 729 | |||
| 730 | buf[4] |= sink_desc_len; | ||
| 731 | |||
| 732 | for (i = 0; i < sink_desc_len; i++) { | ||
| 733 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_SINK_INFO_INDEX, ATI_INFO_IDX_SINK_DESC_FIRST + i); | ||
| 734 | buf[pos++] = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); | ||
| 735 | } | ||
| 736 | } | ||
| 737 | |||
| 738 | for (i = AUDIO_CODING_TYPE_LPCM; i <= AUDIO_CODING_TYPE_WMAPRO; i++) { | ||
| 739 | if (i == AUDIO_CODING_TYPE_SACD || i == AUDIO_CODING_TYPE_DST) | ||
| 740 | continue; /* not handled by ATI/AMD */ | ||
| 741 | |||
| 742 | snd_hda_codec_write(codec, nid, 0, ATI_VERB_SET_AUDIO_DESCRIPTOR, i << 3); | ||
| 743 | ati_sad = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_DESCRIPTOR, 0); | ||
| 744 | |||
| 745 | if (ati_sad <= 0) | ||
| 746 | continue; | ||
| 747 | |||
| 748 | if (ati_sad & ATI_AUDIODESC_RATES) { | ||
| 749 | /* format is supported, copy SAD as-is */ | ||
| 750 | buf[pos++] = (ati_sad & 0x0000ff) >> 0; | ||
| 751 | buf[pos++] = (ati_sad & 0x00ff00) >> 8; | ||
| 752 | buf[pos++] = (ati_sad & 0xff0000) >> 16; | ||
| 753 | } | ||
| 754 | |||
| 755 | if (i == AUDIO_CODING_TYPE_LPCM | ||
| 756 | && (ati_sad & ATI_AUDIODESC_LPCM_STEREO_RATES) | ||
| 757 | && (ati_sad & ATI_AUDIODESC_LPCM_STEREO_RATES) >> 16 != (ati_sad & ATI_AUDIODESC_RATES)) { | ||
| 758 | /* for PCM there is a separate stereo rate mask */ | ||
| 759 | buf[pos++] = ((ati_sad & 0x000000ff) & ~ATI_AUDIODESC_CHANNELS) | 0x1; | ||
| 760 | /* rates from the extra byte */ | ||
| 761 | buf[pos++] = (ati_sad & 0xff000000) >> 24; | ||
| 762 | buf[pos++] = (ati_sad & 0x00ff0000) >> 16; | ||
| 763 | } | ||
| 764 | } | ||
| 765 | |||
| 766 | if (pos == ELD_FIXED_BYTES + sink_desc_len) { | ||
| 767 | snd_printd(KERN_INFO "HDMI ATI/AMD: no audio descriptors for ELD\n"); | ||
| 768 | return -EINVAL; | ||
| 769 | } | ||
| 770 | |||
| 771 | /* | ||
| 772 | * HDMI VSDB latency format: | ||
| 773 | * separately for both audio and video: | ||
| 774 | * 0 field not valid or unknown latency | ||
| 775 | * [1..251] msecs = (x-1)*2 (max 500ms with x = 251 = 0xfb) | ||
| 776 | * 255 audio/video not supported | ||
| 777 | * | ||
| 778 | * HDA latency format: | ||
| 779 | * single value indicating video latency relative to audio: | ||
| 780 | * 0 unknown or 0ms | ||
| 781 | * [1..250] msecs = x*2 (max 500ms with x = 250 = 0xfa) | ||
| 782 | * [251..255] reserved | ||
| 783 | */ | ||
| 784 | aud_synch = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_AUDIO_VIDEO_DELAY, 0); | ||
| 785 | if ((aud_synch & ATI_DELAY_VIDEO_LATENCY) && (aud_synch & ATI_DELAY_AUDIO_LATENCY)) { | ||
| 786 | int video_latency_hdmi = (aud_synch & ATI_DELAY_VIDEO_LATENCY); | ||
| 787 | int audio_latency_hdmi = (aud_synch & ATI_DELAY_AUDIO_LATENCY) >> 8; | ||
| 788 | |||
| 789 | if (video_latency_hdmi <= 0xfb && audio_latency_hdmi <= 0xfb && | ||
| 790 | video_latency_hdmi > audio_latency_hdmi) | ||
| 791 | buf[6] = video_latency_hdmi - audio_latency_hdmi; | ||
| 792 | /* else unknown/invalid or 0ms or video ahead of audio, so use zero */ | ||
| 793 | } | ||
| 794 | |||
| 795 | /* SAD count */ | ||
| 796 | buf[5] |= ((pos - ELD_FIXED_BYTES - sink_desc_len) / 3) << 4; | ||
| 797 | |||
| 798 | /* Baseline ELD block length is 4-byte aligned */ | ||
| 799 | pos = round_up(pos, 4); | ||
| 800 | |||
| 801 | /* Baseline ELD length (4-byte header is not counted in) */ | ||
| 802 | buf[2] = (pos - 4) / 4; | ||
| 803 | |||
| 804 | *eld_size = pos; | ||
| 805 | |||
| 806 | return 0; | ||
| 807 | } | ||
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index b7c89dff7066..3067ed4fe3b2 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
| @@ -549,11 +549,15 @@ static hda_nid_t look_for_out_mute_nid(struct hda_codec *codec, | |||
| 549 | static hda_nid_t look_for_out_vol_nid(struct hda_codec *codec, | 549 | static hda_nid_t look_for_out_vol_nid(struct hda_codec *codec, |
| 550 | struct nid_path *path) | 550 | struct nid_path *path) |
| 551 | { | 551 | { |
| 552 | struct hda_gen_spec *spec = codec->spec; | ||
| 552 | int i; | 553 | int i; |
| 553 | 554 | ||
| 554 | for (i = path->depth - 1; i >= 0; i--) { | 555 | for (i = path->depth - 1; i >= 0; i--) { |
| 555 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) | 556 | hda_nid_t nid = path->path[i]; |
| 556 | return path->path[i]; | 557 | if ((spec->out_vol_mask >> nid) & 1) |
| 558 | continue; | ||
| 559 | if (nid_has_volume(codec, nid, HDA_OUTPUT)) | ||
| 560 | return nid; | ||
| 557 | } | 561 | } |
| 558 | return 0; | 562 | return 0; |
| 559 | } | 563 | } |
| @@ -792,10 +796,10 @@ static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable) | |||
| 792 | if (spec->own_eapd_ctl || | 796 | if (spec->own_eapd_ctl || |
| 793 | !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD)) | 797 | !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD)) |
| 794 | return; | 798 | return; |
| 795 | if (codec->inv_eapd) | ||
| 796 | enable = !enable; | ||
| 797 | if (spec->keep_eapd_on && !enable) | 799 | if (spec->keep_eapd_on && !enable) |
| 798 | return; | 800 | return; |
| 801 | if (codec->inv_eapd) | ||
| 802 | enable = !enable; | ||
| 799 | snd_hda_codec_update_cache(codec, pin, 0, | 803 | snd_hda_codec_update_cache(codec, pin, 0, |
| 800 | AC_VERB_SET_EAPD_BTLENABLE, | 804 | AC_VERB_SET_EAPD_BTLENABLE, |
| 801 | enable ? 0x02 : 0x00); | 805 | enable ? 0x02 : 0x00); |
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 48d44026705b..7e45cb44d151 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h | |||
| @@ -242,6 +242,9 @@ struct hda_gen_spec { | |||
| 242 | /* additional mute flags (only effective with auto_mute_via_amp=1) */ | 242 | /* additional mute flags (only effective with auto_mute_via_amp=1) */ |
| 243 | u64 mute_bits; | 243 | u64 mute_bits; |
| 244 | 244 | ||
| 245 | /* bitmask for skipping volume controls */ | ||
| 246 | u64 out_vol_mask; | ||
| 247 | |||
| 245 | /* badness tables for output path evaluations */ | 248 | /* badness tables for output path evaluations */ |
| 246 | const struct badness_table *main_out_badness; | 249 | const struct badness_table *main_out_badness; |
| 247 | const struct badness_table *extra_out_badness; | 250 | const struct badness_table *extra_out_badness; |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 6e61a019aa5e..7a09404579a7 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
| @@ -169,6 +169,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," | |||
| 169 | "{Intel, PPT}," | 169 | "{Intel, PPT}," |
| 170 | "{Intel, LPT}," | 170 | "{Intel, LPT}," |
| 171 | "{Intel, LPT_LP}," | 171 | "{Intel, LPT_LP}," |
| 172 | "{Intel, WPT_LP}," | ||
| 172 | "{Intel, HPT}," | 173 | "{Intel, HPT}," |
| 173 | "{Intel, PBG}," | 174 | "{Intel, PBG}," |
| 174 | "{Intel, SCH}," | 175 | "{Intel, SCH}," |
| @@ -568,6 +569,7 @@ enum { | |||
| 568 | AZX_DRIVER_ICH, | 569 | AZX_DRIVER_ICH, |
| 569 | AZX_DRIVER_PCH, | 570 | AZX_DRIVER_PCH, |
| 570 | AZX_DRIVER_SCH, | 571 | AZX_DRIVER_SCH, |
| 572 | AZX_DRIVER_HDMI, | ||
| 571 | AZX_DRIVER_ATI, | 573 | AZX_DRIVER_ATI, |
| 572 | AZX_DRIVER_ATIHDMI, | 574 | AZX_DRIVER_ATIHDMI, |
| 573 | AZX_DRIVER_ATIHDMI_NS, | 575 | AZX_DRIVER_ATIHDMI_NS, |
| @@ -612,6 +614,11 @@ enum { | |||
| 612 | #define AZX_DCAPS_INTEL_PCH \ | 614 | #define AZX_DCAPS_INTEL_PCH \ |
| 613 | (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME) | 615 | (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME) |
| 614 | 616 | ||
| 617 | #define AZX_DCAPS_INTEL_HASWELL \ | ||
| 618 | (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \ | ||
| 619 | AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME | \ | ||
| 620 | AZX_DCAPS_I915_POWERWELL) | ||
| 621 | |||
| 615 | /* quirks for ATI SB / AMD Hudson */ | 622 | /* quirks for ATI SB / AMD Hudson */ |
| 616 | #define AZX_DCAPS_PRESET_ATI_SB \ | 623 | #define AZX_DCAPS_PRESET_ATI_SB \ |
| 617 | (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \ | 624 | (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \ |
| @@ -642,6 +649,7 @@ static char *driver_short_names[] = { | |||
| 642 | [AZX_DRIVER_ICH] = "HDA Intel", | 649 | [AZX_DRIVER_ICH] = "HDA Intel", |
| 643 | [AZX_DRIVER_PCH] = "HDA Intel PCH", | 650 | [AZX_DRIVER_PCH] = "HDA Intel PCH", |
| 644 | [AZX_DRIVER_SCH] = "HDA Intel MID", | 651 | [AZX_DRIVER_SCH] = "HDA Intel MID", |
| 652 | [AZX_DRIVER_HDMI] = "HDA Intel HDMI", | ||
| 645 | [AZX_DRIVER_ATI] = "HDA ATI SB", | 653 | [AZX_DRIVER_ATI] = "HDA ATI SB", |
| 646 | [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", | 654 | [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", |
| 647 | [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI", | 655 | [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI", |
| @@ -906,12 +914,12 @@ static void azx_update_rirb(struct azx *chip) | |||
| 906 | chip->rirb.res[addr] = res; | 914 | chip->rirb.res[addr] = res; |
| 907 | smp_wmb(); | 915 | smp_wmb(); |
| 908 | chip->rirb.cmds[addr]--; | 916 | chip->rirb.cmds[addr]--; |
| 909 | } else | 917 | } else if (printk_ratelimit()) { |
| 910 | snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, " | 918 | snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, last cmd=%#08x\n", |
| 911 | "last cmd=%#08x\n", | ||
| 912 | pci_name(chip->pci), | 919 | pci_name(chip->pci), |
| 913 | res, res_ex, | 920 | res, res_ex, |
| 914 | chip->last_cmd[addr]); | 921 | chip->last_cmd[addr]); |
| 922 | } | ||
| 915 | } | 923 | } |
| 916 | } | 924 | } |
| 917 | 925 | ||
| @@ -2986,7 +2994,8 @@ static int azx_runtime_suspend(struct device *dev) | |||
| 2986 | STATESTS_INT_MASK); | 2994 | STATESTS_INT_MASK); |
| 2987 | 2995 | ||
| 2988 | azx_stop_chip(chip); | 2996 | azx_stop_chip(chip); |
| 2989 | azx_enter_link_reset(chip); | 2997 | if (!chip->bus->avoid_link_reset) |
| 2998 | azx_enter_link_reset(chip); | ||
| 2990 | azx_clear_irq_pending(chip); | 2999 | azx_clear_irq_pending(chip); |
| 2991 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) | 3000 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) |
| 2992 | hda_display_power(false); | 3001 | hda_display_power(false); |
| @@ -3985,16 +3994,16 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { | |||
| 3985 | /* Lynx Point-LP */ | 3994 | /* Lynx Point-LP */ |
| 3986 | { PCI_DEVICE(0x8086, 0x9c21), | 3995 | { PCI_DEVICE(0x8086, 0x9c21), |
| 3987 | .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, | 3996 | .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, |
| 3997 | /* Wildcat Point-LP */ | ||
| 3998 | { PCI_DEVICE(0x8086, 0x9ca0), | ||
| 3999 | .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, | ||
| 3988 | /* Haswell */ | 4000 | /* Haswell */ |
| 3989 | { PCI_DEVICE(0x8086, 0x0a0c), | 4001 | { PCI_DEVICE(0x8086, 0x0a0c), |
| 3990 | .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH | | 4002 | .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, |
| 3991 | AZX_DCAPS_I915_POWERWELL }, | ||
| 3992 | { PCI_DEVICE(0x8086, 0x0c0c), | 4003 | { PCI_DEVICE(0x8086, 0x0c0c), |
| 3993 | .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH | | 4004 | .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, |
| 3994 | AZX_DCAPS_I915_POWERWELL }, | ||
| 3995 | { PCI_DEVICE(0x8086, 0x0d0c), | 4005 | { PCI_DEVICE(0x8086, 0x0d0c), |
| 3996 | .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH | | 4006 | .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, |
| 3997 | AZX_DCAPS_I915_POWERWELL }, | ||
| 3998 | /* 5 Series/3400 */ | 4007 | /* 5 Series/3400 */ |
| 3999 | { PCI_DEVICE(0x8086, 0x3b56), | 4008 | { PCI_DEVICE(0x8086, 0x3b56), |
| 4000 | .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM }, | 4009 | .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM }, |
| @@ -4074,6 +4083,22 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { | |||
| 4074 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | 4083 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, |
| 4075 | { PCI_DEVICE(0x1002, 0xaa48), | 4084 | { PCI_DEVICE(0x1002, 0xaa48), |
| 4076 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | 4085 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, |
| 4086 | { PCI_DEVICE(0x1002, 0xaa50), | ||
| 4087 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4088 | { PCI_DEVICE(0x1002, 0xaa58), | ||
| 4089 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4090 | { PCI_DEVICE(0x1002, 0xaa60), | ||
| 4091 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4092 | { PCI_DEVICE(0x1002, 0xaa68), | ||
| 4093 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4094 | { PCI_DEVICE(0x1002, 0xaa80), | ||
| 4095 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4096 | { PCI_DEVICE(0x1002, 0xaa88), | ||
| 4097 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4098 | { PCI_DEVICE(0x1002, 0xaa90), | ||
| 4099 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4100 | { PCI_DEVICE(0x1002, 0xaa98), | ||
| 4101 | .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI }, | ||
| 4077 | { PCI_DEVICE(0x1002, 0x9902), | 4102 | { PCI_DEVICE(0x1002, 0x9902), |
| 4078 | .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, | 4103 | .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI }, |
| 4079 | { PCI_DEVICE(0x1002, 0xaaa0), | 4104 | { PCI_DEVICE(0x1002, 0xaaa0), |
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 05b3e3e9108f..afe594411a56 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
| @@ -286,7 +286,7 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) | |||
| 286 | jack = codec->jacktbl.list; | 286 | jack = codec->jacktbl.list; |
| 287 | for (i = 0; i < codec->jacktbl.used; i++, jack++) | 287 | for (i = 0; i < codec->jacktbl.used; i++, jack++) |
| 288 | if (jack->nid) { | 288 | if (jack->nid) { |
| 289 | if (!jack->kctl) | 289 | if (!jack->kctl || jack->block_report) |
| 290 | continue; | 290 | continue; |
| 291 | state = get_jack_plug_state(jack->pin_sense); | 291 | state = get_jack_plug_state(jack->pin_sense); |
| 292 | snd_kctl_jack_report(codec->bus->card, jack->kctl, state); | 292 | snd_kctl_jack_report(codec->bus->card, jack->kctl, state); |
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index 379420c44eef..46e1ea83ce3c 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h | |||
| @@ -28,6 +28,7 @@ struct hda_jack_tbl { | |||
| 28 | unsigned int jack_detect:1; /* capable of jack-detection? */ | 28 | unsigned int jack_detect:1; /* capable of jack-detection? */ |
| 29 | unsigned int jack_dirty:1; /* needs to update? */ | 29 | unsigned int jack_dirty:1; /* needs to update? */ |
| 30 | unsigned int phantom_jack:1; /* a fixed, always present port? */ | 30 | unsigned int phantom_jack:1; /* a fixed, always present port? */ |
| 31 | unsigned int block_report:1; /* in a transitional state - do not report to userspace */ | ||
| 31 | hda_nid_t gating_jack; /* valid when gating jack plugged */ | 32 | hda_nid_t gating_jack; /* valid when gating jack plugged */ |
| 32 | hda_nid_t gated_jack; /* gated is dependent on this jack */ | 33 | hda_nid_t gated_jack; /* gated is dependent on this jack */ |
| 33 | struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */ | 34 | struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */ |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 2e7493ef8ee0..d398b648bb5d 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
| @@ -428,6 +428,7 @@ enum { | |||
| 428 | HDA_FIXUP_ACT_PROBE, | 428 | HDA_FIXUP_ACT_PROBE, |
| 429 | HDA_FIXUP_ACT_INIT, | 429 | HDA_FIXUP_ACT_INIT, |
| 430 | HDA_FIXUP_ACT_BUILD, | 430 | HDA_FIXUP_ACT_BUILD, |
| 431 | HDA_FIXUP_ACT_FREE, | ||
| 431 | }; | 432 | }; |
| 432 | 433 | ||
| 433 | int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list); | 434 | int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list); |
| @@ -751,10 +752,6 @@ struct hdmi_eld { | |||
| 751 | int eld_size; | 752 | int eld_size; |
| 752 | char eld_buffer[ELD_MAX_SIZE]; | 753 | char eld_buffer[ELD_MAX_SIZE]; |
| 753 | struct parsed_hdmi_eld info; | 754 | struct parsed_hdmi_eld info; |
| 754 | struct mutex lock; | ||
| 755 | #ifdef CONFIG_PROC_FS | ||
| 756 | struct snd_info_entry *proc_entry; | ||
| 757 | #endif | ||
| 758 | }; | 755 | }; |
| 759 | 756 | ||
| 760 | int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); | 757 | int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); |
| @@ -766,21 +763,15 @@ void snd_hdmi_show_eld(struct parsed_hdmi_eld *e); | |||
| 766 | void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e, | 763 | void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e, |
| 767 | struct hda_pcm_stream *hinfo); | 764 | struct hda_pcm_stream *hinfo); |
| 768 | 765 | ||
| 766 | int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid, | ||
| 767 | unsigned char *buf, int *eld_size, | ||
| 768 | bool rev3_or_later); | ||
| 769 | |||
| 769 | #ifdef CONFIG_PROC_FS | 770 | #ifdef CONFIG_PROC_FS |
| 770 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, | 771 | void snd_hdmi_print_eld_info(struct hdmi_eld *eld, |
| 771 | int index); | 772 | struct snd_info_buffer *buffer); |
| 772 | void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld); | 773 | void snd_hdmi_write_eld_info(struct hdmi_eld *eld, |
| 773 | #else | 774 | struct snd_info_buffer *buffer); |
| 774 | static inline int snd_hda_eld_proc_new(struct hda_codec *codec, | ||
| 775 | struct hdmi_eld *eld, | ||
| 776 | int index) | ||
| 777 | { | ||
| 778 | return 0; | ||
| 779 | } | ||
| 780 | static inline void snd_hda_eld_proc_free(struct hda_codec *codec, | ||
| 781 | struct hdmi_eld *eld) | ||
| 782 | { | ||
| 783 | } | ||
| 784 | #endif | 775 | #endif |
| 785 | 776 | ||
| 786 | #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 | 777 | #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 2aa2f579b4d6..1a83559f4cbd 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
| @@ -139,6 +139,18 @@ static int ad198x_suspend(struct hda_codec *codec) | |||
| 139 | } | 139 | } |
| 140 | #endif | 140 | #endif |
| 141 | 141 | ||
| 142 | /* follow EAPD via vmaster hook */ | ||
| 143 | static void ad_vmaster_eapd_hook(void *private_data, int enabled) | ||
| 144 | { | ||
| 145 | struct hda_codec *codec = private_data; | ||
| 146 | struct ad198x_spec *spec = codec->spec; | ||
| 147 | |||
| 148 | if (!spec->eapd_nid) | ||
| 149 | return; | ||
| 150 | snd_hda_codec_update_cache(codec, spec->eapd_nid, 0, | ||
| 151 | AC_VERB_SET_EAPD_BTLENABLE, | ||
| 152 | enabled ? 0x02 : 0x00); | ||
| 153 | } | ||
| 142 | 154 | ||
| 143 | /* | 155 | /* |
| 144 | * Automatic parse of I/O pins from the BIOS configuration | 156 | * Automatic parse of I/O pins from the BIOS configuration |
| @@ -219,8 +231,14 @@ static int alloc_ad_spec(struct hda_codec *codec) | |||
| 219 | static void ad_fixup_inv_jack_detect(struct hda_codec *codec, | 231 | static void ad_fixup_inv_jack_detect(struct hda_codec *codec, |
| 220 | const struct hda_fixup *fix, int action) | 232 | const struct hda_fixup *fix, int action) |
| 221 | { | 233 | { |
| 222 | if (action == HDA_FIXUP_ACT_PRE_PROBE) | 234 | struct ad198x_spec *spec = codec->spec; |
| 235 | |||
| 236 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
| 223 | codec->inv_jack_detect = 1; | 237 | codec->inv_jack_detect = 1; |
| 238 | spec->gen.keep_eapd_on = 1; | ||
| 239 | spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; | ||
| 240 | spec->eapd_nid = 0x1b; | ||
| 241 | } | ||
| 224 | } | 242 | } |
| 225 | 243 | ||
| 226 | enum { | 244 | enum { |
| @@ -465,19 +483,6 @@ static int patch_ad1983(struct hda_codec *codec) | |||
| 465 | * AD1981 HD specific | 483 | * AD1981 HD specific |
| 466 | */ | 484 | */ |
| 467 | 485 | ||
| 468 | /* follow EAPD via vmaster hook */ | ||
| 469 | static void ad_vmaster_eapd_hook(void *private_data, int enabled) | ||
| 470 | { | ||
| 471 | struct hda_codec *codec = private_data; | ||
| 472 | struct ad198x_spec *spec = codec->spec; | ||
| 473 | |||
| 474 | if (!spec->eapd_nid) | ||
| 475 | return; | ||
| 476 | snd_hda_codec_update_cache(codec, spec->eapd_nid, 0, | ||
| 477 | AC_VERB_SET_EAPD_BTLENABLE, | ||
| 478 | enabled ? 0x02 : 0x00); | ||
| 479 | } | ||
| 480 | |||
| 481 | static void ad1981_fixup_hp_eapd(struct hda_codec *codec, | 486 | static void ad1981_fixup_hp_eapd(struct hda_codec *codec, |
| 482 | const struct hda_fixup *fix, int action) | 487 | const struct hda_fixup *fix, int action) |
| 483 | { | 488 | { |
| @@ -973,8 +978,11 @@ static void ad1884_fixup_thinkpad(struct hda_codec *codec, | |||
| 973 | { | 978 | { |
| 974 | struct ad198x_spec *spec = codec->spec; | 979 | struct ad198x_spec *spec = codec->spec; |
| 975 | 980 | ||
| 976 | if (action == HDA_FIXUP_ACT_PRE_PROBE) | 981 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 977 | spec->gen.keep_eapd_on = 1; | 982 | spec->gen.keep_eapd_on = 1; |
| 983 | spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook; | ||
| 984 | spec->eapd_nid = 0x12; | ||
| 985 | } | ||
| 978 | } | 986 | } |
| 979 | 987 | ||
| 980 | /* set magic COEFs for dmic */ | 988 | /* set magic COEFs for dmic */ |
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 6e9876f27d95..54d14793725a 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c | |||
| @@ -759,7 +759,7 @@ struct ca0132_spec { | |||
| 759 | /* | 759 | /* |
| 760 | * CA0132 codec access | 760 | * CA0132 codec access |
| 761 | */ | 761 | */ |
| 762 | unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, | 762 | static unsigned int codec_send_command(struct hda_codec *codec, hda_nid_t nid, |
| 763 | unsigned int verb, unsigned int parm, unsigned int *res) | 763 | unsigned int verb, unsigned int parm, unsigned int *res) |
| 764 | { | 764 | { |
| 765 | unsigned int response; | 765 | unsigned int response; |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 18d972501585..fc492ac24caa 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
| @@ -47,6 +47,10 @@ struct cs_spec { | |||
| 47 | unsigned int spdif_present:1; | 47 | unsigned int spdif_present:1; |
| 48 | unsigned int sense_b:1; | 48 | unsigned int sense_b:1; |
| 49 | hda_nid_t vendor_nid; | 49 | hda_nid_t vendor_nid; |
| 50 | |||
| 51 | /* for MBP SPDIF control */ | ||
| 52 | int (*spdif_sw_put)(struct snd_kcontrol *kcontrol, | ||
| 53 | struct snd_ctl_elem_value *ucontrol); | ||
| 50 | }; | 54 | }; |
| 51 | 55 | ||
| 52 | /* available models with CS420x */ | 56 | /* available models with CS420x */ |
| @@ -331,10 +335,21 @@ static int cs_init(struct hda_codec *codec) | |||
| 331 | return 0; | 335 | return 0; |
| 332 | } | 336 | } |
| 333 | 337 | ||
| 338 | static int cs_build_controls(struct hda_codec *codec) | ||
| 339 | { | ||
| 340 | int err; | ||
| 341 | |||
| 342 | err = snd_hda_gen_build_controls(codec); | ||
| 343 | if (err < 0) | ||
| 344 | return err; | ||
| 345 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); | ||
| 346 | return 0; | ||
| 347 | } | ||
| 348 | |||
| 334 | #define cs_free snd_hda_gen_free | 349 | #define cs_free snd_hda_gen_free |
| 335 | 350 | ||
| 336 | static const struct hda_codec_ops cs_patch_ops = { | 351 | static const struct hda_codec_ops cs_patch_ops = { |
| 337 | .build_controls = snd_hda_gen_build_controls, | 352 | .build_controls = cs_build_controls, |
| 338 | .build_pcms = snd_hda_gen_build_pcms, | 353 | .build_pcms = snd_hda_gen_build_pcms, |
| 339 | .init = cs_init, | 354 | .init = cs_init, |
| 340 | .free = cs_free, | 355 | .free = cs_free, |
| @@ -597,18 +612,27 @@ static int patch_cs420x(struct hda_codec *codec) | |||
| 597 | * Its layout is no longer compatible with CS4206/CS4207 | 612 | * Its layout is no longer compatible with CS4206/CS4207 |
| 598 | */ | 613 | */ |
| 599 | enum { | 614 | enum { |
| 615 | CS4208_MAC_AUTO, | ||
| 600 | CS4208_MBA6, | 616 | CS4208_MBA6, |
| 617 | CS4208_MBP11, | ||
| 601 | CS4208_GPIO0, | 618 | CS4208_GPIO0, |
| 602 | }; | 619 | }; |
| 603 | 620 | ||
| 604 | static const struct hda_model_fixup cs4208_models[] = { | 621 | static const struct hda_model_fixup cs4208_models[] = { |
| 605 | { .id = CS4208_GPIO0, .name = "gpio0" }, | 622 | { .id = CS4208_GPIO0, .name = "gpio0" }, |
| 606 | { .id = CS4208_MBA6, .name = "mba6" }, | 623 | { .id = CS4208_MBA6, .name = "mba6" }, |
| 624 | { .id = CS4208_MBP11, .name = "mbp11" }, | ||
| 607 | {} | 625 | {} |
| 608 | }; | 626 | }; |
| 609 | 627 | ||
| 610 | static const struct snd_pci_quirk cs4208_fixup_tbl[] = { | 628 | static const struct snd_pci_quirk cs4208_fixup_tbl[] = { |
| 611 | /* codec SSID */ | 629 | SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS4208_MAC_AUTO), |
| 630 | {} /* terminator */ | ||
| 631 | }; | ||
| 632 | |||
| 633 | /* codec SSID matching */ | ||
| 634 | static const struct snd_pci_quirk cs4208_mac_fixup_tbl[] = { | ||
| 635 | SND_PCI_QUIRK(0x106b, 0x5e00, "MacBookPro 11,2", CS4208_MBP11), | ||
| 612 | SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6), | 636 | SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6), |
| 613 | SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6), | 637 | SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6), |
| 614 | {} /* terminator */ | 638 | {} /* terminator */ |
| @@ -626,6 +650,50 @@ static void cs4208_fixup_gpio0(struct hda_codec *codec, | |||
| 626 | } | 650 | } |
| 627 | } | 651 | } |
| 628 | 652 | ||
| 653 | static const struct hda_fixup cs4208_fixups[]; | ||
| 654 | |||
| 655 | /* remap the fixup from codec SSID and apply it */ | ||
| 656 | static void cs4208_fixup_mac(struct hda_codec *codec, | ||
| 657 | const struct hda_fixup *fix, int action) | ||
| 658 | { | ||
| 659 | if (action != HDA_FIXUP_ACT_PRE_PROBE) | ||
| 660 | return; | ||
| 661 | snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups); | ||
| 662 | if (codec->fixup_id < 0 || codec->fixup_id == CS4208_MAC_AUTO) | ||
| 663 | codec->fixup_id = CS4208_GPIO0; /* default fixup */ | ||
| 664 | snd_hda_apply_fixup(codec, action); | ||
| 665 | } | ||
| 666 | |||
| 667 | static int cs4208_spdif_sw_put(struct snd_kcontrol *kcontrol, | ||
| 668 | struct snd_ctl_elem_value *ucontrol) | ||
| 669 | { | ||
| 670 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
| 671 | struct cs_spec *spec = codec->spec; | ||
| 672 | hda_nid_t pin = spec->gen.autocfg.dig_out_pins[0]; | ||
| 673 | int pinctl = ucontrol->value.integer.value[0] ? PIN_OUT : 0; | ||
| 674 | |||
| 675 | snd_hda_set_pin_ctl_cache(codec, pin, pinctl); | ||
| 676 | return spec->spdif_sw_put(kcontrol, ucontrol); | ||
| 677 | } | ||
| 678 | |||
| 679 | /* hook the SPDIF switch */ | ||
| 680 | static void cs4208_fixup_spdif_switch(struct hda_codec *codec, | ||
| 681 | const struct hda_fixup *fix, int action) | ||
| 682 | { | ||
| 683 | if (action == HDA_FIXUP_ACT_BUILD) { | ||
| 684 | struct cs_spec *spec = codec->spec; | ||
| 685 | struct snd_kcontrol *kctl; | ||
| 686 | |||
| 687 | if (!spec->gen.autocfg.dig_out_pins[0]) | ||
| 688 | return; | ||
| 689 | kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch"); | ||
| 690 | if (!kctl) | ||
| 691 | return; | ||
| 692 | spec->spdif_sw_put = kctl->put; | ||
| 693 | kctl->put = cs4208_spdif_sw_put; | ||
| 694 | } | ||
| 695 | } | ||
| 696 | |||
| 629 | static const struct hda_fixup cs4208_fixups[] = { | 697 | static const struct hda_fixup cs4208_fixups[] = { |
| 630 | [CS4208_MBA6] = { | 698 | [CS4208_MBA6] = { |
| 631 | .type = HDA_FIXUP_PINS, | 699 | .type = HDA_FIXUP_PINS, |
| @@ -633,10 +701,20 @@ static const struct hda_fixup cs4208_fixups[] = { | |||
| 633 | .chained = true, | 701 | .chained = true, |
| 634 | .chain_id = CS4208_GPIO0, | 702 | .chain_id = CS4208_GPIO0, |
| 635 | }, | 703 | }, |
| 704 | [CS4208_MBP11] = { | ||
| 705 | .type = HDA_FIXUP_FUNC, | ||
| 706 | .v.func = cs4208_fixup_spdif_switch, | ||
| 707 | .chained = true, | ||
| 708 | .chain_id = CS4208_GPIO0, | ||
| 709 | }, | ||
| 636 | [CS4208_GPIO0] = { | 710 | [CS4208_GPIO0] = { |
| 637 | .type = HDA_FIXUP_FUNC, | 711 | .type = HDA_FIXUP_FUNC, |
| 638 | .v.func = cs4208_fixup_gpio0, | 712 | .v.func = cs4208_fixup_gpio0, |
| 639 | }, | 713 | }, |
| 714 | [CS4208_MAC_AUTO] = { | ||
| 715 | .type = HDA_FIXUP_FUNC, | ||
| 716 | .v.func = cs4208_fixup_mac, | ||
| 717 | }, | ||
| 640 | }; | 718 | }; |
| 641 | 719 | ||
| 642 | /* correct the 0dB offset of input pins */ | 720 | /* correct the 0dB offset of input pins */ |
| @@ -660,6 +738,8 @@ static int patch_cs4208(struct hda_codec *codec) | |||
| 660 | return -ENOMEM; | 738 | return -ENOMEM; |
| 661 | 739 | ||
| 662 | spec->gen.automute_hook = cs_automute; | 740 | spec->gen.automute_hook = cs_automute; |
| 741 | /* exclude NID 0x10 (HP) from output volumes due to different steps */ | ||
| 742 | spec->gen.out_vol_mask = 1ULL << 0x10; | ||
| 663 | 743 | ||
| 664 | snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl, | 744 | snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl, |
| 665 | cs4208_fixups); | 745 | cs4208_fixups); |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index ec68eaea0336..c205bb1747fd 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
| @@ -3208,11 +3208,17 @@ static int cx_auto_init(struct hda_codec *codec) | |||
| 3208 | return 0; | 3208 | return 0; |
| 3209 | } | 3209 | } |
| 3210 | 3210 | ||
| 3211 | static void cx_auto_free(struct hda_codec *codec) | ||
| 3212 | { | ||
| 3213 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); | ||
| 3214 | snd_hda_gen_free(codec); | ||
| 3215 | } | ||
| 3216 | |||
| 3211 | static const struct hda_codec_ops cx_auto_patch_ops = { | 3217 | static const struct hda_codec_ops cx_auto_patch_ops = { |
| 3212 | .build_controls = cx_auto_build_controls, | 3218 | .build_controls = cx_auto_build_controls, |
| 3213 | .build_pcms = snd_hda_gen_build_pcms, | 3219 | .build_pcms = snd_hda_gen_build_pcms, |
| 3214 | .init = cx_auto_init, | 3220 | .init = cx_auto_init, |
| 3215 | .free = snd_hda_gen_free, | 3221 | .free = cx_auto_free, |
| 3216 | .unsol_event = snd_hda_jack_unsol_event, | 3222 | .unsol_event = snd_hda_jack_unsol_event, |
| 3217 | #ifdef CONFIG_PM | 3223 | #ifdef CONFIG_PM |
| 3218 | .check_power_status = snd_hda_gen_check_power_status, | 3224 | .check_power_status = snd_hda_gen_check_power_status, |
| @@ -3232,8 +3238,84 @@ enum { | |||
| 3232 | CXT_FIXUP_HEADPHONE_MIC_PIN, | 3238 | CXT_FIXUP_HEADPHONE_MIC_PIN, |
| 3233 | CXT_FIXUP_HEADPHONE_MIC, | 3239 | CXT_FIXUP_HEADPHONE_MIC, |
| 3234 | CXT_FIXUP_GPIO1, | 3240 | CXT_FIXUP_GPIO1, |
| 3241 | CXT_FIXUP_THINKPAD_ACPI, | ||
| 3235 | }; | 3242 | }; |
| 3236 | 3243 | ||
| 3244 | #if IS_ENABLED(CONFIG_THINKPAD_ACPI) | ||
| 3245 | |||
| 3246 | #include <linux/thinkpad_acpi.h> | ||
| 3247 | |||
| 3248 | static int (*led_set_func)(int, bool); | ||
| 3249 | |||
| 3250 | static void update_tpacpi_mute_led(void *private_data, int enabled) | ||
| 3251 | { | ||
| 3252 | struct hda_codec *codec = private_data; | ||
| 3253 | struct conexant_spec *spec = codec->spec; | ||
| 3254 | |||
| 3255 | if (spec->dynamic_eapd) | ||
| 3256 | cx_auto_vmaster_hook(private_data, enabled); | ||
| 3257 | |||
| 3258 | if (led_set_func) | ||
| 3259 | led_set_func(TPACPI_LED_MUTE, !enabled); | ||
| 3260 | } | ||
| 3261 | |||
| 3262 | static void update_tpacpi_micmute_led(struct hda_codec *codec, | ||
| 3263 | struct snd_ctl_elem_value *ucontrol) | ||
| 3264 | { | ||
| 3265 | if (!ucontrol || !led_set_func) | ||
| 3266 | return; | ||
| 3267 | if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) { | ||
| 3268 | /* TODO: How do I verify if it's a mono or stereo here? */ | ||
| 3269 | bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]; | ||
| 3270 | led_set_func(TPACPI_LED_MICMUTE, !val); | ||
| 3271 | } | ||
| 3272 | } | ||
| 3273 | |||
| 3274 | static void cxt_fixup_thinkpad_acpi(struct hda_codec *codec, | ||
| 3275 | const struct hda_fixup *fix, int action) | ||
| 3276 | { | ||
| 3277 | struct conexant_spec *spec = codec->spec; | ||
| 3278 | |||
| 3279 | bool removefunc = false; | ||
| 3280 | |||
| 3281 | if (action == HDA_FIXUP_ACT_PROBE) { | ||
| 3282 | if (!led_set_func) | ||
| 3283 | led_set_func = symbol_request(tpacpi_led_set); | ||
| 3284 | if (!led_set_func) { | ||
| 3285 | snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n"); | ||
| 3286 | return; | ||
| 3287 | } | ||
| 3288 | |||
| 3289 | removefunc = true; | ||
| 3290 | if (led_set_func(TPACPI_LED_MUTE, false) >= 0) { | ||
| 3291 | spec->gen.vmaster_mute.hook = update_tpacpi_mute_led; | ||
| 3292 | removefunc = false; | ||
| 3293 | } | ||
| 3294 | if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { | ||
| 3295 | if (spec->gen.num_adc_nids > 1) | ||
| 3296 | snd_printdd("Skipping micmute LED control due to several ADCs"); | ||
| 3297 | else { | ||
| 3298 | spec->gen.cap_sync_hook = update_tpacpi_micmute_led; | ||
| 3299 | removefunc = false; | ||
| 3300 | } | ||
| 3301 | } | ||
| 3302 | } | ||
| 3303 | |||
| 3304 | if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) { | ||
| 3305 | symbol_put(tpacpi_led_set); | ||
| 3306 | led_set_func = NULL; | ||
| 3307 | } | ||
| 3308 | } | ||
| 3309 | |||
| 3310 | #else | ||
| 3311 | |||
| 3312 | static void cxt_fixup_thinkpad_acpi(struct hda_codec *codec, | ||
| 3313 | const struct hda_fixup *fix, int action) | ||
| 3314 | { | ||
| 3315 | } | ||
| 3316 | |||
| 3317 | #endif | ||
| 3318 | |||
| 3237 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec, | 3319 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec, |
| 3238 | const struct hda_fixup *fix, int action) | 3320 | const struct hda_fixup *fix, int action) |
| 3239 | { | 3321 | { |
| @@ -3344,6 +3426,8 @@ static const struct hda_fixup cxt_fixups[] = { | |||
| 3344 | [CXT_PINCFG_LENOVO_TP410] = { | 3426 | [CXT_PINCFG_LENOVO_TP410] = { |
| 3345 | .type = HDA_FIXUP_PINS, | 3427 | .type = HDA_FIXUP_PINS, |
| 3346 | .v.pins = cxt_pincfg_lenovo_tp410, | 3428 | .v.pins = cxt_pincfg_lenovo_tp410, |
| 3429 | .chained = true, | ||
| 3430 | .chain_id = CXT_FIXUP_THINKPAD_ACPI, | ||
| 3347 | }, | 3431 | }, |
| 3348 | [CXT_PINCFG_LEMOTE_A1004] = { | 3432 | [CXT_PINCFG_LEMOTE_A1004] = { |
| 3349 | .type = HDA_FIXUP_PINS, | 3433 | .type = HDA_FIXUP_PINS, |
| @@ -3385,6 +3469,10 @@ static const struct hda_fixup cxt_fixups[] = { | |||
| 3385 | { } | 3469 | { } |
| 3386 | }, | 3470 | }, |
| 3387 | }, | 3471 | }, |
| 3472 | [CXT_FIXUP_THINKPAD_ACPI] = { | ||
| 3473 | .type = HDA_FIXUP_FUNC, | ||
| 3474 | .v.func = cxt_fixup_thinkpad_acpi, | ||
| 3475 | }, | ||
| 3388 | }; | 3476 | }; |
| 3389 | 3477 | ||
| 3390 | static const struct snd_pci_quirk cxt5051_fixups[] = { | 3478 | static const struct snd_pci_quirk cxt5051_fixups[] = { |
| @@ -3507,7 +3595,7 @@ static int patch_conexant_auto(struct hda_codec *codec) | |||
| 3507 | return 0; | 3595 | return 0; |
| 3508 | 3596 | ||
| 3509 | error: | 3597 | error: |
| 3510 | snd_hda_gen_free(codec); | 3598 | cx_auto_free(codec); |
| 3511 | return err; | 3599 | return err; |
| 3512 | } | 3600 | } |
| 3513 | 3601 | ||
| @@ -3568,6 +3656,8 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = { | |||
| 3568 | .patch = patch_conexant_auto }, | 3656 | .patch = patch_conexant_auto }, |
| 3569 | { .id = 0x14f15115, .name = "CX20757", | 3657 | { .id = 0x14f15115, .name = "CX20757", |
| 3570 | .patch = patch_conexant_auto }, | 3658 | .patch = patch_conexant_auto }, |
| 3659 | { .id = 0x14f151d7, .name = "CX20952", | ||
| 3660 | .patch = patch_conexant_auto }, | ||
| 3571 | {} /* terminator */ | 3661 | {} /* terminator */ |
| 3572 | }; | 3662 | }; |
| 3573 | 3663 | ||
| @@ -3594,6 +3684,7 @@ MODULE_ALIAS("snd-hda-codec-id:14f15111"); | |||
| 3594 | MODULE_ALIAS("snd-hda-codec-id:14f15113"); | 3684 | MODULE_ALIAS("snd-hda-codec-id:14f15113"); |
| 3595 | MODULE_ALIAS("snd-hda-codec-id:14f15114"); | 3685 | MODULE_ALIAS("snd-hda-codec-id:14f15114"); |
| 3596 | MODULE_ALIAS("snd-hda-codec-id:14f15115"); | 3686 | MODULE_ALIAS("snd-hda-codec-id:14f15115"); |
| 3687 | MODULE_ALIAS("snd-hda-codec-id:14f151d7"); | ||
| 3597 | 3688 | ||
| 3598 | MODULE_LICENSE("GPL"); | 3689 | MODULE_LICENSE("GPL"); |
| 3599 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | 3690 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 50173d412ac5..08407bed093e 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | * Copyright (c) 2006 ATI Technologies Inc. | 6 | * Copyright (c) 2006 ATI Technologies Inc. |
| 7 | * Copyright (c) 2008 NVIDIA Corp. All rights reserved. | 7 | * Copyright (c) 2008 NVIDIA Corp. All rights reserved. |
| 8 | * Copyright (c) 2008 Wei Ni <wni@nvidia.com> | 8 | * Copyright (c) 2008 Wei Ni <wni@nvidia.com> |
| 9 | * Copyright (c) 2013 Anssi Hannula <anssi.hannula@iki.fi> | ||
| 9 | * | 10 | * |
| 10 | * Authors: | 11 | * Authors: |
| 11 | * Wu Fengguang <wfg@linux.intel.com> | 12 | * Wu Fengguang <wfg@linux.intel.com> |
| @@ -45,6 +46,7 @@ module_param(static_hdmi_pcm, bool, 0644); | |||
| 45 | MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); | 46 | MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); |
| 46 | 47 | ||
| 47 | #define is_haswell(codec) ((codec)->vendor_id == 0x80862807) | 48 | #define is_haswell(codec) ((codec)->vendor_id == 0x80862807) |
| 49 | #define is_valleyview(codec) ((codec)->vendor_id == 0x80862882) | ||
| 48 | 50 | ||
| 49 | struct hdmi_spec_per_cvt { | 51 | struct hdmi_spec_per_cvt { |
| 50 | hda_nid_t cvt_nid; | 52 | hda_nid_t cvt_nid; |
| @@ -63,9 +65,11 @@ struct hdmi_spec_per_pin { | |||
| 63 | hda_nid_t pin_nid; | 65 | hda_nid_t pin_nid; |
| 64 | int num_mux_nids; | 66 | int num_mux_nids; |
| 65 | hda_nid_t mux_nids[HDA_MAX_CONNECTIONS]; | 67 | hda_nid_t mux_nids[HDA_MAX_CONNECTIONS]; |
| 68 | hda_nid_t cvt_nid; | ||
| 66 | 69 | ||
| 67 | struct hda_codec *codec; | 70 | struct hda_codec *codec; |
| 68 | struct hdmi_eld sink_eld; | 71 | struct hdmi_eld sink_eld; |
| 72 | struct mutex lock; | ||
| 69 | struct delayed_work work; | 73 | struct delayed_work work; |
| 70 | struct snd_kcontrol *eld_ctl; | 74 | struct snd_kcontrol *eld_ctl; |
| 71 | int repoll_count; | 75 | int repoll_count; |
| @@ -75,6 +79,42 @@ struct hdmi_spec_per_pin { | |||
| 75 | bool chmap_set; /* channel-map override by ALSA API? */ | 79 | bool chmap_set; /* channel-map override by ALSA API? */ |
| 76 | unsigned char chmap[8]; /* ALSA API channel-map */ | 80 | unsigned char chmap[8]; /* ALSA API channel-map */ |
| 77 | char pcm_name[8]; /* filled in build_pcm callbacks */ | 81 | char pcm_name[8]; /* filled in build_pcm callbacks */ |
| 82 | #ifdef CONFIG_PROC_FS | ||
| 83 | struct snd_info_entry *proc_entry; | ||
| 84 | #endif | ||
| 85 | }; | ||
| 86 | |||
| 87 | struct cea_channel_speaker_allocation; | ||
| 88 | |||
| 89 | /* operations used by generic code that can be overridden by patches */ | ||
| 90 | struct hdmi_ops { | ||
| 91 | int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 92 | unsigned char *buf, int *eld_size); | ||
| 93 | |||
| 94 | /* get and set channel assigned to each HDMI ASP (audio sample packet) slot */ | ||
| 95 | int (*pin_get_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 96 | int asp_slot); | ||
| 97 | int (*pin_set_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 98 | int asp_slot, int channel); | ||
| 99 | |||
| 100 | void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 101 | int ca, int active_channels, int conn_type); | ||
| 102 | |||
| 103 | /* enable/disable HBR (HD passthrough) */ | ||
| 104 | int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr); | ||
| 105 | |||
| 106 | int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid, | ||
| 107 | hda_nid_t pin_nid, u32 stream_tag, int format); | ||
| 108 | |||
| 109 | /* Helpers for producing the channel map TLVs. These can be overridden | ||
| 110 | * for devices that have non-standard mapping requirements. */ | ||
| 111 | int (*chmap_cea_alloc_validate_get_type)(struct cea_channel_speaker_allocation *cap, | ||
| 112 | int channels); | ||
| 113 | void (*cea_alloc_to_tlv_chmap)(struct cea_channel_speaker_allocation *cap, | ||
| 114 | unsigned int *chmap, int channels); | ||
| 115 | |||
| 116 | /* check that the user-given chmap is supported */ | ||
| 117 | int (*chmap_validate)(int ca, int channels, unsigned char *chmap); | ||
| 78 | }; | 118 | }; |
| 79 | 119 | ||
| 80 | struct hdmi_spec { | 120 | struct hdmi_spec { |
| @@ -88,8 +128,9 @@ struct hdmi_spec { | |||
| 88 | unsigned int channels_max; /* max over all cvts */ | 128 | unsigned int channels_max; /* max over all cvts */ |
| 89 | 129 | ||
| 90 | struct hdmi_eld temp_eld; | 130 | struct hdmi_eld temp_eld; |
| 131 | struct hdmi_ops ops; | ||
| 91 | /* | 132 | /* |
| 92 | * Non-generic ATI/NVIDIA specific | 133 | * Non-generic VIA/NVIDIA specific |
| 93 | */ | 134 | */ |
| 94 | struct hda_multi_out multiout; | 135 | struct hda_multi_out multiout; |
| 95 | struct hda_pcm_stream pcm_playback; | 136 | struct hda_pcm_stream pcm_playback; |
| @@ -348,17 +389,19 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol, | |||
| 348 | { | 389 | { |
| 349 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 390 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 350 | struct hdmi_spec *spec = codec->spec; | 391 | struct hdmi_spec *spec = codec->spec; |
| 392 | struct hdmi_spec_per_pin *per_pin; | ||
| 351 | struct hdmi_eld *eld; | 393 | struct hdmi_eld *eld; |
| 352 | int pin_idx; | 394 | int pin_idx; |
| 353 | 395 | ||
| 354 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | 396 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; |
| 355 | 397 | ||
| 356 | pin_idx = kcontrol->private_value; | 398 | pin_idx = kcontrol->private_value; |
| 357 | eld = &get_pin(spec, pin_idx)->sink_eld; | 399 | per_pin = get_pin(spec, pin_idx); |
| 400 | eld = &per_pin->sink_eld; | ||
| 358 | 401 | ||
| 359 | mutex_lock(&eld->lock); | 402 | mutex_lock(&per_pin->lock); |
| 360 | uinfo->count = eld->eld_valid ? eld->eld_size : 0; | 403 | uinfo->count = eld->eld_valid ? eld->eld_size : 0; |
| 361 | mutex_unlock(&eld->lock); | 404 | mutex_unlock(&per_pin->lock); |
| 362 | 405 | ||
| 363 | return 0; | 406 | return 0; |
| 364 | } | 407 | } |
| @@ -368,15 +411,17 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, | |||
| 368 | { | 411 | { |
| 369 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 412 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 370 | struct hdmi_spec *spec = codec->spec; | 413 | struct hdmi_spec *spec = codec->spec; |
| 414 | struct hdmi_spec_per_pin *per_pin; | ||
| 371 | struct hdmi_eld *eld; | 415 | struct hdmi_eld *eld; |
| 372 | int pin_idx; | 416 | int pin_idx; |
| 373 | 417 | ||
| 374 | pin_idx = kcontrol->private_value; | 418 | pin_idx = kcontrol->private_value; |
| 375 | eld = &get_pin(spec, pin_idx)->sink_eld; | 419 | per_pin = get_pin(spec, pin_idx); |
| 420 | eld = &per_pin->sink_eld; | ||
| 376 | 421 | ||
| 377 | mutex_lock(&eld->lock); | 422 | mutex_lock(&per_pin->lock); |
| 378 | if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) { | 423 | if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) { |
| 379 | mutex_unlock(&eld->lock); | 424 | mutex_unlock(&per_pin->lock); |
| 380 | snd_BUG(); | 425 | snd_BUG(); |
| 381 | return -EINVAL; | 426 | return -EINVAL; |
| 382 | } | 427 | } |
| @@ -386,7 +431,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, | |||
| 386 | if (eld->eld_valid) | 431 | if (eld->eld_valid) |
| 387 | memcpy(ucontrol->value.bytes.data, eld->eld_buffer, | 432 | memcpy(ucontrol->value.bytes.data, eld->eld_buffer, |
| 388 | eld->eld_size); | 433 | eld->eld_size); |
| 389 | mutex_unlock(&eld->lock); | 434 | mutex_unlock(&per_pin->lock); |
| 390 | 435 | ||
| 391 | return 0; | 436 | return 0; |
| 392 | } | 437 | } |
| @@ -477,6 +522,68 @@ static void hdmi_set_channel_count(struct hda_codec *codec, | |||
| 477 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | 522 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); |
| 478 | } | 523 | } |
| 479 | 524 | ||
| 525 | /* | ||
| 526 | * ELD proc files | ||
| 527 | */ | ||
| 528 | |||
| 529 | #ifdef CONFIG_PROC_FS | ||
| 530 | static void print_eld_info(struct snd_info_entry *entry, | ||
| 531 | struct snd_info_buffer *buffer) | ||
| 532 | { | ||
| 533 | struct hdmi_spec_per_pin *per_pin = entry->private_data; | ||
| 534 | |||
| 535 | mutex_lock(&per_pin->lock); | ||
| 536 | snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer); | ||
| 537 | mutex_unlock(&per_pin->lock); | ||
| 538 | } | ||
| 539 | |||
| 540 | static void write_eld_info(struct snd_info_entry *entry, | ||
| 541 | struct snd_info_buffer *buffer) | ||
| 542 | { | ||
| 543 | struct hdmi_spec_per_pin *per_pin = entry->private_data; | ||
| 544 | |||
| 545 | mutex_lock(&per_pin->lock); | ||
| 546 | snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer); | ||
| 547 | mutex_unlock(&per_pin->lock); | ||
| 548 | } | ||
| 549 | |||
| 550 | static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index) | ||
| 551 | { | ||
| 552 | char name[32]; | ||
| 553 | struct hda_codec *codec = per_pin->codec; | ||
| 554 | struct snd_info_entry *entry; | ||
| 555 | int err; | ||
| 556 | |||
| 557 | snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); | ||
| 558 | err = snd_card_proc_new(codec->bus->card, name, &entry); | ||
| 559 | if (err < 0) | ||
| 560 | return err; | ||
| 561 | |||
| 562 | snd_info_set_text_ops(entry, per_pin, print_eld_info); | ||
| 563 | entry->c.text.write = write_eld_info; | ||
| 564 | entry->mode |= S_IWUSR; | ||
| 565 | per_pin->proc_entry = entry; | ||
| 566 | |||
| 567 | return 0; | ||
| 568 | } | ||
| 569 | |||
| 570 | static void eld_proc_free(struct hdmi_spec_per_pin *per_pin) | ||
| 571 | { | ||
| 572 | if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { | ||
| 573 | snd_device_free(per_pin->codec->bus->card, per_pin->proc_entry); | ||
| 574 | per_pin->proc_entry = NULL; | ||
| 575 | } | ||
| 576 | } | ||
| 577 | #else | ||
| 578 | static inline int eld_proc_new(struct hdmi_spec_per_pin *per_pin, | ||
| 579 | int index) | ||
| 580 | { | ||
| 581 | return 0; | ||
| 582 | } | ||
| 583 | static inline void eld_proc_free(struct hdmi_spec_per_pin *per_pin) | ||
| 584 | { | ||
| 585 | } | ||
| 586 | #endif | ||
| 480 | 587 | ||
| 481 | /* | 588 | /* |
| 482 | * Channel mapping routines | 589 | * Channel mapping routines |
| @@ -577,74 +684,91 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec, | |||
| 577 | hda_nid_t pin_nid) | 684 | hda_nid_t pin_nid) |
| 578 | { | 685 | { |
| 579 | #ifdef CONFIG_SND_DEBUG_VERBOSE | 686 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 687 | struct hdmi_spec *spec = codec->spec; | ||
| 580 | int i; | 688 | int i; |
| 581 | int slot; | 689 | int channel; |
| 582 | 690 | ||
| 583 | for (i = 0; i < 8; i++) { | 691 | for (i = 0; i < 8; i++) { |
| 584 | slot = snd_hda_codec_read(codec, pin_nid, 0, | 692 | channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i); |
| 585 | AC_VERB_GET_HDMI_CHAN_SLOT, i); | ||
| 586 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", | 693 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", |
| 587 | slot >> 4, slot & 0xf); | 694 | channel, i); |
| 588 | } | 695 | } |
| 589 | #endif | 696 | #endif |
| 590 | } | 697 | } |
| 591 | 698 | ||
| 592 | |||
| 593 | static void hdmi_std_setup_channel_mapping(struct hda_codec *codec, | 699 | static void hdmi_std_setup_channel_mapping(struct hda_codec *codec, |
| 594 | hda_nid_t pin_nid, | 700 | hda_nid_t pin_nid, |
| 595 | bool non_pcm, | 701 | bool non_pcm, |
| 596 | int ca) | 702 | int ca) |
| 597 | { | 703 | { |
| 704 | struct hdmi_spec *spec = codec->spec; | ||
| 705 | struct cea_channel_speaker_allocation *ch_alloc; | ||
| 598 | int i; | 706 | int i; |
| 599 | int err; | 707 | int err; |
| 600 | int order; | 708 | int order; |
| 601 | int non_pcm_mapping[8]; | 709 | int non_pcm_mapping[8]; |
| 602 | 710 | ||
| 603 | order = get_channel_allocation_order(ca); | 711 | order = get_channel_allocation_order(ca); |
| 712 | ch_alloc = &channel_allocations[order]; | ||
| 604 | 713 | ||
| 605 | if (hdmi_channel_mapping[ca][1] == 0) { | 714 | if (hdmi_channel_mapping[ca][1] == 0) { |
| 606 | for (i = 0; i < channel_allocations[order].channels; i++) | 715 | int hdmi_slot = 0; |
| 607 | hdmi_channel_mapping[ca][i] = i | (i << 4); | 716 | /* fill actual channel mappings in ALSA channel (i) order */ |
| 608 | for (; i < 8; i++) | 717 | for (i = 0; i < ch_alloc->channels; i++) { |
| 609 | hdmi_channel_mapping[ca][i] = 0xf | (i << 4); | 718 | while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8)) |
| 719 | hdmi_slot++; /* skip zero slots */ | ||
| 720 | |||
| 721 | hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++; | ||
| 722 | } | ||
| 723 | /* fill the rest of the slots with ALSA channel 0xf */ | ||
| 724 | for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) | ||
| 725 | if (!ch_alloc->speakers[7 - hdmi_slot]) | ||
| 726 | hdmi_channel_mapping[ca][i++] = (0xf << 4) | hdmi_slot; | ||
| 610 | } | 727 | } |
| 611 | 728 | ||
| 612 | if (non_pcm) { | 729 | if (non_pcm) { |
| 613 | for (i = 0; i < channel_allocations[order].channels; i++) | 730 | for (i = 0; i < ch_alloc->channels; i++) |
| 614 | non_pcm_mapping[i] = i | (i << 4); | 731 | non_pcm_mapping[i] = (i << 4) | i; |
| 615 | for (; i < 8; i++) | 732 | for (; i < 8; i++) |
| 616 | non_pcm_mapping[i] = 0xf | (i << 4); | 733 | non_pcm_mapping[i] = (0xf << 4) | i; |
| 617 | } | 734 | } |
| 618 | 735 | ||
| 619 | for (i = 0; i < 8; i++) { | 736 | for (i = 0; i < 8; i++) { |
| 620 | err = snd_hda_codec_write(codec, pin_nid, 0, | 737 | int slotsetup = non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]; |
| 621 | AC_VERB_SET_HDMI_CHAN_SLOT, | 738 | int hdmi_slot = slotsetup & 0x0f; |
| 622 | non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]); | 739 | int channel = (slotsetup & 0xf0) >> 4; |
| 740 | err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel); | ||
| 623 | if (err) { | 741 | if (err) { |
| 624 | snd_printdd(KERN_NOTICE | 742 | snd_printdd(KERN_NOTICE |
| 625 | "HDMI: channel mapping failed\n"); | 743 | "HDMI: channel mapping failed\n"); |
| 626 | break; | 744 | break; |
| 627 | } | 745 | } |
| 628 | } | 746 | } |
| 629 | |||
| 630 | hdmi_debug_channel_mapping(codec, pin_nid); | ||
| 631 | } | 747 | } |
| 632 | 748 | ||
| 633 | struct channel_map_table { | 749 | struct channel_map_table { |
| 634 | unsigned char map; /* ALSA API channel map position */ | 750 | unsigned char map; /* ALSA API channel map position */ |
| 635 | unsigned char cea_slot; /* CEA slot value */ | ||
| 636 | int spk_mask; /* speaker position bit mask */ | 751 | int spk_mask; /* speaker position bit mask */ |
| 637 | }; | 752 | }; |
| 638 | 753 | ||
| 639 | static struct channel_map_table map_tables[] = { | 754 | static struct channel_map_table map_tables[] = { |
| 640 | { SNDRV_CHMAP_FL, 0x00, FL }, | 755 | { SNDRV_CHMAP_FL, FL }, |
| 641 | { SNDRV_CHMAP_FR, 0x01, FR }, | 756 | { SNDRV_CHMAP_FR, FR }, |
| 642 | { SNDRV_CHMAP_RL, 0x04, RL }, | 757 | { SNDRV_CHMAP_RL, RL }, |
| 643 | { SNDRV_CHMAP_RR, 0x05, RR }, | 758 | { SNDRV_CHMAP_RR, RR }, |
| 644 | { SNDRV_CHMAP_LFE, 0x02, LFE }, | 759 | { SNDRV_CHMAP_LFE, LFE }, |
| 645 | { SNDRV_CHMAP_FC, 0x03, FC }, | 760 | { SNDRV_CHMAP_FC, FC }, |
| 646 | { SNDRV_CHMAP_RLC, 0x06, RLC }, | 761 | { SNDRV_CHMAP_RLC, RLC }, |
| 647 | { SNDRV_CHMAP_RRC, 0x07, RRC }, | 762 | { SNDRV_CHMAP_RRC, RRC }, |
| 763 | { SNDRV_CHMAP_RC, RC }, | ||
| 764 | { SNDRV_CHMAP_FLC, FLC }, | ||
| 765 | { SNDRV_CHMAP_FRC, FRC }, | ||
| 766 | { SNDRV_CHMAP_TFL, FLH }, | ||
| 767 | { SNDRV_CHMAP_TFR, FRH }, | ||
| 768 | { SNDRV_CHMAP_FLW, FLW }, | ||
| 769 | { SNDRV_CHMAP_FRW, FRW }, | ||
| 770 | { SNDRV_CHMAP_TC, TC }, | ||
| 771 | { SNDRV_CHMAP_TFC, FCH }, | ||
| 648 | {} /* terminator */ | 772 | {} /* terminator */ |
| 649 | }; | 773 | }; |
| 650 | 774 | ||
| @@ -660,25 +784,19 @@ static int to_spk_mask(unsigned char c) | |||
| 660 | } | 784 | } |
| 661 | 785 | ||
| 662 | /* from ALSA API channel position to CEA slot */ | 786 | /* from ALSA API channel position to CEA slot */ |
| 663 | static int to_cea_slot(unsigned char c) | 787 | static int to_cea_slot(int ordered_ca, unsigned char pos) |
| 664 | { | 788 | { |
| 665 | struct channel_map_table *t = map_tables; | 789 | int mask = to_spk_mask(pos); |
| 666 | for (; t->map; t++) { | 790 | int i; |
| 667 | if (t->map == c) | ||
| 668 | return t->cea_slot; | ||
| 669 | } | ||
| 670 | return 0x0f; | ||
| 671 | } | ||
| 672 | 791 | ||
| 673 | /* from CEA slot to ALSA API channel position */ | 792 | if (mask) { |
| 674 | static int from_cea_slot(unsigned char c) | 793 | for (i = 0; i < 8; i++) { |
| 675 | { | 794 | if (channel_allocations[ordered_ca].speakers[7 - i] == mask) |
| 676 | struct channel_map_table *t = map_tables; | 795 | return i; |
| 677 | for (; t->map; t++) { | 796 | } |
| 678 | if (t->cea_slot == c) | ||
| 679 | return t->map; | ||
| 680 | } | 797 | } |
| 681 | return 0; | 798 | |
| 799 | return -1; | ||
| 682 | } | 800 | } |
| 683 | 801 | ||
| 684 | /* from speaker bit mask to ALSA API channel position */ | 802 | /* from speaker bit mask to ALSA API channel position */ |
| @@ -692,6 +810,14 @@ static int spk_to_chmap(int spk) | |||
| 692 | return 0; | 810 | return 0; |
| 693 | } | 811 | } |
| 694 | 812 | ||
| 813 | /* from CEA slot to ALSA API channel position */ | ||
| 814 | static int from_cea_slot(int ordered_ca, unsigned char slot) | ||
| 815 | { | ||
| 816 | int mask = channel_allocations[ordered_ca].speakers[7 - slot]; | ||
| 817 | |||
| 818 | return spk_to_chmap(mask); | ||
| 819 | } | ||
| 820 | |||
| 695 | /* get the CA index corresponding to the given ALSA API channel map */ | 821 | /* get the CA index corresponding to the given ALSA API channel map */ |
| 696 | static int hdmi_manual_channel_allocation(int chs, unsigned char *map) | 822 | static int hdmi_manual_channel_allocation(int chs, unsigned char *map) |
| 697 | { | 823 | { |
| @@ -718,18 +844,29 @@ static int hdmi_manual_channel_allocation(int chs, unsigned char *map) | |||
| 718 | /* set up the channel slots for the given ALSA API channel map */ | 844 | /* set up the channel slots for the given ALSA API channel map */ |
| 719 | static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec, | 845 | static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec, |
| 720 | hda_nid_t pin_nid, | 846 | hda_nid_t pin_nid, |
| 721 | int chs, unsigned char *map) | 847 | int chs, unsigned char *map, |
| 848 | int ca) | ||
| 722 | { | 849 | { |
| 723 | int i; | 850 | struct hdmi_spec *spec = codec->spec; |
| 724 | for (i = 0; i < 8; i++) { | 851 | int ordered_ca = get_channel_allocation_order(ca); |
| 725 | int val, err; | 852 | int alsa_pos, hdmi_slot; |
| 726 | if (i < chs) | 853 | int assignments[8] = {[0 ... 7] = 0xf}; |
| 727 | val = to_cea_slot(map[i]); | 854 | |
| 728 | else | 855 | for (alsa_pos = 0; alsa_pos < chs; alsa_pos++) { |
| 729 | val = 0xf; | 856 | |
| 730 | val |= (i << 4); | 857 | hdmi_slot = to_cea_slot(ordered_ca, map[alsa_pos]); |
| 731 | err = snd_hda_codec_write(codec, pin_nid, 0, | 858 | |
| 732 | AC_VERB_SET_HDMI_CHAN_SLOT, val); | 859 | if (hdmi_slot < 0) |
| 860 | continue; /* unassigned channel */ | ||
| 861 | |||
| 862 | assignments[hdmi_slot] = alsa_pos; | ||
| 863 | } | ||
| 864 | |||
| 865 | for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) { | ||
| 866 | int err; | ||
| 867 | |||
| 868 | err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, | ||
| 869 | assignments[hdmi_slot]); | ||
| 733 | if (err) | 870 | if (err) |
| 734 | return -EINVAL; | 871 | return -EINVAL; |
| 735 | } | 872 | } |
| @@ -740,9 +877,10 @@ static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec, | |||
| 740 | static void hdmi_setup_fake_chmap(unsigned char *map, int ca) | 877 | static void hdmi_setup_fake_chmap(unsigned char *map, int ca) |
| 741 | { | 878 | { |
| 742 | int i; | 879 | int i; |
| 880 | int ordered_ca = get_channel_allocation_order(ca); | ||
| 743 | for (i = 0; i < 8; i++) { | 881 | for (i = 0; i < 8; i++) { |
| 744 | if (i < channel_allocations[ca].channels) | 882 | if (i < channel_allocations[ordered_ca].channels) |
| 745 | map[i] = from_cea_slot((hdmi_channel_mapping[ca][i] >> 4) & 0x0f); | 883 | map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f); |
| 746 | else | 884 | else |
| 747 | map[i] = 0; | 885 | map[i] = 0; |
| 748 | } | 886 | } |
| @@ -755,11 +893,29 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec, | |||
| 755 | { | 893 | { |
| 756 | if (!non_pcm && chmap_set) { | 894 | if (!non_pcm && chmap_set) { |
| 757 | hdmi_manual_setup_channel_mapping(codec, pin_nid, | 895 | hdmi_manual_setup_channel_mapping(codec, pin_nid, |
| 758 | channels, map); | 896 | channels, map, ca); |
| 759 | } else { | 897 | } else { |
| 760 | hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca); | 898 | hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca); |
| 761 | hdmi_setup_fake_chmap(map, ca); | 899 | hdmi_setup_fake_chmap(map, ca); |
| 762 | } | 900 | } |
| 901 | |||
| 902 | hdmi_debug_channel_mapping(codec, pin_nid); | ||
| 903 | } | ||
| 904 | |||
| 905 | static int hdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 906 | int asp_slot, int channel) | ||
| 907 | { | ||
| 908 | return snd_hda_codec_write(codec, pin_nid, 0, | ||
| 909 | AC_VERB_SET_HDMI_CHAN_SLOT, | ||
| 910 | (channel << 4) | asp_slot); | ||
| 911 | } | ||
| 912 | |||
| 913 | static int hdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 914 | int asp_slot) | ||
| 915 | { | ||
| 916 | return (snd_hda_codec_read(codec, pin_nid, 0, | ||
| 917 | AC_VERB_GET_HDMI_CHAN_SLOT, | ||
| 918 | asp_slot) & 0xf0) >> 4; | ||
| 763 | } | 919 | } |
| 764 | 920 | ||
| 765 | /* | 921 | /* |
| @@ -883,15 +1039,64 @@ static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, | |||
| 883 | return true; | 1039 | return true; |
| 884 | } | 1040 | } |
| 885 | 1041 | ||
| 1042 | static void hdmi_pin_setup_infoframe(struct hda_codec *codec, | ||
| 1043 | hda_nid_t pin_nid, | ||
| 1044 | int ca, int active_channels, | ||
| 1045 | int conn_type) | ||
| 1046 | { | ||
| 1047 | union audio_infoframe ai; | ||
| 1048 | |||
| 1049 | if (conn_type == 0) { /* HDMI */ | ||
| 1050 | struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi; | ||
| 1051 | |||
| 1052 | hdmi_ai->type = 0x84; | ||
| 1053 | hdmi_ai->ver = 0x01; | ||
| 1054 | hdmi_ai->len = 0x0a; | ||
| 1055 | hdmi_ai->CC02_CT47 = active_channels - 1; | ||
| 1056 | hdmi_ai->CA = ca; | ||
| 1057 | hdmi_checksum_audio_infoframe(hdmi_ai); | ||
| 1058 | } else if (conn_type == 1) { /* DisplayPort */ | ||
| 1059 | struct dp_audio_infoframe *dp_ai = &ai.dp; | ||
| 1060 | |||
| 1061 | dp_ai->type = 0x84; | ||
| 1062 | dp_ai->len = 0x1b; | ||
| 1063 | dp_ai->ver = 0x11 << 2; | ||
| 1064 | dp_ai->CC02_CT47 = active_channels - 1; | ||
| 1065 | dp_ai->CA = ca; | ||
| 1066 | } else { | ||
| 1067 | snd_printd("HDMI: unknown connection type at pin %d\n", | ||
| 1068 | pin_nid); | ||
| 1069 | return; | ||
| 1070 | } | ||
| 1071 | |||
| 1072 | /* | ||
| 1073 | * sizeof(ai) is used instead of sizeof(*hdmi_ai) or | ||
| 1074 | * sizeof(*dp_ai) to avoid partial match/update problems when | ||
| 1075 | * the user switches between HDMI/DP monitors. | ||
| 1076 | */ | ||
| 1077 | if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, | ||
| 1078 | sizeof(ai))) { | ||
| 1079 | snd_printdd("hdmi_pin_setup_infoframe: " | ||
| 1080 | "pin=%d channels=%d ca=0x%02x\n", | ||
| 1081 | pin_nid, | ||
| 1082 | active_channels, ca); | ||
| 1083 | hdmi_stop_infoframe_trans(codec, pin_nid); | ||
| 1084 | hdmi_fill_audio_infoframe(codec, pin_nid, | ||
| 1085 | ai.bytes, sizeof(ai)); | ||
| 1086 | hdmi_start_infoframe_trans(codec, pin_nid); | ||
| 1087 | } | ||
| 1088 | } | ||
| 1089 | |||
| 886 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, | 1090 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, |
| 887 | struct hdmi_spec_per_pin *per_pin, | 1091 | struct hdmi_spec_per_pin *per_pin, |
| 888 | bool non_pcm) | 1092 | bool non_pcm) |
| 889 | { | 1093 | { |
| 1094 | struct hdmi_spec *spec = codec->spec; | ||
| 890 | hda_nid_t pin_nid = per_pin->pin_nid; | 1095 | hda_nid_t pin_nid = per_pin->pin_nid; |
| 891 | int channels = per_pin->channels; | 1096 | int channels = per_pin->channels; |
| 1097 | int active_channels; | ||
| 892 | struct hdmi_eld *eld; | 1098 | struct hdmi_eld *eld; |
| 893 | int ca; | 1099 | int ca, ordered_ca; |
| 894 | union audio_infoframe ai; | ||
| 895 | 1100 | ||
| 896 | if (!channels) | 1101 | if (!channels) |
| 897 | return; | 1102 | return; |
| @@ -912,29 +1117,10 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, | |||
| 912 | if (ca < 0) | 1117 | if (ca < 0) |
| 913 | ca = 0; | 1118 | ca = 0; |
| 914 | 1119 | ||
| 915 | memset(&ai, 0, sizeof(ai)); | 1120 | ordered_ca = get_channel_allocation_order(ca); |
| 916 | if (eld->info.conn_type == 0) { /* HDMI */ | 1121 | active_channels = channel_allocations[ordered_ca].channels; |
| 917 | struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi; | ||
| 918 | 1122 | ||
| 919 | hdmi_ai->type = 0x84; | 1123 | hdmi_set_channel_count(codec, per_pin->cvt_nid, active_channels); |
| 920 | hdmi_ai->ver = 0x01; | ||
| 921 | hdmi_ai->len = 0x0a; | ||
| 922 | hdmi_ai->CC02_CT47 = channels - 1; | ||
| 923 | hdmi_ai->CA = ca; | ||
| 924 | hdmi_checksum_audio_infoframe(hdmi_ai); | ||
| 925 | } else if (eld->info.conn_type == 1) { /* DisplayPort */ | ||
| 926 | struct dp_audio_infoframe *dp_ai = &ai.dp; | ||
| 927 | |||
| 928 | dp_ai->type = 0x84; | ||
| 929 | dp_ai->len = 0x1b; | ||
| 930 | dp_ai->ver = 0x11 << 2; | ||
| 931 | dp_ai->CC02_CT47 = channels - 1; | ||
| 932 | dp_ai->CA = ca; | ||
| 933 | } else { | ||
| 934 | snd_printd("HDMI: unknown connection type at pin %d\n", | ||
| 935 | pin_nid); | ||
| 936 | return; | ||
| 937 | } | ||
| 938 | 1124 | ||
| 939 | /* | 1125 | /* |
| 940 | * always configure channel mapping, it may have been changed by the | 1126 | * always configure channel mapping, it may have been changed by the |
| @@ -944,32 +1130,17 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, | |||
| 944 | channels, per_pin->chmap, | 1130 | channels, per_pin->chmap, |
| 945 | per_pin->chmap_set); | 1131 | per_pin->chmap_set); |
| 946 | 1132 | ||
| 947 | /* | 1133 | spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels, |
| 948 | * sizeof(ai) is used instead of sizeof(*hdmi_ai) or | 1134 | eld->info.conn_type); |
| 949 | * sizeof(*dp_ai) to avoid partial match/update problems when | ||
| 950 | * the user switches between HDMI/DP monitors. | ||
| 951 | */ | ||
| 952 | if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, | ||
| 953 | sizeof(ai))) { | ||
| 954 | snd_printdd("hdmi_setup_audio_infoframe: " | ||
| 955 | "pin=%d channels=%d\n", | ||
| 956 | pin_nid, | ||
| 957 | channels); | ||
| 958 | hdmi_stop_infoframe_trans(codec, pin_nid); | ||
| 959 | hdmi_fill_audio_infoframe(codec, pin_nid, | ||
| 960 | ai.bytes, sizeof(ai)); | ||
| 961 | hdmi_start_infoframe_trans(codec, pin_nid); | ||
| 962 | } | ||
| 963 | 1135 | ||
| 964 | per_pin->non_pcm = non_pcm; | 1136 | per_pin->non_pcm = non_pcm; |
| 965 | } | 1137 | } |
| 966 | 1138 | ||
| 967 | |||
| 968 | /* | 1139 | /* |
| 969 | * Unsolicited events | 1140 | * Unsolicited events |
| 970 | */ | 1141 | */ |
| 971 | 1142 | ||
| 972 | static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll); | 1143 | static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll); |
| 973 | 1144 | ||
| 974 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) | 1145 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) |
| 975 | { | 1146 | { |
| @@ -995,8 +1166,8 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) | |||
| 995 | if (pin_idx < 0) | 1166 | if (pin_idx < 0) |
| 996 | return; | 1167 | return; |
| 997 | 1168 | ||
| 998 | hdmi_present_sense(get_pin(spec, pin_idx), 1); | 1169 | if (hdmi_present_sense(get_pin(spec, pin_idx), 1)) |
| 999 | snd_hda_jack_report_sync(codec); | 1170 | snd_hda_jack_report_sync(codec); |
| 1000 | } | 1171 | } |
| 1001 | 1172 | ||
| 1002 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) | 1173 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) |
| @@ -1067,26 +1238,25 @@ static void haswell_verify_D0(struct hda_codec *codec, | |||
| 1067 | #define is_hbr_format(format) \ | 1238 | #define is_hbr_format(format) \ |
| 1068 | ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7) | 1239 | ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7) |
| 1069 | 1240 | ||
| 1070 | static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, | 1241 | static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, |
| 1071 | hda_nid_t pin_nid, u32 stream_tag, int format) | 1242 | bool hbr) |
| 1072 | { | 1243 | { |
| 1073 | int pinctl; | 1244 | int pinctl, new_pinctl; |
| 1074 | int new_pinctl = 0; | ||
| 1075 | |||
| 1076 | if (is_haswell(codec)) | ||
| 1077 | haswell_verify_D0(codec, cvt_nid, pin_nid); | ||
| 1078 | 1245 | ||
| 1079 | if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { | 1246 | if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { |
| 1080 | pinctl = snd_hda_codec_read(codec, pin_nid, 0, | 1247 | pinctl = snd_hda_codec_read(codec, pin_nid, 0, |
| 1081 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 1248 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1082 | 1249 | ||
| 1250 | if (pinctl < 0) | ||
| 1251 | return hbr ? -EINVAL : 0; | ||
| 1252 | |||
| 1083 | new_pinctl = pinctl & ~AC_PINCTL_EPT; | 1253 | new_pinctl = pinctl & ~AC_PINCTL_EPT; |
| 1084 | if (is_hbr_format(format)) | 1254 | if (hbr) |
| 1085 | new_pinctl |= AC_PINCTL_EPT_HBR; | 1255 | new_pinctl |= AC_PINCTL_EPT_HBR; |
| 1086 | else | 1256 | else |
| 1087 | new_pinctl |= AC_PINCTL_EPT_NATIVE; | 1257 | new_pinctl |= AC_PINCTL_EPT_NATIVE; |
| 1088 | 1258 | ||
| 1089 | snd_printdd("hdmi_setup_stream: " | 1259 | snd_printdd("hdmi_pin_hbr_setup: " |
| 1090 | "NID=0x%x, %spinctl=0x%x\n", | 1260 | "NID=0x%x, %spinctl=0x%x\n", |
| 1091 | pin_nid, | 1261 | pin_nid, |
| 1092 | pinctl == new_pinctl ? "" : "new-", | 1262 | pinctl == new_pinctl ? "" : "new-", |
| @@ -1096,11 +1266,26 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, | |||
| 1096 | snd_hda_codec_write(codec, pin_nid, 0, | 1266 | snd_hda_codec_write(codec, pin_nid, 0, |
| 1097 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 1267 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1098 | new_pinctl); | 1268 | new_pinctl); |
| 1269 | } else if (hbr) | ||
| 1270 | return -EINVAL; | ||
| 1099 | 1271 | ||
| 1100 | } | 1272 | return 0; |
| 1101 | if (is_hbr_format(format) && !new_pinctl) { | 1273 | } |
| 1274 | |||
| 1275 | static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, | ||
| 1276 | hda_nid_t pin_nid, u32 stream_tag, int format) | ||
| 1277 | { | ||
| 1278 | struct hdmi_spec *spec = codec->spec; | ||
| 1279 | int err; | ||
| 1280 | |||
| 1281 | if (is_haswell(codec)) | ||
| 1282 | haswell_verify_D0(codec, cvt_nid, pin_nid); | ||
| 1283 | |||
| 1284 | err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format)); | ||
| 1285 | |||
| 1286 | if (err) { | ||
| 1102 | snd_printdd("hdmi_setup_stream: HBR is not supported\n"); | 1287 | snd_printdd("hdmi_setup_stream: HBR is not supported\n"); |
| 1103 | return -EINVAL; | 1288 | return err; |
| 1104 | } | 1289 | } |
| 1105 | 1290 | ||
| 1106 | snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); | 1291 | snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); |
| @@ -1146,7 +1331,16 @@ static int hdmi_choose_cvt(struct hda_codec *codec, | |||
| 1146 | return 0; | 1331 | return 0; |
| 1147 | } | 1332 | } |
| 1148 | 1333 | ||
| 1149 | static void haswell_config_cvts(struct hda_codec *codec, | 1334 | /* Intel HDMI workaround to fix audio routing issue: |
| 1335 | * For some Intel display codecs, pins share the same connection list. | ||
| 1336 | * So a conveter can be selected by multiple pins and playback on any of these | ||
| 1337 | * pins will generate sound on the external display, because audio flows from | ||
| 1338 | * the same converter to the display pipeline. Also muting one pin may make | ||
| 1339 | * other pins have no sound output. | ||
| 1340 | * So this function assures that an assigned converter for a pin is not selected | ||
| 1341 | * by any other pins. | ||
| 1342 | */ | ||
| 1343 | static void intel_not_share_assigned_cvt(struct hda_codec *codec, | ||
| 1150 | hda_nid_t pin_nid, int mux_idx) | 1344 | hda_nid_t pin_nid, int mux_idx) |
| 1151 | { | 1345 | { |
| 1152 | struct hdmi_spec *spec = codec->spec; | 1346 | struct hdmi_spec *spec = codec->spec; |
| @@ -1217,6 +1411,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, | |||
| 1217 | per_cvt = get_cvt(spec, cvt_idx); | 1411 | per_cvt = get_cvt(spec, cvt_idx); |
| 1218 | /* Claim converter */ | 1412 | /* Claim converter */ |
| 1219 | per_cvt->assigned = 1; | 1413 | per_cvt->assigned = 1; |
| 1414 | per_pin->cvt_nid = per_cvt->cvt_nid; | ||
| 1220 | hinfo->nid = per_cvt->cvt_nid; | 1415 | hinfo->nid = per_cvt->cvt_nid; |
| 1221 | 1416 | ||
| 1222 | snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, | 1417 | snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, |
| @@ -1224,8 +1419,8 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, | |||
| 1224 | mux_idx); | 1419 | mux_idx); |
| 1225 | 1420 | ||
| 1226 | /* configure unused pins to choose other converters */ | 1421 | /* configure unused pins to choose other converters */ |
| 1227 | if (is_haswell(codec)) | 1422 | if (is_haswell(codec) || is_valleyview(codec)) |
| 1228 | haswell_config_cvts(codec, per_pin->pin_nid, mux_idx); | 1423 | intel_not_share_assigned_cvt(codec, per_pin->pin_nid, mux_idx); |
| 1229 | 1424 | ||
| 1230 | snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid); | 1425 | snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid); |
| 1231 | 1426 | ||
| @@ -1283,8 +1478,9 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) | |||
| 1283 | return 0; | 1478 | return 0; |
| 1284 | } | 1479 | } |
| 1285 | 1480 | ||
| 1286 | static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) | 1481 | static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) |
| 1287 | { | 1482 | { |
| 1483 | struct hda_jack_tbl *jack; | ||
| 1288 | struct hda_codec *codec = per_pin->codec; | 1484 | struct hda_codec *codec = per_pin->codec; |
| 1289 | struct hdmi_spec *spec = codec->spec; | 1485 | struct hdmi_spec *spec = codec->spec; |
| 1290 | struct hdmi_eld *eld = &spec->temp_eld; | 1486 | struct hdmi_eld *eld = &spec->temp_eld; |
| @@ -1301,7 +1497,9 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) | |||
| 1301 | int present = snd_hda_pin_sense(codec, pin_nid); | 1497 | int present = snd_hda_pin_sense(codec, pin_nid); |
| 1302 | bool update_eld = false; | 1498 | bool update_eld = false; |
| 1303 | bool eld_changed = false; | 1499 | bool eld_changed = false; |
| 1500 | bool ret; | ||
| 1304 | 1501 | ||
| 1502 | mutex_lock(&per_pin->lock); | ||
| 1305 | pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); | 1503 | pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); |
| 1306 | if (pin_eld->monitor_present) | 1504 | if (pin_eld->monitor_present) |
| 1307 | eld->eld_valid = !!(present & AC_PINSENSE_ELDV); | 1505 | eld->eld_valid = !!(present & AC_PINSENSE_ELDV); |
| @@ -1313,7 +1511,7 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) | |||
| 1313 | codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid); | 1511 | codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid); |
| 1314 | 1512 | ||
| 1315 | if (eld->eld_valid) { | 1513 | if (eld->eld_valid) { |
| 1316 | if (snd_hdmi_get_eld(codec, pin_nid, eld->eld_buffer, | 1514 | if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer, |
| 1317 | &eld->eld_size) < 0) | 1515 | &eld->eld_size) < 0) |
| 1318 | eld->eld_valid = false; | 1516 | eld->eld_valid = false; |
| 1319 | else { | 1517 | else { |
| @@ -1331,11 +1529,10 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) | |||
| 1331 | queue_delayed_work(codec->bus->workq, | 1529 | queue_delayed_work(codec->bus->workq, |
| 1332 | &per_pin->work, | 1530 | &per_pin->work, |
| 1333 | msecs_to_jiffies(300)); | 1531 | msecs_to_jiffies(300)); |
| 1334 | return; | 1532 | goto unlock; |
| 1335 | } | 1533 | } |
| 1336 | } | 1534 | } |
| 1337 | 1535 | ||
| 1338 | mutex_lock(&pin_eld->lock); | ||
| 1339 | if (pin_eld->eld_valid && !eld->eld_valid) { | 1536 | if (pin_eld->eld_valid && !eld->eld_valid) { |
| 1340 | update_eld = true; | 1537 | update_eld = true; |
| 1341 | eld_changed = true; | 1538 | eld_changed = true; |
| @@ -1352,20 +1549,29 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) | |||
| 1352 | pin_eld->eld_size = eld->eld_size; | 1549 | pin_eld->eld_size = eld->eld_size; |
| 1353 | pin_eld->info = eld->info; | 1550 | pin_eld->info = eld->info; |
| 1354 | 1551 | ||
| 1355 | /* Haswell-specific workaround: re-setup when the transcoder is | 1552 | /* |
| 1356 | * changed during the stream playback | 1553 | * Re-setup pin and infoframe. This is needed e.g. when |
| 1554 | * - sink is first plugged-in (infoframe is not set up if !monitor_present) | ||
| 1555 | * - transcoder can change during stream playback on Haswell | ||
| 1357 | */ | 1556 | */ |
| 1358 | if (is_haswell(codec) && | 1557 | if (eld->eld_valid && !old_eld_valid && per_pin->setup) |
| 1359 | eld->eld_valid && !old_eld_valid && per_pin->setup) | ||
| 1360 | hdmi_setup_audio_infoframe(codec, per_pin, | 1558 | hdmi_setup_audio_infoframe(codec, per_pin, |
| 1361 | per_pin->non_pcm); | 1559 | per_pin->non_pcm); |
| 1362 | } | 1560 | } |
| 1363 | mutex_unlock(&pin_eld->lock); | ||
| 1364 | 1561 | ||
| 1365 | if (eld_changed) | 1562 | if (eld_changed) |
| 1366 | snd_ctl_notify(codec->bus->card, | 1563 | snd_ctl_notify(codec->bus->card, |
| 1367 | SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, | 1564 | SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, |
| 1368 | &per_pin->eld_ctl->id); | 1565 | &per_pin->eld_ctl->id); |
| 1566 | unlock: | ||
| 1567 | ret = !repoll || !pin_eld->monitor_present || pin_eld->eld_valid; | ||
| 1568 | |||
| 1569 | jack = snd_hda_jack_tbl_get(codec, pin_nid); | ||
| 1570 | if (jack) | ||
| 1571 | jack->block_report = !ret; | ||
| 1572 | |||
| 1573 | mutex_unlock(&per_pin->lock); | ||
| 1574 | return ret; | ||
| 1369 | } | 1575 | } |
| 1370 | 1576 | ||
| 1371 | static void hdmi_repoll_eld(struct work_struct *work) | 1577 | static void hdmi_repoll_eld(struct work_struct *work) |
| @@ -1376,7 +1582,8 @@ static void hdmi_repoll_eld(struct work_struct *work) | |||
| 1376 | if (per_pin->repoll_count++ > 6) | 1582 | if (per_pin->repoll_count++ > 6) |
| 1377 | per_pin->repoll_count = 0; | 1583 | per_pin->repoll_count = 0; |
| 1378 | 1584 | ||
| 1379 | hdmi_present_sense(per_pin, per_pin->repoll_count); | 1585 | if (hdmi_present_sense(per_pin, per_pin->repoll_count)) |
| 1586 | snd_hda_jack_report_sync(per_pin->codec); | ||
| 1380 | } | 1587 | } |
| 1381 | 1588 | ||
| 1382 | static void intel_haswell_fixup_connect_list(struct hda_codec *codec, | 1589 | static void intel_haswell_fixup_connect_list(struct hda_codec *codec, |
| @@ -1536,14 +1743,14 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
| 1536 | bool non_pcm; | 1743 | bool non_pcm; |
| 1537 | 1744 | ||
| 1538 | non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); | 1745 | non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); |
| 1746 | mutex_lock(&per_pin->lock); | ||
| 1539 | per_pin->channels = substream->runtime->channels; | 1747 | per_pin->channels = substream->runtime->channels; |
| 1540 | per_pin->setup = true; | 1748 | per_pin->setup = true; |
| 1541 | 1749 | ||
| 1542 | hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels); | ||
| 1543 | |||
| 1544 | hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); | 1750 | hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); |
| 1751 | mutex_unlock(&per_pin->lock); | ||
| 1545 | 1752 | ||
| 1546 | return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); | 1753 | return spec->ops.setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); |
| 1547 | } | 1754 | } |
| 1548 | 1755 | ||
| 1549 | static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | 1756 | static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| @@ -1579,11 +1786,14 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo, | |||
| 1579 | per_pin = get_pin(spec, pin_idx); | 1786 | per_pin = get_pin(spec, pin_idx); |
| 1580 | 1787 | ||
| 1581 | snd_hda_spdif_ctls_unassign(codec, pin_idx); | 1788 | snd_hda_spdif_ctls_unassign(codec, pin_idx); |
| 1789 | |||
| 1790 | mutex_lock(&per_pin->lock); | ||
| 1582 | per_pin->chmap_set = false; | 1791 | per_pin->chmap_set = false; |
| 1583 | memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); | 1792 | memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); |
| 1584 | 1793 | ||
| 1585 | per_pin->setup = false; | 1794 | per_pin->setup = false; |
| 1586 | per_pin->channels = 0; | 1795 | per_pin->channels = 0; |
| 1796 | mutex_unlock(&per_pin->lock); | ||
| 1587 | } | 1797 | } |
| 1588 | 1798 | ||
| 1589 | return 0; | 1799 | return 0; |
| @@ -1612,14 +1822,40 @@ static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol, | |||
| 1612 | return 0; | 1822 | return 0; |
| 1613 | } | 1823 | } |
| 1614 | 1824 | ||
| 1825 | static int hdmi_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap, | ||
| 1826 | int channels) | ||
| 1827 | { | ||
| 1828 | /* If the speaker allocation matches the channel count, it is OK.*/ | ||
| 1829 | if (cap->channels != channels) | ||
| 1830 | return -1; | ||
| 1831 | |||
| 1832 | /* all channels are remappable freely */ | ||
| 1833 | return SNDRV_CTL_TLVT_CHMAP_VAR; | ||
| 1834 | } | ||
| 1835 | |||
| 1836 | static void hdmi_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap, | ||
| 1837 | unsigned int *chmap, int channels) | ||
| 1838 | { | ||
| 1839 | int count = 0; | ||
| 1840 | int c; | ||
| 1841 | |||
| 1842 | for (c = 7; c >= 0; c--) { | ||
| 1843 | int spk = cap->speakers[c]; | ||
| 1844 | if (!spk) | ||
| 1845 | continue; | ||
| 1846 | |||
| 1847 | chmap[count++] = spk_to_chmap(spk); | ||
| 1848 | } | ||
| 1849 | |||
| 1850 | WARN_ON(count != channels); | ||
| 1851 | } | ||
| 1852 | |||
| 1615 | static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, | 1853 | static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1616 | unsigned int size, unsigned int __user *tlv) | 1854 | unsigned int size, unsigned int __user *tlv) |
| 1617 | { | 1855 | { |
| 1618 | struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); | 1856 | struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); |
| 1619 | struct hda_codec *codec = info->private_data; | 1857 | struct hda_codec *codec = info->private_data; |
| 1620 | struct hdmi_spec *spec = codec->spec; | 1858 | struct hdmi_spec *spec = codec->spec; |
| 1621 | const unsigned int valid_mask = | ||
| 1622 | FL | FR | RL | RR | LFE | FC | RLC | RRC; | ||
| 1623 | unsigned int __user *dst; | 1859 | unsigned int __user *dst; |
| 1624 | int chs, count = 0; | 1860 | int chs, count = 0; |
| 1625 | 1861 | ||
| @@ -1630,18 +1866,19 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
| 1630 | size -= 8; | 1866 | size -= 8; |
| 1631 | dst = tlv + 2; | 1867 | dst = tlv + 2; |
| 1632 | for (chs = 2; chs <= spec->channels_max; chs++) { | 1868 | for (chs = 2; chs <= spec->channels_max; chs++) { |
| 1633 | int i, c; | 1869 | int i; |
| 1634 | struct cea_channel_speaker_allocation *cap; | 1870 | struct cea_channel_speaker_allocation *cap; |
| 1635 | cap = channel_allocations; | 1871 | cap = channel_allocations; |
| 1636 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) { | 1872 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) { |
| 1637 | int chs_bytes = chs * 4; | 1873 | int chs_bytes = chs * 4; |
| 1638 | if (cap->channels != chs) | 1874 | int type = spec->ops.chmap_cea_alloc_validate_get_type(cap, chs); |
| 1639 | continue; | 1875 | unsigned int tlv_chmap[8]; |
| 1640 | if (cap->spk_mask & ~valid_mask) | 1876 | |
| 1877 | if (type < 0) | ||
| 1641 | continue; | 1878 | continue; |
| 1642 | if (size < 8) | 1879 | if (size < 8) |
| 1643 | return -ENOMEM; | 1880 | return -ENOMEM; |
| 1644 | if (put_user(SNDRV_CTL_TLVT_CHMAP_VAR, dst) || | 1881 | if (put_user(type, dst) || |
| 1645 | put_user(chs_bytes, dst + 1)) | 1882 | put_user(chs_bytes, dst + 1)) |
| 1646 | return -EFAULT; | 1883 | return -EFAULT; |
| 1647 | dst += 2; | 1884 | dst += 2; |
| @@ -1651,14 +1888,10 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
| 1651 | return -ENOMEM; | 1888 | return -ENOMEM; |
| 1652 | size -= chs_bytes; | 1889 | size -= chs_bytes; |
| 1653 | count += chs_bytes; | 1890 | count += chs_bytes; |
| 1654 | for (c = 7; c >= 0; c--) { | 1891 | spec->ops.cea_alloc_to_tlv_chmap(cap, tlv_chmap, chs); |
| 1655 | int spk = cap->speakers[c]; | 1892 | if (copy_to_user(dst, tlv_chmap, chs_bytes)) |
| 1656 | if (!spk) | 1893 | return -EFAULT; |
| 1657 | continue; | 1894 | dst += chs; |
| 1658 | if (put_user(spk_to_chmap(spk), dst)) | ||
| 1659 | return -EFAULT; | ||
| 1660 | dst++; | ||
| 1661 | } | ||
| 1662 | } | 1895 | } |
| 1663 | } | 1896 | } |
| 1664 | if (put_user(count, tlv + 1)) | 1897 | if (put_user(count, tlv + 1)) |
| @@ -1692,7 +1925,7 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, | |||
| 1692 | unsigned int ctl_idx; | 1925 | unsigned int ctl_idx; |
| 1693 | struct snd_pcm_substream *substream; | 1926 | struct snd_pcm_substream *substream; |
| 1694 | unsigned char chmap[8]; | 1927 | unsigned char chmap[8]; |
| 1695 | int i, ca, prepared = 0; | 1928 | int i, err, ca, prepared = 0; |
| 1696 | 1929 | ||
| 1697 | ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 1930 | ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 1698 | substream = snd_pcm_chmap_substream(info, ctl_idx); | 1931 | substream = snd_pcm_chmap_substream(info, ctl_idx); |
| @@ -1716,10 +1949,17 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, | |||
| 1716 | ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap); | 1949 | ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap); |
| 1717 | if (ca < 0) | 1950 | if (ca < 0) |
| 1718 | return -EINVAL; | 1951 | return -EINVAL; |
| 1952 | if (spec->ops.chmap_validate) { | ||
| 1953 | err = spec->ops.chmap_validate(ca, ARRAY_SIZE(chmap), chmap); | ||
| 1954 | if (err) | ||
| 1955 | return err; | ||
| 1956 | } | ||
| 1957 | mutex_lock(&per_pin->lock); | ||
| 1719 | per_pin->chmap_set = true; | 1958 | per_pin->chmap_set = true; |
| 1720 | memcpy(per_pin->chmap, chmap, sizeof(chmap)); | 1959 | memcpy(per_pin->chmap, chmap, sizeof(chmap)); |
| 1721 | if (prepared) | 1960 | if (prepared) |
| 1722 | hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); | 1961 | hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); |
| 1962 | mutex_unlock(&per_pin->lock); | ||
| 1723 | 1963 | ||
| 1724 | return 0; | 1964 | return 0; |
| 1725 | } | 1965 | } |
| @@ -1836,12 +2076,11 @@ static int generic_hdmi_init_per_pins(struct hda_codec *codec) | |||
| 1836 | 2076 | ||
| 1837 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 2077 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
| 1838 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); | 2078 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
| 1839 | struct hdmi_eld *eld = &per_pin->sink_eld; | ||
| 1840 | 2079 | ||
| 1841 | per_pin->codec = codec; | 2080 | per_pin->codec = codec; |
| 1842 | mutex_init(&eld->lock); | 2081 | mutex_init(&per_pin->lock); |
| 1843 | INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); | 2082 | INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); |
| 1844 | snd_hda_eld_proc_new(codec, eld, pin_idx); | 2083 | eld_proc_new(per_pin, pin_idx); |
| 1845 | } | 2084 | } |
| 1846 | return 0; | 2085 | return 0; |
| 1847 | } | 2086 | } |
| @@ -1882,10 +2121,9 @@ static void generic_hdmi_free(struct hda_codec *codec) | |||
| 1882 | 2121 | ||
| 1883 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 2122 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
| 1884 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); | 2123 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
| 1885 | struct hdmi_eld *eld = &per_pin->sink_eld; | ||
| 1886 | 2124 | ||
| 1887 | cancel_delayed_work(&per_pin->work); | 2125 | cancel_delayed_work(&per_pin->work); |
| 1888 | snd_hda_eld_proc_free(codec, eld); | 2126 | eld_proc_free(per_pin); |
| 1889 | } | 2127 | } |
| 1890 | 2128 | ||
| 1891 | flush_workqueue(codec->bus->workq); | 2129 | flush_workqueue(codec->bus->workq); |
| @@ -1922,6 +2160,17 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = { | |||
| 1922 | #endif | 2160 | #endif |
| 1923 | }; | 2161 | }; |
| 1924 | 2162 | ||
| 2163 | static const struct hdmi_ops generic_standard_hdmi_ops = { | ||
| 2164 | .pin_get_eld = snd_hdmi_get_eld, | ||
| 2165 | .pin_get_slot_channel = hdmi_pin_get_slot_channel, | ||
| 2166 | .pin_set_slot_channel = hdmi_pin_set_slot_channel, | ||
| 2167 | .pin_setup_infoframe = hdmi_pin_setup_infoframe, | ||
| 2168 | .pin_hbr_setup = hdmi_pin_hbr_setup, | ||
| 2169 | .setup_stream = hdmi_setup_stream, | ||
| 2170 | .chmap_cea_alloc_validate_get_type = hdmi_chmap_cea_alloc_validate_get_type, | ||
| 2171 | .cea_alloc_to_tlv_chmap = hdmi_cea_alloc_to_tlv_chmap, | ||
| 2172 | }; | ||
| 2173 | |||
| 1925 | 2174 | ||
| 1926 | static void intel_haswell_fixup_connect_list(struct hda_codec *codec, | 2175 | static void intel_haswell_fixup_connect_list(struct hda_codec *codec, |
| 1927 | hda_nid_t nid) | 2176 | hda_nid_t nid) |
| @@ -2004,6 +2253,7 @@ static int patch_generic_hdmi(struct hda_codec *codec) | |||
| 2004 | if (spec == NULL) | 2253 | if (spec == NULL) |
| 2005 | return -ENOMEM; | 2254 | return -ENOMEM; |
| 2006 | 2255 | ||
| 2256 | spec->ops = generic_standard_hdmi_ops; | ||
| 2007 | codec->spec = spec; | 2257 | codec->spec = spec; |
| 2008 | hdmi_array_init(spec, 4); | 2258 | hdmi_array_init(spec, 4); |
| 2009 | 2259 | ||
| @@ -2559,49 +2809,398 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) | |||
| 2559 | } | 2809 | } |
| 2560 | 2810 | ||
| 2561 | /* | 2811 | /* |
| 2562 | * ATI-specific implementations | 2812 | * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on: |
| 2563 | * | 2813 | * - 0x10de0015 |
| 2564 | * FIXME: we may omit the whole this and use the generic code once after | 2814 | * - 0x10de0040 |
| 2565 | * it's confirmed to work. | 2815 | */ |
| 2816 | static int nvhdmi_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap, | ||
| 2817 | int channels) | ||
| 2818 | { | ||
| 2819 | if (cap->ca_index == 0x00 && channels == 2) | ||
| 2820 | return SNDRV_CTL_TLVT_CHMAP_FIXED; | ||
| 2821 | |||
| 2822 | return hdmi_chmap_cea_alloc_validate_get_type(cap, channels); | ||
| 2823 | } | ||
| 2824 | |||
| 2825 | static int nvhdmi_chmap_validate(int ca, int chs, unsigned char *map) | ||
| 2826 | { | ||
| 2827 | if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR)) | ||
| 2828 | return -EINVAL; | ||
| 2829 | |||
| 2830 | return 0; | ||
| 2831 | } | ||
| 2832 | |||
| 2833 | static int patch_nvhdmi(struct hda_codec *codec) | ||
| 2834 | { | ||
| 2835 | struct hdmi_spec *spec; | ||
| 2836 | int err; | ||
| 2837 | |||
| 2838 | err = patch_generic_hdmi(codec); | ||
| 2839 | if (err) | ||
| 2840 | return err; | ||
| 2841 | |||
| 2842 | spec = codec->spec; | ||
| 2843 | |||
| 2844 | spec->ops.chmap_cea_alloc_validate_get_type = | ||
| 2845 | nvhdmi_chmap_cea_alloc_validate_get_type; | ||
| 2846 | spec->ops.chmap_validate = nvhdmi_chmap_validate; | ||
| 2847 | |||
| 2848 | return 0; | ||
| 2849 | } | ||
| 2850 | |||
| 2851 | /* | ||
| 2852 | * ATI/AMD-specific implementations | ||
| 2566 | */ | 2853 | */ |
| 2567 | 2854 | ||
| 2568 | #define ATIHDMI_CVT_NID 0x02 /* audio converter */ | 2855 | #define is_amdhdmi_rev3_or_later(codec) \ |
| 2569 | #define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */ | 2856 | ((codec)->vendor_id == 0x1002aa01 && ((codec)->revision_id & 0xff00) >= 0x0300) |
| 2857 | #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) | ||
| 2570 | 2858 | ||
| 2571 | static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 2859 | /* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */ |
| 2572 | struct hda_codec *codec, | 2860 | #define ATI_VERB_SET_CHANNEL_ALLOCATION 0x771 |
| 2573 | unsigned int stream_tag, | 2861 | #define ATI_VERB_SET_DOWNMIX_INFO 0x772 |
| 2574 | unsigned int format, | 2862 | #define ATI_VERB_SET_MULTICHANNEL_01 0x777 |
| 2575 | struct snd_pcm_substream *substream) | 2863 | #define ATI_VERB_SET_MULTICHANNEL_23 0x778 |
| 2864 | #define ATI_VERB_SET_MULTICHANNEL_45 0x779 | ||
| 2865 | #define ATI_VERB_SET_MULTICHANNEL_67 0x77a | ||
| 2866 | #define ATI_VERB_SET_HBR_CONTROL 0x77c | ||
| 2867 | #define ATI_VERB_SET_MULTICHANNEL_1 0x785 | ||
| 2868 | #define ATI_VERB_SET_MULTICHANNEL_3 0x786 | ||
| 2869 | #define ATI_VERB_SET_MULTICHANNEL_5 0x787 | ||
| 2870 | #define ATI_VERB_SET_MULTICHANNEL_7 0x788 | ||
| 2871 | #define ATI_VERB_SET_MULTICHANNEL_MODE 0x789 | ||
| 2872 | #define ATI_VERB_GET_CHANNEL_ALLOCATION 0xf71 | ||
| 2873 | #define ATI_VERB_GET_DOWNMIX_INFO 0xf72 | ||
| 2874 | #define ATI_VERB_GET_MULTICHANNEL_01 0xf77 | ||
| 2875 | #define ATI_VERB_GET_MULTICHANNEL_23 0xf78 | ||
| 2876 | #define ATI_VERB_GET_MULTICHANNEL_45 0xf79 | ||
| 2877 | #define ATI_VERB_GET_MULTICHANNEL_67 0xf7a | ||
| 2878 | #define ATI_VERB_GET_HBR_CONTROL 0xf7c | ||
| 2879 | #define ATI_VERB_GET_MULTICHANNEL_1 0xf85 | ||
| 2880 | #define ATI_VERB_GET_MULTICHANNEL_3 0xf86 | ||
| 2881 | #define ATI_VERB_GET_MULTICHANNEL_5 0xf87 | ||
| 2882 | #define ATI_VERB_GET_MULTICHANNEL_7 0xf88 | ||
| 2883 | #define ATI_VERB_GET_MULTICHANNEL_MODE 0xf89 | ||
| 2884 | |||
| 2885 | /* AMD specific HDA cvt verbs */ | ||
| 2886 | #define ATI_VERB_SET_RAMP_RATE 0x770 | ||
| 2887 | #define ATI_VERB_GET_RAMP_RATE 0xf70 | ||
| 2888 | |||
| 2889 | #define ATI_OUT_ENABLE 0x1 | ||
| 2890 | |||
| 2891 | #define ATI_MULTICHANNEL_MODE_PAIRED 0 | ||
| 2892 | #define ATI_MULTICHANNEL_MODE_SINGLE 1 | ||
| 2893 | |||
| 2894 | #define ATI_HBR_CAPABLE 0x01 | ||
| 2895 | #define ATI_HBR_ENABLE 0x10 | ||
| 2896 | |||
| 2897 | static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, | ||
| 2898 | unsigned char *buf, int *eld_size) | ||
| 2899 | { | ||
| 2900 | /* call hda_eld.c ATI/AMD-specific function */ | ||
| 2901 | return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, | ||
| 2902 | is_amdhdmi_rev3_or_later(codec)); | ||
| 2903 | } | ||
| 2904 | |||
| 2905 | static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca, | ||
| 2906 | int active_channels, int conn_type) | ||
| 2907 | { | ||
| 2908 | snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); | ||
| 2909 | } | ||
| 2910 | |||
| 2911 | static int atihdmi_paired_swap_fc_lfe(int pos) | ||
| 2912 | { | ||
| 2913 | /* | ||
| 2914 | * ATI/AMD have automatic FC/LFE swap built-in | ||
| 2915 | * when in pairwise mapping mode. | ||
| 2916 | */ | ||
| 2917 | |||
| 2918 | switch (pos) { | ||
| 2919 | /* see channel_allocations[].speakers[] */ | ||
| 2920 | case 2: return 3; | ||
| 2921 | case 3: return 2; | ||
| 2922 | default: break; | ||
| 2923 | } | ||
| 2924 | |||
| 2925 | return pos; | ||
| 2926 | } | ||
| 2927 | |||
| 2928 | static int atihdmi_paired_chmap_validate(int ca, int chs, unsigned char *map) | ||
| 2929 | { | ||
| 2930 | struct cea_channel_speaker_allocation *cap; | ||
| 2931 | int i, j; | ||
| 2932 | |||
| 2933 | /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ | ||
| 2934 | |||
| 2935 | cap = &channel_allocations[get_channel_allocation_order(ca)]; | ||
| 2936 | for (i = 0; i < chs; ++i) { | ||
| 2937 | int mask = to_spk_mask(map[i]); | ||
| 2938 | bool ok = false; | ||
| 2939 | bool companion_ok = false; | ||
| 2940 | |||
| 2941 | if (!mask) | ||
| 2942 | continue; | ||
| 2943 | |||
| 2944 | for (j = 0 + i % 2; j < 8; j += 2) { | ||
| 2945 | int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); | ||
| 2946 | if (cap->speakers[chan_idx] == mask) { | ||
| 2947 | /* channel is in a supported position */ | ||
| 2948 | ok = true; | ||
| 2949 | |||
| 2950 | if (i % 2 == 0 && i + 1 < chs) { | ||
| 2951 | /* even channel, check the odd companion */ | ||
| 2952 | int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); | ||
| 2953 | int comp_mask_req = to_spk_mask(map[i+1]); | ||
| 2954 | int comp_mask_act = cap->speakers[comp_chan_idx]; | ||
| 2955 | |||
| 2956 | if (comp_mask_req == comp_mask_act) | ||
| 2957 | companion_ok = true; | ||
| 2958 | else | ||
| 2959 | return -EINVAL; | ||
| 2960 | } | ||
| 2961 | break; | ||
| 2962 | } | ||
| 2963 | } | ||
| 2964 | |||
| 2965 | if (!ok) | ||
| 2966 | return -EINVAL; | ||
| 2967 | |||
| 2968 | if (companion_ok) | ||
| 2969 | i++; /* companion channel already checked */ | ||
| 2970 | } | ||
| 2971 | |||
| 2972 | return 0; | ||
| 2973 | } | ||
| 2974 | |||
| 2975 | static int atihdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 2976 | int hdmi_slot, int stream_channel) | ||
| 2977 | { | ||
| 2978 | int verb; | ||
| 2979 | int ati_channel_setup = 0; | ||
| 2980 | |||
| 2981 | if (hdmi_slot > 7) | ||
| 2982 | return -EINVAL; | ||
| 2983 | |||
| 2984 | if (!has_amd_full_remap_support(codec)) { | ||
| 2985 | hdmi_slot = atihdmi_paired_swap_fc_lfe(hdmi_slot); | ||
| 2986 | |||
| 2987 | /* In case this is an odd slot but without stream channel, do not | ||
| 2988 | * disable the slot since the corresponding even slot could have a | ||
| 2989 | * channel. In case neither have a channel, the slot pair will be | ||
| 2990 | * disabled when this function is called for the even slot. */ | ||
| 2991 | if (hdmi_slot % 2 != 0 && stream_channel == 0xf) | ||
| 2992 | return 0; | ||
| 2993 | |||
| 2994 | hdmi_slot -= hdmi_slot % 2; | ||
| 2995 | |||
| 2996 | if (stream_channel != 0xf) | ||
| 2997 | stream_channel -= stream_channel % 2; | ||
| 2998 | } | ||
| 2999 | |||
| 3000 | verb = ATI_VERB_SET_MULTICHANNEL_01 + hdmi_slot/2 + (hdmi_slot % 2) * 0x00e; | ||
| 3001 | |||
| 3002 | /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */ | ||
| 3003 | |||
| 3004 | if (stream_channel != 0xf) | ||
| 3005 | ati_channel_setup = (stream_channel << 4) | ATI_OUT_ENABLE; | ||
| 3006 | |||
| 3007 | return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); | ||
| 3008 | } | ||
| 3009 | |||
| 3010 | static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 3011 | int asp_slot) | ||
| 3012 | { | ||
| 3013 | bool was_odd = false; | ||
| 3014 | int ati_asp_slot = asp_slot; | ||
| 3015 | int verb; | ||
| 3016 | int ati_channel_setup; | ||
| 3017 | |||
| 3018 | if (asp_slot > 7) | ||
| 3019 | return -EINVAL; | ||
| 3020 | |||
| 3021 | if (!has_amd_full_remap_support(codec)) { | ||
| 3022 | ati_asp_slot = atihdmi_paired_swap_fc_lfe(asp_slot); | ||
| 3023 | if (ati_asp_slot % 2 != 0) { | ||
| 3024 | ati_asp_slot -= 1; | ||
| 3025 | was_odd = true; | ||
| 3026 | } | ||
| 3027 | } | ||
| 3028 | |||
| 3029 | verb = ATI_VERB_GET_MULTICHANNEL_01 + ati_asp_slot/2 + (ati_asp_slot % 2) * 0x00e; | ||
| 3030 | |||
| 3031 | ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); | ||
| 3032 | |||
| 3033 | if (!(ati_channel_setup & ATI_OUT_ENABLE)) | ||
| 3034 | return 0xf; | ||
| 3035 | |||
| 3036 | return ((ati_channel_setup & 0xf0) >> 4) + !!was_odd; | ||
| 3037 | } | ||
| 3038 | |||
| 3039 | static int atihdmi_paired_chmap_cea_alloc_validate_get_type(struct cea_channel_speaker_allocation *cap, | ||
| 3040 | int channels) | ||
| 3041 | { | ||
| 3042 | int c; | ||
| 3043 | |||
| 3044 | /* | ||
| 3045 | * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so | ||
| 3046 | * we need to take that into account (a single channel may take 2 | ||
| 3047 | * channel slots if we need to carry a silent channel next to it). | ||
| 3048 | * On Rev3+ AMD codecs this function is not used. | ||
| 3049 | */ | ||
| 3050 | int chanpairs = 0; | ||
| 3051 | |||
| 3052 | /* We only produce even-numbered channel count TLVs */ | ||
| 3053 | if ((channels % 2) != 0) | ||
| 3054 | return -1; | ||
| 3055 | |||
| 3056 | for (c = 0; c < 7; c += 2) { | ||
| 3057 | if (cap->speakers[c] || cap->speakers[c+1]) | ||
| 3058 | chanpairs++; | ||
| 3059 | } | ||
| 3060 | |||
| 3061 | if (chanpairs * 2 != channels) | ||
| 3062 | return -1; | ||
| 3063 | |||
| 3064 | return SNDRV_CTL_TLVT_CHMAP_PAIRED; | ||
| 3065 | } | ||
| 3066 | |||
| 3067 | static void atihdmi_paired_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap, | ||
| 3068 | unsigned int *chmap, int channels) | ||
| 3069 | { | ||
| 3070 | /* produce paired maps for pre-rev3 ATI/AMD codecs */ | ||
| 3071 | int count = 0; | ||
| 3072 | int c; | ||
| 3073 | |||
| 3074 | for (c = 7; c >= 0; c--) { | ||
| 3075 | int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); | ||
| 3076 | int spk = cap->speakers[chan]; | ||
| 3077 | if (!spk) { | ||
| 3078 | /* add N/A channel if the companion channel is occupied */ | ||
| 3079 | if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) | ||
| 3080 | chmap[count++] = SNDRV_CHMAP_NA; | ||
| 3081 | |||
| 3082 | continue; | ||
| 3083 | } | ||
| 3084 | |||
| 3085 | chmap[count++] = spk_to_chmap(spk); | ||
| 3086 | } | ||
| 3087 | |||
| 3088 | WARN_ON(count != channels); | ||
| 3089 | } | ||
| 3090 | |||
| 3091 | static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, | ||
| 3092 | bool hbr) | ||
| 3093 | { | ||
| 3094 | int hbr_ctl, hbr_ctl_new; | ||
| 3095 | |||
| 3096 | hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); | ||
| 3097 | if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) { | ||
| 3098 | if (hbr) | ||
| 3099 | hbr_ctl_new = hbr_ctl | ATI_HBR_ENABLE; | ||
| 3100 | else | ||
| 3101 | hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE; | ||
| 3102 | |||
| 3103 | snd_printdd("atihdmi_pin_hbr_setup: " | ||
| 3104 | "NID=0x%x, %shbr-ctl=0x%x\n", | ||
| 3105 | pin_nid, | ||
| 3106 | hbr_ctl == hbr_ctl_new ? "" : "new-", | ||
| 3107 | hbr_ctl_new); | ||
| 3108 | |||
| 3109 | if (hbr_ctl != hbr_ctl_new) | ||
| 3110 | snd_hda_codec_write(codec, pin_nid, 0, | ||
| 3111 | ATI_VERB_SET_HBR_CONTROL, | ||
| 3112 | hbr_ctl_new); | ||
| 3113 | |||
| 3114 | } else if (hbr) | ||
| 3115 | return -EINVAL; | ||
| 3116 | |||
| 3117 | return 0; | ||
| 3118 | } | ||
| 3119 | |||
| 3120 | static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, | ||
| 3121 | hda_nid_t pin_nid, u32 stream_tag, int format) | ||
| 3122 | { | ||
| 3123 | |||
| 3124 | if (is_amdhdmi_rev3_or_later(codec)) { | ||
| 3125 | int ramp_rate = 180; /* default as per AMD spec */ | ||
| 3126 | /* disable ramp-up/down for non-pcm as per AMD spec */ | ||
| 3127 | if (format & AC_FMT_TYPE_NON_PCM) | ||
| 3128 | ramp_rate = 0; | ||
| 3129 | |||
| 3130 | snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); | ||
| 3131 | } | ||
| 3132 | |||
| 3133 | return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); | ||
| 3134 | } | ||
| 3135 | |||
| 3136 | |||
| 3137 | static int atihdmi_init(struct hda_codec *codec) | ||
| 2576 | { | 3138 | { |
| 2577 | struct hdmi_spec *spec = codec->spec; | 3139 | struct hdmi_spec *spec = codec->spec; |
| 2578 | struct hdmi_spec_per_cvt *per_cvt = get_cvt(spec, 0); | 3140 | int pin_idx, err; |
| 2579 | int chans = substream->runtime->channels; | ||
| 2580 | int i, err; | ||
| 2581 | 3141 | ||
| 2582 | err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format, | 3142 | err = generic_hdmi_init(codec); |
| 2583 | substream); | 3143 | |
| 2584 | if (err < 0) | 3144 | if (err) |
| 2585 | return err; | 3145 | return err; |
| 2586 | snd_hda_codec_write(codec, per_cvt->cvt_nid, 0, | 3146 | |
| 2587 | AC_VERB_SET_CVT_CHAN_COUNT, chans - 1); | 3147 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
| 2588 | /* FIXME: XXX */ | 3148 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
| 2589 | for (i = 0; i < chans; i++) { | 3149 | |
| 2590 | snd_hda_codec_write(codec, per_cvt->cvt_nid, 0, | 3150 | /* make sure downmix information in infoframe is zero */ |
| 2591 | AC_VERB_SET_HDMI_CHAN_SLOT, | 3151 | snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); |
| 2592 | (i << 4) | i); | 3152 | |
| 3153 | /* enable channel-wise remap mode if supported */ | ||
| 3154 | if (has_amd_full_remap_support(codec)) | ||
| 3155 | snd_hda_codec_write(codec, per_pin->pin_nid, 0, | ||
| 3156 | ATI_VERB_SET_MULTICHANNEL_MODE, | ||
| 3157 | ATI_MULTICHANNEL_MODE_SINGLE); | ||
| 2593 | } | 3158 | } |
| 3159 | |||
| 2594 | return 0; | 3160 | return 0; |
| 2595 | } | 3161 | } |
| 2596 | 3162 | ||
| 2597 | static int patch_atihdmi(struct hda_codec *codec) | 3163 | static int patch_atihdmi(struct hda_codec *codec) |
| 2598 | { | 3164 | { |
| 2599 | struct hdmi_spec *spec; | 3165 | struct hdmi_spec *spec; |
| 2600 | int err = patch_simple_hdmi(codec, ATIHDMI_CVT_NID, ATIHDMI_PIN_NID); | 3166 | struct hdmi_spec_per_cvt *per_cvt; |
| 2601 | if (err < 0) | 3167 | int err, cvt_idx; |
| 3168 | |||
| 3169 | err = patch_generic_hdmi(codec); | ||
| 3170 | |||
| 3171 | if (err) | ||
| 2602 | return err; | 3172 | return err; |
| 3173 | |||
| 3174 | codec->patch_ops.init = atihdmi_init; | ||
| 3175 | |||
| 2603 | spec = codec->spec; | 3176 | spec = codec->spec; |
| 2604 | spec->pcm_playback.ops.prepare = atihdmi_playback_pcm_prepare; | 3177 | |
| 3178 | spec->ops.pin_get_eld = atihdmi_pin_get_eld; | ||
| 3179 | spec->ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; | ||
| 3180 | spec->ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; | ||
| 3181 | spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; | ||
| 3182 | spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; | ||
| 3183 | spec->ops.setup_stream = atihdmi_setup_stream; | ||
| 3184 | |||
| 3185 | if (!has_amd_full_remap_support(codec)) { | ||
| 3186 | /* override to ATI/AMD-specific versions with pairwise mapping */ | ||
| 3187 | spec->ops.chmap_cea_alloc_validate_get_type = | ||
| 3188 | atihdmi_paired_chmap_cea_alloc_validate_get_type; | ||
| 3189 | spec->ops.cea_alloc_to_tlv_chmap = atihdmi_paired_cea_alloc_to_tlv_chmap; | ||
| 3190 | spec->ops.chmap_validate = atihdmi_paired_chmap_validate; | ||
| 3191 | } | ||
| 3192 | |||
| 3193 | /* ATI/AMD converters do not advertise all of their capabilities */ | ||
| 3194 | for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { | ||
| 3195 | per_cvt = get_cvt(spec, cvt_idx); | ||
| 3196 | per_cvt->channels_max = max(per_cvt->channels_max, 8u); | ||
| 3197 | per_cvt->rates |= SUPPORTED_RATES; | ||
| 3198 | per_cvt->formats |= SUPPORTED_FORMATS; | ||
| 3199 | per_cvt->maxbps = max(per_cvt->maxbps, 24u); | ||
| 3200 | } | ||
| 3201 | |||
| 3202 | spec->channels_max = max(spec->channels_max, 8u); | ||
| 3203 | |||
| 2605 | return 0; | 3204 | return 0; |
| 2606 | } | 3205 | } |
| 2607 | 3206 | ||
| @@ -2621,7 +3220,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { | |||
| 2621 | { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, | 3220 | { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, |
| 2622 | { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, | 3221 | { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, |
| 2623 | { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, | 3222 | { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, |
| 2624 | { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_generic_hdmi }, | 3223 | { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, |
| 2625 | { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi }, | 3224 | { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi }, |
| 2626 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi }, | 3225 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi }, |
| 2627 | { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi }, | 3226 | { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi }, |
| @@ -2630,30 +3229,30 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { | |||
| 2630 | { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, | 3229 | { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, |
| 2631 | { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, | 3230 | { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, |
| 2632 | { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, | 3231 | { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, |
| 2633 | { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_generic_hdmi }, | 3232 | { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi }, |
| 2634 | { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_generic_hdmi }, | 3233 | { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi }, |
| 2635 | { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_generic_hdmi }, | 3234 | { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi }, |
| 2636 | { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_generic_hdmi }, | 3235 | { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi }, |
| 2637 | { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_generic_hdmi }, | 3236 | { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi }, |
| 2638 | { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_generic_hdmi }, | 3237 | { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi }, |
| 2639 | { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_generic_hdmi }, | 3238 | { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi }, |
| 2640 | { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_generic_hdmi }, | 3239 | { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi }, |
| 2641 | { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_generic_hdmi }, | 3240 | { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi }, |
| 2642 | { .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_generic_hdmi }, | 3241 | { .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_nvhdmi }, |
| 2643 | { .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_generic_hdmi }, | 3242 | { .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_nvhdmi }, |
| 2644 | /* 17 is known to be absent */ | 3243 | /* 17 is known to be absent */ |
| 2645 | { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_generic_hdmi }, | 3244 | { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi }, |
| 2646 | { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_generic_hdmi }, | 3245 | { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi }, |
| 2647 | { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_generic_hdmi }, | 3246 | { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi }, |
| 2648 | { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_generic_hdmi }, | 3247 | { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi }, |
| 2649 | { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_generic_hdmi }, | 3248 | { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi }, |
| 2650 | { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_generic_hdmi }, | 3249 | { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi }, |
| 2651 | { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_generic_hdmi }, | 3250 | { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi }, |
| 2652 | { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_generic_hdmi }, | 3251 | { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi }, |
| 2653 | { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi }, | 3252 | { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi }, |
| 2654 | { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi }, | 3253 | { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi }, |
| 2655 | { .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi }, | 3254 | { .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_nvhdmi }, |
| 2656 | { .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi }, | 3255 | { .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_nvhdmi }, |
| 2657 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, | 3256 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
| 2658 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, | 3257 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, |
| 2659 | { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, | 3258 | { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, |
| @@ -2669,6 +3268,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { | |||
| 2669 | { .id = 0x80862806, .name = "PantherPoint HDMI", .patch = patch_generic_hdmi }, | 3268 | { .id = 0x80862806, .name = "PantherPoint HDMI", .patch = patch_generic_hdmi }, |
| 2670 | { .id = 0x80862807, .name = "Haswell HDMI", .patch = patch_generic_hdmi }, | 3269 | { .id = 0x80862807, .name = "Haswell HDMI", .patch = patch_generic_hdmi }, |
| 2671 | { .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi }, | 3270 | { .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi }, |
| 3271 | { .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi }, | ||
| 2672 | { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, | 3272 | { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, |
| 2673 | {} /* terminator */ | 3273 | {} /* terminator */ |
| 2674 | }; | 3274 | }; |
| @@ -2723,6 +3323,7 @@ MODULE_ALIAS("snd-hda-codec-id:80862805"); | |||
| 2723 | MODULE_ALIAS("snd-hda-codec-id:80862806"); | 3323 | MODULE_ALIAS("snd-hda-codec-id:80862806"); |
| 2724 | MODULE_ALIAS("snd-hda-codec-id:80862807"); | 3324 | MODULE_ALIAS("snd-hda-codec-id:80862807"); |
| 2725 | MODULE_ALIAS("snd-hda-codec-id:80862880"); | 3325 | MODULE_ALIAS("snd-hda-codec-id:80862880"); |
| 3326 | MODULE_ALIAS("snd-hda-codec-id:80862882"); | ||
| 2726 | MODULE_ALIAS("snd-hda-codec-id:808629fb"); | 3327 | MODULE_ALIAS("snd-hda-codec-id:808629fb"); |
| 2727 | 3328 | ||
| 2728 | MODULE_LICENSE("GPL"); | 3329 | MODULE_LICENSE("GPL"); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 8ad554312b69..bb653dd0f813 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -554,8 +554,6 @@ do_sku: | |||
| 554 | nid = portd; | 554 | nid = portd; |
| 555 | else if (tmp == 3) | 555 | else if (tmp == 3) |
| 556 | nid = porti; | 556 | nid = porti; |
| 557 | else | ||
| 558 | return 1; | ||
| 559 | if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins, | 557 | if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins, |
| 560 | spec->gen.autocfg.line_outs)) | 558 | spec->gen.autocfg.line_outs)) |
| 561 | return 1; | 559 | return 1; |
| @@ -579,26 +577,35 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) | |||
| 579 | /* | 577 | /* |
| 580 | * COEF access helper functions | 578 | * COEF access helper functions |
| 581 | */ | 579 | */ |
| 582 | static int alc_read_coef_idx(struct hda_codec *codec, | 580 | |
| 583 | unsigned int coef_idx) | 581 | static int alc_read_coefex_idx(struct hda_codec *codec, |
| 582 | hda_nid_t nid, | ||
| 583 | unsigned int coef_idx) | ||
| 584 | { | 584 | { |
| 585 | unsigned int val; | 585 | unsigned int val; |
| 586 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, | 586 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, |
| 587 | coef_idx); | 587 | coef_idx); |
| 588 | val = snd_hda_codec_read(codec, 0x20, 0, | 588 | val = snd_hda_codec_read(codec, nid, 0, |
| 589 | AC_VERB_GET_PROC_COEF, 0); | 589 | AC_VERB_GET_PROC_COEF, 0); |
| 590 | return val; | 590 | return val; |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, | 593 | #define alc_read_coef_idx(codec, coef_idx) \ |
| 594 | alc_read_coefex_idx(codec, 0x20, coef_idx) | ||
| 595 | |||
| 596 | static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, | ||
| 597 | unsigned int coef_idx, | ||
| 594 | unsigned int coef_val) | 598 | unsigned int coef_val) |
| 595 | { | 599 | { |
| 596 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, | 600 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, |
| 597 | coef_idx); | 601 | coef_idx); |
| 598 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, | 602 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, |
| 599 | coef_val); | 603 | coef_val); |
| 600 | } | 604 | } |
| 601 | 605 | ||
| 606 | #define alc_write_coef_idx(codec, coef_idx, coef_val) \ | ||
| 607 | alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val) | ||
| 608 | |||
| 602 | /* a special bypass for COEF 0; read the cached value at the second time */ | 609 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 603 | static unsigned int alc_get_coef0(struct hda_codec *codec) | 610 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 604 | { | 611 | { |
| @@ -831,7 +838,11 @@ static inline void alc_shutup(struct hda_codec *codec) | |||
| 831 | snd_hda_shutup_pins(codec); | 838 | snd_hda_shutup_pins(codec); |
| 832 | } | 839 | } |
| 833 | 840 | ||
| 834 | #define alc_free snd_hda_gen_free | 841 | static void alc_free(struct hda_codec *codec) |
| 842 | { | ||
| 843 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); | ||
| 844 | snd_hda_gen_free(codec); | ||
| 845 | } | ||
| 835 | 846 | ||
| 836 | #ifdef CONFIG_PM | 847 | #ifdef CONFIG_PM |
| 837 | static void alc_power_eapd(struct hda_codec *codec) | 848 | static void alc_power_eapd(struct hda_codec *codec) |
| @@ -1043,6 +1054,7 @@ enum { | |||
| 1043 | ALC880_FIXUP_UNIWILL, | 1054 | ALC880_FIXUP_UNIWILL, |
| 1044 | ALC880_FIXUP_UNIWILL_DIG, | 1055 | ALC880_FIXUP_UNIWILL_DIG, |
| 1045 | ALC880_FIXUP_Z71V, | 1056 | ALC880_FIXUP_Z71V, |
| 1057 | ALC880_FIXUP_ASUS_W5A, | ||
| 1046 | ALC880_FIXUP_3ST_BASE, | 1058 | ALC880_FIXUP_3ST_BASE, |
| 1047 | ALC880_FIXUP_3ST, | 1059 | ALC880_FIXUP_3ST, |
| 1048 | ALC880_FIXUP_3ST_DIG, | 1060 | ALC880_FIXUP_3ST_DIG, |
| @@ -1213,6 +1225,26 @@ static const struct hda_fixup alc880_fixups[] = { | |||
| 1213 | { } | 1225 | { } |
| 1214 | } | 1226 | } |
| 1215 | }, | 1227 | }, |
| 1228 | [ALC880_FIXUP_ASUS_W5A] = { | ||
| 1229 | .type = HDA_FIXUP_PINS, | ||
| 1230 | .v.pins = (const struct hda_pintbl[]) { | ||
| 1231 | /* set up the whole pins as BIOS is utterly broken */ | ||
| 1232 | { 0x14, 0x0121411f }, /* HP */ | ||
| 1233 | { 0x15, 0x411111f0 }, /* N/A */ | ||
| 1234 | { 0x16, 0x411111f0 }, /* N/A */ | ||
| 1235 | { 0x17, 0x411111f0 }, /* N/A */ | ||
| 1236 | { 0x18, 0x90a60160 }, /* mic */ | ||
| 1237 | { 0x19, 0x411111f0 }, /* N/A */ | ||
| 1238 | { 0x1a, 0x411111f0 }, /* N/A */ | ||
| 1239 | { 0x1b, 0x411111f0 }, /* N/A */ | ||
| 1240 | { 0x1c, 0x411111f0 }, /* N/A */ | ||
| 1241 | { 0x1d, 0x411111f0 }, /* N/A */ | ||
| 1242 | { 0x1e, 0xb743111e }, /* SPDIF out */ | ||
| 1243 | { } | ||
| 1244 | }, | ||
| 1245 | .chained = true, | ||
| 1246 | .chain_id = ALC880_FIXUP_GPIO1, | ||
| 1247 | }, | ||
| 1216 | [ALC880_FIXUP_3ST_BASE] = { | 1248 | [ALC880_FIXUP_3ST_BASE] = { |
| 1217 | .type = HDA_FIXUP_PINS, | 1249 | .type = HDA_FIXUP_PINS, |
| 1218 | .v.pins = (const struct hda_pintbl[]) { | 1250 | .v.pins = (const struct hda_pintbl[]) { |
| @@ -1334,6 +1366,7 @@ static const struct hda_fixup alc880_fixups[] = { | |||
| 1334 | 1366 | ||
| 1335 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { | 1367 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
| 1336 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), | 1368 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
| 1369 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A), | ||
| 1337 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), | 1370 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
| 1338 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), | 1371 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 1339 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), | 1372 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
| @@ -1627,6 +1660,7 @@ static const struct snd_pci_quirk alc260_fixup_tbl[] = { | |||
| 1627 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), | 1660 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
| 1628 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), | 1661 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
| 1629 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), | 1662 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
| 1663 | SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F), | ||
| 1630 | SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020), | 1664 | SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020), |
| 1631 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), | 1665 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
| 1632 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), | 1666 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
| @@ -2388,6 +2422,7 @@ static const struct hda_verb alc268_beep_init_verbs[] = { | |||
| 2388 | enum { | 2422 | enum { |
| 2389 | ALC268_FIXUP_INV_DMIC, | 2423 | ALC268_FIXUP_INV_DMIC, |
| 2390 | ALC268_FIXUP_HP_EAPD, | 2424 | ALC268_FIXUP_HP_EAPD, |
| 2425 | ALC268_FIXUP_SPDIF, | ||
| 2391 | }; | 2426 | }; |
| 2392 | 2427 | ||
| 2393 | static const struct hda_fixup alc268_fixups[] = { | 2428 | static const struct hda_fixup alc268_fixups[] = { |
| @@ -2402,6 +2437,13 @@ static const struct hda_fixup alc268_fixups[] = { | |||
| 2402 | {} | 2437 | {} |
| 2403 | } | 2438 | } |
| 2404 | }, | 2439 | }, |
| 2440 | [ALC268_FIXUP_SPDIF] = { | ||
| 2441 | .type = HDA_FIXUP_PINS, | ||
| 2442 | .v.pins = (const struct hda_pintbl[]) { | ||
| 2443 | { 0x1e, 0x014b1180 }, /* enable SPDIF out */ | ||
| 2444 | {} | ||
| 2445 | } | ||
| 2446 | }, | ||
| 2405 | }; | 2447 | }; |
| 2406 | 2448 | ||
| 2407 | static const struct hda_model_fixup alc268_fixup_models[] = { | 2449 | static const struct hda_model_fixup alc268_fixup_models[] = { |
| @@ -2411,6 +2453,7 @@ static const struct hda_model_fixup alc268_fixup_models[] = { | |||
| 2411 | }; | 2453 | }; |
| 2412 | 2454 | ||
| 2413 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { | 2455 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 2456 | SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF), | ||
| 2414 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC), | 2457 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC), |
| 2415 | /* below is codec SSID since multiple Toshiba laptops have the | 2458 | /* below is codec SSID since multiple Toshiba laptops have the |
| 2416 | * same PCI SSID 1179:ff00 | 2459 | * same PCI SSID 1179:ff00 |
| @@ -2539,7 +2582,9 @@ enum { | |||
| 2539 | ALC269_TYPE_ALC282, | 2582 | ALC269_TYPE_ALC282, |
| 2540 | ALC269_TYPE_ALC283, | 2583 | ALC269_TYPE_ALC283, |
| 2541 | ALC269_TYPE_ALC284, | 2584 | ALC269_TYPE_ALC284, |
| 2585 | ALC269_TYPE_ALC285, | ||
| 2542 | ALC269_TYPE_ALC286, | 2586 | ALC269_TYPE_ALC286, |
| 2587 | ALC269_TYPE_ALC255, | ||
| 2543 | }; | 2588 | }; |
| 2544 | 2589 | ||
| 2545 | /* | 2590 | /* |
| @@ -2558,6 +2603,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
| 2558 | case ALC269_TYPE_ALC269VC: | 2603 | case ALC269_TYPE_ALC269VC: |
| 2559 | case ALC269_TYPE_ALC280: | 2604 | case ALC269_TYPE_ALC280: |
| 2560 | case ALC269_TYPE_ALC284: | 2605 | case ALC269_TYPE_ALC284: |
| 2606 | case ALC269_TYPE_ALC285: | ||
| 2561 | ssids = alc269va_ssids; | 2607 | ssids = alc269va_ssids; |
| 2562 | break; | 2608 | break; |
| 2563 | case ALC269_TYPE_ALC269VB: | 2609 | case ALC269_TYPE_ALC269VB: |
| @@ -2565,6 +2611,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
| 2565 | case ALC269_TYPE_ALC282: | 2611 | case ALC269_TYPE_ALC282: |
| 2566 | case ALC269_TYPE_ALC283: | 2612 | case ALC269_TYPE_ALC283: |
| 2567 | case ALC269_TYPE_ALC286: | 2613 | case ALC269_TYPE_ALC286: |
| 2614 | case ALC269_TYPE_ALC255: | ||
| 2568 | ssids = alc269_ssids; | 2615 | ssids = alc269_ssids; |
| 2569 | break; | 2616 | break; |
| 2570 | default: | 2617 | default: |
| @@ -2652,7 +2699,7 @@ static void alc283_shutup(struct hda_codec *codec) | |||
| 2652 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | 2699 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); |
| 2653 | 2700 | ||
| 2654 | if (hp_pin_sense) | 2701 | if (hp_pin_sense) |
| 2655 | msleep(85); | 2702 | msleep(100); |
| 2656 | 2703 | ||
| 2657 | snd_hda_codec_write(codec, hp_pin, 0, | 2704 | snd_hda_codec_write(codec, hp_pin, 0, |
| 2658 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); | 2705 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); |
| @@ -2661,7 +2708,7 @@ static void alc283_shutup(struct hda_codec *codec) | |||
| 2661 | alc_write_coef_idx(codec, 0x46, val | (3 << 12)); | 2708 | alc_write_coef_idx(codec, 0x46, val | (3 << 12)); |
| 2662 | 2709 | ||
| 2663 | if (hp_pin_sense) | 2710 | if (hp_pin_sense) |
| 2664 | msleep(85); | 2711 | msleep(100); |
| 2665 | snd_hda_shutup_pins(codec); | 2712 | snd_hda_shutup_pins(codec); |
| 2666 | alc_write_coef_idx(codec, 0x43, 0x9614); | 2713 | alc_write_coef_idx(codec, 0x43, 0x9614); |
| 2667 | } | 2714 | } |
| @@ -2944,6 +2991,23 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) | |||
| 2944 | snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); | 2991 | snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); |
| 2945 | } | 2992 | } |
| 2946 | 2993 | ||
| 2994 | /* Make sure the led works even in runtime suspend */ | ||
| 2995 | static unsigned int led_power_filter(struct hda_codec *codec, | ||
| 2996 | hda_nid_t nid, | ||
| 2997 | unsigned int power_state) | ||
| 2998 | { | ||
| 2999 | struct alc_spec *spec = codec->spec; | ||
| 3000 | |||
| 3001 | if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid) | ||
| 3002 | return power_state; | ||
| 3003 | |||
| 3004 | /* Set pin ctl again, it might have just been set to 0 */ | ||
| 3005 | snd_hda_set_pin_ctl(codec, nid, | ||
| 3006 | snd_hda_codec_get_pin_target(codec, nid)); | ||
| 3007 | |||
| 3008 | return AC_PWRST_D0; | ||
| 3009 | } | ||
| 3010 | |||
| 2947 | static void alc269_fixup_hp_mute_led(struct hda_codec *codec, | 3011 | static void alc269_fixup_hp_mute_led(struct hda_codec *codec, |
| 2948 | const struct hda_fixup *fix, int action) | 3012 | const struct hda_fixup *fix, int action) |
| 2949 | { | 3013 | { |
| @@ -2963,6 +3027,7 @@ static void alc269_fixup_hp_mute_led(struct hda_codec *codec, | |||
| 2963 | spec->mute_led_nid = pin - 0x0a + 0x18; | 3027 | spec->mute_led_nid = pin - 0x0a + 0x18; |
| 2964 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; | 3028 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; |
| 2965 | spec->gen.vmaster_mute_enum = 1; | 3029 | spec->gen.vmaster_mute_enum = 1; |
| 3030 | codec->power_filter = led_power_filter; | ||
| 2966 | snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid, | 3031 | snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid, |
| 2967 | spec->mute_led_polarity); | 3032 | spec->mute_led_polarity); |
| 2968 | break; | 3033 | break; |
| @@ -2978,6 +3043,7 @@ static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec, | |||
| 2978 | spec->mute_led_nid = 0x18; | 3043 | spec->mute_led_nid = 0x18; |
| 2979 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; | 3044 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; |
| 2980 | spec->gen.vmaster_mute_enum = 1; | 3045 | spec->gen.vmaster_mute_enum = 1; |
| 3046 | codec->power_filter = led_power_filter; | ||
| 2981 | } | 3047 | } |
| 2982 | } | 3048 | } |
| 2983 | 3049 | ||
| @@ -2990,6 +3056,7 @@ static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec, | |||
| 2990 | spec->mute_led_nid = 0x19; | 3056 | spec->mute_led_nid = 0x19; |
| 2991 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; | 3057 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; |
| 2992 | spec->gen.vmaster_mute_enum = 1; | 3058 | spec->gen.vmaster_mute_enum = 1; |
| 3059 | codec->power_filter = led_power_filter; | ||
| 2993 | } | 3060 | } |
| 2994 | } | 3061 | } |
| 2995 | 3062 | ||
| @@ -3052,6 +3119,19 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) | |||
| 3052 | int val; | 3119 | int val; |
| 3053 | 3120 | ||
| 3054 | switch (codec->vendor_id) { | 3121 | switch (codec->vendor_id) { |
| 3122 | case 0x10ec0255: | ||
| 3123 | /* LDO and MISC control */ | ||
| 3124 | alc_write_coef_idx(codec, 0x1b, 0x0c0b); | ||
| 3125 | /* UAJ function set to menual mode */ | ||
| 3126 | alc_write_coef_idx(codec, 0x45, 0xd089); | ||
| 3127 | /* Direct Drive HP Amp control(Set to verb control)*/ | ||
| 3128 | val = alc_read_coefex_idx(codec, 0x57, 0x05); | ||
| 3129 | alc_write_coefex_idx(codec, 0x57, 0x05, val & ~(1<<14)); | ||
| 3130 | /* Set MIC2 Vref gate with HP */ | ||
| 3131 | alc_write_coef_idx(codec, 0x06, 0x6104); | ||
| 3132 | /* Direct Drive HP Amp control */ | ||
| 3133 | alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6); | ||
| 3134 | break; | ||
| 3055 | case 0x10ec0283: | 3135 | case 0x10ec0283: |
| 3056 | alc_write_coef_idx(codec, 0x1b, 0x0c0b); | 3136 | alc_write_coef_idx(codec, 0x1b, 0x0c0b); |
| 3057 | alc_write_coef_idx(codec, 0x45, 0xc429); | 3137 | alc_write_coef_idx(codec, 0x45, 0xc429); |
| @@ -3083,6 +3163,14 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, | |||
| 3083 | int val; | 3163 | int val; |
| 3084 | 3164 | ||
| 3085 | switch (codec->vendor_id) { | 3165 | switch (codec->vendor_id) { |
| 3166 | case 0x10ec0255: | ||
| 3167 | alc_write_coef_idx(codec, 0x45, 0xc489); | ||
| 3168 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | ||
| 3169 | alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6); | ||
| 3170 | /* Set MIC2 Vref gate to normal */ | ||
| 3171 | alc_write_coef_idx(codec, 0x06, 0x6100); | ||
| 3172 | snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); | ||
| 3173 | break; | ||
| 3086 | case 0x10ec0283: | 3174 | case 0x10ec0283: |
| 3087 | alc_write_coef_idx(codec, 0x45, 0xc429); | 3175 | alc_write_coef_idx(codec, 0x45, 0xc429); |
| 3088 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | 3176 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); |
| @@ -3114,6 +3202,12 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, | |||
| 3114 | static void alc_headset_mode_default(struct hda_codec *codec) | 3202 | static void alc_headset_mode_default(struct hda_codec *codec) |
| 3115 | { | 3203 | { |
| 3116 | switch (codec->vendor_id) { | 3204 | switch (codec->vendor_id) { |
| 3205 | case 0x10ec0255: | ||
| 3206 | alc_write_coef_idx(codec, 0x45, 0xc089); | ||
| 3207 | alc_write_coef_idx(codec, 0x45, 0xc489); | ||
| 3208 | alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); | ||
| 3209 | alc_write_coef_idx(codec, 0x49, 0x0049); | ||
| 3210 | break; | ||
| 3117 | case 0x10ec0283: | 3211 | case 0x10ec0283: |
| 3118 | alc_write_coef_idx(codec, 0x06, 0x2100); | 3212 | alc_write_coef_idx(codec, 0x06, 0x2100); |
| 3119 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | 3213 | alc_write_coef_idx(codec, 0x32, 0x4ea3); |
| @@ -3137,6 +3231,12 @@ static void alc_headset_mode_default(struct hda_codec *codec) | |||
| 3137 | static void alc_headset_mode_ctia(struct hda_codec *codec) | 3231 | static void alc_headset_mode_ctia(struct hda_codec *codec) |
| 3138 | { | 3232 | { |
| 3139 | switch (codec->vendor_id) { | 3233 | switch (codec->vendor_id) { |
| 3234 | case 0x10ec0255: | ||
| 3235 | /* Set to CTIA type */ | ||
| 3236 | alc_write_coef_idx(codec, 0x45, 0xd489); | ||
| 3237 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | ||
| 3238 | alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); | ||
| 3239 | break; | ||
| 3140 | case 0x10ec0283: | 3240 | case 0x10ec0283: |
| 3141 | alc_write_coef_idx(codec, 0x45, 0xd429); | 3241 | alc_write_coef_idx(codec, 0x45, 0xd429); |
| 3142 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | 3242 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); |
| @@ -3159,6 +3259,12 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) | |||
| 3159 | static void alc_headset_mode_omtp(struct hda_codec *codec) | 3259 | static void alc_headset_mode_omtp(struct hda_codec *codec) |
| 3160 | { | 3260 | { |
| 3161 | switch (codec->vendor_id) { | 3261 | switch (codec->vendor_id) { |
| 3262 | case 0x10ec0255: | ||
| 3263 | /* Set to OMTP Type */ | ||
| 3264 | alc_write_coef_idx(codec, 0x45, 0xe489); | ||
| 3265 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | ||
| 3266 | alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); | ||
| 3267 | break; | ||
| 3162 | case 0x10ec0283: | 3268 | case 0x10ec0283: |
| 3163 | alc_write_coef_idx(codec, 0x45, 0xe429); | 3269 | alc_write_coef_idx(codec, 0x45, 0xe429); |
| 3164 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | 3270 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); |
| @@ -3184,6 +3290,15 @@ static void alc_determine_headset_type(struct hda_codec *codec) | |||
| 3184 | struct alc_spec *spec = codec->spec; | 3290 | struct alc_spec *spec = codec->spec; |
| 3185 | 3291 | ||
| 3186 | switch (codec->vendor_id) { | 3292 | switch (codec->vendor_id) { |
| 3293 | case 0x10ec0255: | ||
| 3294 | /* combo jack auto switch control(Check type)*/ | ||
| 3295 | alc_write_coef_idx(codec, 0x45, 0xd089); | ||
| 3296 | /* combo jack auto switch control(Vref conteol) */ | ||
| 3297 | alc_write_coef_idx(codec, 0x49, 0x0149); | ||
| 3298 | msleep(300); | ||
| 3299 | val = alc_read_coef_idx(codec, 0x46); | ||
| 3300 | is_ctia = (val & 0x0070) == 0x0070; | ||
| 3301 | break; | ||
| 3187 | case 0x10ec0283: | 3302 | case 0x10ec0283: |
| 3188 | alc_write_coef_idx(codec, 0x45, 0xd029); | 3303 | alc_write_coef_idx(codec, 0x45, 0xd029); |
| 3189 | msleep(300); | 3304 | msleep(300); |
| @@ -3230,8 +3345,10 @@ static void alc_update_headset_mode(struct hda_codec *codec) | |||
| 3230 | else | 3345 | else |
| 3231 | new_headset_mode = ALC_HEADSET_MODE_HEADPHONE; | 3346 | new_headset_mode = ALC_HEADSET_MODE_HEADPHONE; |
| 3232 | 3347 | ||
| 3233 | if (new_headset_mode == spec->current_headset_mode) | 3348 | if (new_headset_mode == spec->current_headset_mode) { |
| 3349 | snd_hda_gen_update_outputs(codec); | ||
| 3234 | return; | 3350 | return; |
| 3351 | } | ||
| 3235 | 3352 | ||
| 3236 | switch (new_headset_mode) { | 3353 | switch (new_headset_mode) { |
| 3237 | case ALC_HEADSET_MODE_UNPLUGGED: | 3354 | case ALC_HEADSET_MODE_UNPLUGGED: |
| @@ -3330,6 +3447,21 @@ static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, | |||
| 3330 | alc_fixup_headset_mode(codec, fix, action); | 3447 | alc_fixup_headset_mode(codec, fix, action); |
| 3331 | } | 3448 | } |
| 3332 | 3449 | ||
| 3450 | static void alc_fixup_headset_mode_alc255(struct hda_codec *codec, | ||
| 3451 | const struct hda_fixup *fix, int action) | ||
| 3452 | { | ||
| 3453 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
| 3454 | /* Set to iphone type */ | ||
| 3455 | alc_write_coef_idx(codec, 0x1b, 0x880b); | ||
| 3456 | alc_write_coef_idx(codec, 0x45, 0xd089); | ||
| 3457 | alc_write_coef_idx(codec, 0x1b, 0x080b); | ||
| 3458 | alc_write_coef_idx(codec, 0x46, 0x0004); | ||
| 3459 | alc_write_coef_idx(codec, 0x1b, 0x0c0b); | ||
| 3460 | msleep(30); | ||
| 3461 | } | ||
| 3462 | alc_fixup_headset_mode(codec, fix, action); | ||
| 3463 | } | ||
| 3464 | |||
| 3333 | static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, | 3465 | static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, |
| 3334 | const struct hda_fixup *fix, int action) | 3466 | const struct hda_fixup *fix, int action) |
| 3335 | { | 3467 | { |
| @@ -3443,7 +3575,11 @@ static void alc283_fixup_chromebook(struct hda_codec *codec, | |||
| 3443 | switch (action) { | 3575 | switch (action) { |
| 3444 | case HDA_FIXUP_ACT_PRE_PROBE: | 3576 | case HDA_FIXUP_ACT_PRE_PROBE: |
| 3445 | alc283_chromebook_caps(codec); | 3577 | alc283_chromebook_caps(codec); |
| 3578 | /* Disable AA-loopback as it causes white noise */ | ||
| 3579 | spec->gen.mixer_nid = 0; | ||
| 3446 | spec->gen.hp_automute_hook = alc283_hp_automute_hook; | 3580 | spec->gen.hp_automute_hook = alc283_hp_automute_hook; |
| 3581 | break; | ||
| 3582 | case HDA_FIXUP_ACT_INIT: | ||
| 3447 | /* MIC2-VREF control */ | 3583 | /* MIC2-VREF control */ |
| 3448 | /* Set to manual mode */ | 3584 | /* Set to manual mode */ |
| 3449 | val = alc_read_coef_idx(codec, 0x06); | 3585 | val = alc_read_coef_idx(codec, 0x06); |
| @@ -3514,6 +3650,96 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec, | |||
| 3514 | snd_hda_override_wcaps(codec, 0x03, 0); | 3650 | snd_hda_override_wcaps(codec, 0x03, 0); |
| 3515 | } | 3651 | } |
| 3516 | 3652 | ||
| 3653 | #if IS_ENABLED(CONFIG_THINKPAD_ACPI) | ||
| 3654 | |||
| 3655 | #include <linux/thinkpad_acpi.h> | ||
| 3656 | #include <acpi/acpi.h> | ||
| 3657 | |||
| 3658 | static int (*led_set_func)(int, bool); | ||
| 3659 | |||
| 3660 | static acpi_status acpi_check_cb(acpi_handle handle, u32 lvl, void *context, | ||
| 3661 | void **rv) | ||
| 3662 | { | ||
| 3663 | bool *found = context; | ||
| 3664 | *found = true; | ||
| 3665 | return AE_OK; | ||
| 3666 | } | ||
| 3667 | |||
| 3668 | static bool is_thinkpad(struct hda_codec *codec) | ||
| 3669 | { | ||
| 3670 | bool found = false; | ||
| 3671 | if (codec->subsystem_id >> 16 != 0x17aa) | ||
| 3672 | return false; | ||
| 3673 | if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found) | ||
| 3674 | return true; | ||
| 3675 | found = false; | ||
| 3676 | return ACPI_SUCCESS(acpi_get_devices("IBM0068", acpi_check_cb, &found, NULL)) && found; | ||
| 3677 | } | ||
| 3678 | |||
| 3679 | static void update_tpacpi_mute_led(void *private_data, int enabled) | ||
| 3680 | { | ||
| 3681 | if (led_set_func) | ||
| 3682 | led_set_func(TPACPI_LED_MUTE, !enabled); | ||
| 3683 | } | ||
| 3684 | |||
| 3685 | static void update_tpacpi_micmute_led(struct hda_codec *codec, | ||
| 3686 | struct snd_ctl_elem_value *ucontrol) | ||
| 3687 | { | ||
| 3688 | if (!ucontrol || !led_set_func) | ||
| 3689 | return; | ||
| 3690 | if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) { | ||
| 3691 | /* TODO: How do I verify if it's a mono or stereo here? */ | ||
| 3692 | bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]; | ||
| 3693 | led_set_func(TPACPI_LED_MICMUTE, !val); | ||
| 3694 | } | ||
| 3695 | } | ||
| 3696 | |||
| 3697 | static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, | ||
| 3698 | const struct hda_fixup *fix, int action) | ||
| 3699 | { | ||
| 3700 | struct alc_spec *spec = codec->spec; | ||
| 3701 | bool removefunc = false; | ||
| 3702 | |||
| 3703 | if (action == HDA_FIXUP_ACT_PROBE) { | ||
| 3704 | if (!is_thinkpad(codec)) | ||
| 3705 | return; | ||
| 3706 | if (!led_set_func) | ||
| 3707 | led_set_func = symbol_request(tpacpi_led_set); | ||
| 3708 | if (!led_set_func) { | ||
| 3709 | snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n"); | ||
| 3710 | return; | ||
| 3711 | } | ||
| 3712 | |||
| 3713 | removefunc = true; | ||
| 3714 | if (led_set_func(TPACPI_LED_MUTE, false) >= 0) { | ||
| 3715 | spec->gen.vmaster_mute.hook = update_tpacpi_mute_led; | ||
| 3716 | removefunc = false; | ||
| 3717 | } | ||
| 3718 | if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { | ||
| 3719 | if (spec->gen.num_adc_nids > 1) | ||
| 3720 | snd_printdd("Skipping micmute LED control due to several ADCs"); | ||
| 3721 | else { | ||
| 3722 | spec->gen.cap_sync_hook = update_tpacpi_micmute_led; | ||
| 3723 | removefunc = false; | ||
| 3724 | } | ||
| 3725 | } | ||
| 3726 | } | ||
| 3727 | |||
| 3728 | if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) { | ||
| 3729 | symbol_put(tpacpi_led_set); | ||
| 3730 | led_set_func = NULL; | ||
| 3731 | } | ||
| 3732 | } | ||
| 3733 | |||
| 3734 | #else | ||
| 3735 | |||
| 3736 | static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, | ||
| 3737 | const struct hda_fixup *fix, int action) | ||
| 3738 | { | ||
| 3739 | } | ||
| 3740 | |||
| 3741 | #endif | ||
| 3742 | |||
| 3517 | enum { | 3743 | enum { |
| 3518 | ALC269_FIXUP_SONY_VAIO, | 3744 | ALC269_FIXUP_SONY_VAIO, |
| 3519 | ALC275_FIXUP_SONY_VAIO_GPIO2, | 3745 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| @@ -3552,11 +3778,15 @@ enum { | |||
| 3552 | ALC271_FIXUP_HP_GATE_MIC_JACK, | 3778 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
| 3553 | ALC269_FIXUP_ACER_AC700, | 3779 | ALC269_FIXUP_ACER_AC700, |
| 3554 | ALC269_FIXUP_LIMIT_INT_MIC_BOOST, | 3780 | ALC269_FIXUP_LIMIT_INT_MIC_BOOST, |
| 3781 | ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED, | ||
| 3555 | ALC269VB_FIXUP_ORDISSIMO_EVE2, | 3782 | ALC269VB_FIXUP_ORDISSIMO_EVE2, |
| 3556 | ALC283_FIXUP_CHROME_BOOK, | 3783 | ALC283_FIXUP_CHROME_BOOK, |
| 3557 | ALC282_FIXUP_ASUS_TX300, | 3784 | ALC282_FIXUP_ASUS_TX300, |
| 3558 | ALC283_FIXUP_INT_MIC, | 3785 | ALC283_FIXUP_INT_MIC, |
| 3559 | ALC290_FIXUP_MONO_SPEAKERS, | 3786 | ALC290_FIXUP_MONO_SPEAKERS, |
| 3787 | ALC269_FIXUP_THINKPAD_ACPI, | ||
| 3788 | ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, | ||
| 3789 | ALC255_FIXUP_HEADSET_MODE, | ||
| 3560 | }; | 3790 | }; |
| 3561 | 3791 | ||
| 3562 | static const struct hda_fixup alc269_fixups[] = { | 3792 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -3716,6 +3946,8 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 3716 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { | 3946 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 3717 | .type = HDA_FIXUP_FUNC, | 3947 | .type = HDA_FIXUP_FUNC, |
| 3718 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, | 3948 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 3949 | .chained = true, | ||
| 3950 | .chain_id = ALC269_FIXUP_THINKPAD_ACPI, | ||
| 3719 | }, | 3951 | }, |
| 3720 | [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { | 3952 | [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { |
| 3721 | .type = HDA_FIXUP_PINS, | 3953 | .type = HDA_FIXUP_PINS, |
| @@ -3820,6 +4052,14 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 3820 | [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { | 4052 | [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { |
| 3821 | .type = HDA_FIXUP_FUNC, | 4053 | .type = HDA_FIXUP_FUNC, |
| 3822 | .v.func = alc269_fixup_limit_int_mic_boost, | 4054 | .v.func = alc269_fixup_limit_int_mic_boost, |
| 4055 | .chained = true, | ||
| 4056 | .chain_id = ALC269_FIXUP_THINKPAD_ACPI, | ||
| 4057 | }, | ||
| 4058 | [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = { | ||
| 4059 | .type = HDA_FIXUP_FUNC, | ||
| 4060 | .v.func = alc269_fixup_limit_int_mic_boost, | ||
| 4061 | .chained = true, | ||
| 4062 | .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1, | ||
| 3823 | }, | 4063 | }, |
| 3824 | [ALC269VB_FIXUP_ORDISSIMO_EVE2] = { | 4064 | [ALC269VB_FIXUP_ORDISSIMO_EVE2] = { |
| 3825 | .type = HDA_FIXUP_PINS, | 4065 | .type = HDA_FIXUP_PINS, |
| @@ -3854,6 +4094,24 @@ static const struct hda_fixup alc269_fixups[] = { | |||
| 3854 | .chained = true, | 4094 | .chained = true, |
| 3855 | .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, | 4095 | .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, |
| 3856 | }, | 4096 | }, |
| 4097 | [ALC269_FIXUP_THINKPAD_ACPI] = { | ||
| 4098 | .type = HDA_FIXUP_FUNC, | ||
| 4099 | .v.func = alc_fixup_thinkpad_acpi, | ||
| 4100 | }, | ||
| 4101 | [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = { | ||
| 4102 | .type = HDA_FIXUP_PINS, | ||
| 4103 | .v.pins = (const struct hda_pintbl[]) { | ||
| 4104 | { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | ||
| 4105 | { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ | ||
| 4106 | { } | ||
| 4107 | }, | ||
| 4108 | .chained = true, | ||
| 4109 | .chain_id = ALC255_FIXUP_HEADSET_MODE | ||
| 4110 | }, | ||
| 4111 | [ALC255_FIXUP_HEADSET_MODE] = { | ||
| 4112 | .type = HDA_FIXUP_FUNC, | ||
| 4113 | .v.func = alc_fixup_headset_mode_alc255, | ||
| 4114 | }, | ||
| 3857 | }; | 4115 | }; |
| 3858 | 4116 | ||
| 3859 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { | 4117 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -3895,13 +4153,17 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 3895 | SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | 4153 | SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 3896 | SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | 4154 | SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 3897 | SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | 4155 | SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4156 | SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
| 3898 | SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS), | 4157 | SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS), |
| 4158 | SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
| 4159 | SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
| 3899 | SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | 4160 | SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
| 3900 | SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | 4161 | SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
| 3901 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), | 4162 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), |
| 3902 | SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), | 4163 | SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), |
| 3903 | SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), | 4164 | SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
| 3904 | SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), | 4165 | SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
| 4166 | SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED), | ||
| 3905 | SND_PCI_QUIRK(0x103c, 0x21ed, "HP Falco Chromebook", ALC283_FIXUP_CHROME_BOOK), | 4167 | SND_PCI_QUIRK(0x103c, 0x21ed, "HP Falco Chromebook", ALC283_FIXUP_CHROME_BOOK), |
| 3906 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), | 4168 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), |
| 3907 | SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), | 4169 | SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), |
| @@ -3945,6 +4207,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { | |||
| 3945 | SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), | 4207 | SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
| 3946 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), | 4208 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
| 3947 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), | 4209 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
| 4210 | SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI), | ||
| 3948 | SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ | 4211 | SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ |
| 3949 | 4212 | ||
| 3950 | #if 0 | 4213 | #if 0 |
| @@ -4125,9 +4388,16 @@ static int patch_alc269(struct hda_codec *codec) | |||
| 4125 | case 0x10ec0292: | 4388 | case 0x10ec0292: |
| 4126 | spec->codec_variant = ALC269_TYPE_ALC284; | 4389 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 4127 | break; | 4390 | break; |
| 4391 | case 0x10ec0285: | ||
| 4392 | case 0x10ec0293: | ||
| 4393 | spec->codec_variant = ALC269_TYPE_ALC285; | ||
| 4394 | break; | ||
| 4128 | case 0x10ec0286: | 4395 | case 0x10ec0286: |
| 4129 | spec->codec_variant = ALC269_TYPE_ALC286; | 4396 | spec->codec_variant = ALC269_TYPE_ALC286; |
| 4130 | break; | 4397 | break; |
| 4398 | case 0x10ec0255: | ||
| 4399 | spec->codec_variant = ALC269_TYPE_ALC255; | ||
| 4400 | break; | ||
| 4131 | } | 4401 | } |
| 4132 | 4402 | ||
| 4133 | if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) { | 4403 | if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) { |
| @@ -4415,6 +4685,25 @@ static void alc272_fixup_mario(struct hda_codec *codec, | |||
| 4415 | "hda_codec: failed to override amp caps for NID 0x2\n"); | 4685 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 4416 | } | 4686 | } |
| 4417 | 4687 | ||
| 4688 | static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = { | ||
| 4689 | { .channels = 2, | ||
| 4690 | .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, | ||
| 4691 | { .channels = 4, | ||
| 4692 | .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, | ||
| 4693 | SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */ | ||
| 4694 | { } | ||
| 4695 | }; | ||
| 4696 | |||
| 4697 | /* override the 2.1 chmap */ | ||
| 4698 | static void alc662_fixup_bass_chmap(struct hda_codec *codec, | ||
| 4699 | const struct hda_fixup *fix, int action) | ||
| 4700 | { | ||
| 4701 | if (action == HDA_FIXUP_ACT_BUILD) { | ||
| 4702 | struct alc_spec *spec = codec->spec; | ||
| 4703 | spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps; | ||
| 4704 | } | ||
| 4705 | } | ||
| 4706 | |||
| 4418 | enum { | 4707 | enum { |
| 4419 | ALC662_FIXUP_ASPIRE, | 4708 | ALC662_FIXUP_ASPIRE, |
| 4420 | ALC662_FIXUP_IDEAPAD, | 4709 | ALC662_FIXUP_IDEAPAD, |
| @@ -4435,6 +4724,9 @@ enum { | |||
| 4435 | ALC662_FIXUP_INV_DMIC, | 4724 | ALC662_FIXUP_INV_DMIC, |
| 4436 | ALC668_FIXUP_DELL_MIC_NO_PRESENCE, | 4725 | ALC668_FIXUP_DELL_MIC_NO_PRESENCE, |
| 4437 | ALC668_FIXUP_HEADSET_MODE, | 4726 | ALC668_FIXUP_HEADSET_MODE, |
| 4727 | ALC662_FIXUP_BASS_CHMAP, | ||
| 4728 | ALC662_FIXUP_BASS_1A, | ||
| 4729 | ALC662_FIXUP_BASS_1A_CHMAP, | ||
| 4438 | }; | 4730 | }; |
| 4439 | 4731 | ||
| 4440 | static const struct hda_fixup alc662_fixups[] = { | 4732 | static const struct hda_fixup alc662_fixups[] = { |
| @@ -4609,6 +4901,25 @@ static const struct hda_fixup alc662_fixups[] = { | |||
| 4609 | .type = HDA_FIXUP_FUNC, | 4901 | .type = HDA_FIXUP_FUNC, |
| 4610 | .v.func = alc_fixup_headset_mode_alc668, | 4902 | .v.func = alc_fixup_headset_mode_alc668, |
| 4611 | }, | 4903 | }, |
| 4904 | [ALC662_FIXUP_BASS_CHMAP] = { | ||
| 4905 | .type = HDA_FIXUP_FUNC, | ||
| 4906 | .v.func = alc662_fixup_bass_chmap, | ||
| 4907 | .chained = true, | ||
| 4908 | .chain_id = ALC662_FIXUP_ASUS_MODE4 | ||
| 4909 | }, | ||
| 4910 | [ALC662_FIXUP_BASS_1A] = { | ||
| 4911 | .type = HDA_FIXUP_PINS, | ||
| 4912 | .v.pins = (const struct hda_pintbl[]) { | ||
| 4913 | {0x1a, 0x80106111}, /* bass speaker */ | ||
| 4914 | {} | ||
| 4915 | }, | ||
| 4916 | }, | ||
| 4917 | [ALC662_FIXUP_BASS_1A_CHMAP] = { | ||
| 4918 | .type = HDA_FIXUP_FUNC, | ||
| 4919 | .v.func = alc662_fixup_bass_chmap, | ||
| 4920 | .chained = true, | ||
| 4921 | .chain_id = ALC662_FIXUP_BASS_1A, | ||
| 4922 | }, | ||
| 4612 | }; | 4923 | }; |
| 4613 | 4924 | ||
| 4614 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { | 4925 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
| @@ -4621,9 +4932,12 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { | |||
| 4621 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), | 4932 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
| 4622 | SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | 4933 | SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), |
| 4623 | SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | 4934 | SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), |
| 4935 | SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | ||
| 4936 | SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | ||
| 4624 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), | 4937 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
| 4625 | SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_ASUS_MODE4), | 4938 | SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP), |
| 4626 | SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_ASUS_MODE4), | 4939 | SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP), |
| 4940 | SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_CHMAP), | ||
| 4627 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), | 4941 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
| 4628 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), | 4942 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
| 4629 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), | 4943 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
| @@ -4842,6 +5156,7 @@ static int patch_alc680(struct hda_codec *codec) | |||
| 4842 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { | 5156 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
| 4843 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, | 5157 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
| 4844 | { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 }, | 5158 | { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 }, |
| 5159 | { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 }, | ||
| 4845 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | 5160 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
| 4846 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, | 5161 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
| 4847 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, | 5162 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
| @@ -4855,9 +5170,11 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
| 4855 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, | 5170 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
| 4856 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, | 5171 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
| 4857 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, | 5172 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
| 5173 | { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 }, | ||
| 4858 | { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 }, | 5174 | { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 }, |
| 4859 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, | 5175 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
| 4860 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, | 5176 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
| 5177 | { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 }, | ||
| 4861 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", | 5178 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
| 4862 | .patch = patch_alc861 }, | 5179 | .patch = patch_alc861 }, |
| 4863 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, | 5180 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index fba0cef1c47f..d2cc0041d9d3 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
| @@ -100,6 +100,7 @@ enum { | |||
| 100 | STAC_92HD83XXX_HEADSET_JACK, | 100 | STAC_92HD83XXX_HEADSET_JACK, |
| 101 | STAC_92HD83XXX_HP, | 101 | STAC_92HD83XXX_HP, |
| 102 | STAC_HP_ENVY_BASS, | 102 | STAC_HP_ENVY_BASS, |
| 103 | STAC_HP_BNB13_EQ, | ||
| 103 | STAC_92HD83XXX_MODELS | 104 | STAC_92HD83XXX_MODELS |
| 104 | }; | 105 | }; |
| 105 | 106 | ||
| @@ -2091,8 +2092,10 @@ static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec, | |||
| 2091 | { | 2092 | { |
| 2092 | struct sigmatel_spec *spec = codec->spec; | 2093 | struct sigmatel_spec *spec = codec->spec; |
| 2093 | 2094 | ||
| 2094 | if (action == HDA_FIXUP_ACT_PRE_PROBE) | 2095 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 2095 | spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ | 2096 | spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ |
| 2097 | codec->bus->avoid_link_reset = 1; | ||
| 2098 | } | ||
| 2096 | } | 2099 | } |
| 2097 | 2100 | ||
| 2098 | static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, | 2101 | static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, |
| @@ -2104,6 +2107,434 @@ static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, | |||
| 2104 | spec->headset_jack = 1; | 2107 | spec->headset_jack = 1; |
| 2105 | } | 2108 | } |
| 2106 | 2109 | ||
| 2110 | static const struct hda_verb hp_bnb13_eq_verbs[] = { | ||
| 2111 | /* 44.1KHz base */ | ||
| 2112 | { 0x22, 0x7A6, 0x3E }, | ||
| 2113 | { 0x22, 0x7A7, 0x68 }, | ||
| 2114 | { 0x22, 0x7A8, 0x17 }, | ||
| 2115 | { 0x22, 0x7A9, 0x3E }, | ||
| 2116 | { 0x22, 0x7AA, 0x68 }, | ||
| 2117 | { 0x22, 0x7AB, 0x17 }, | ||
| 2118 | { 0x22, 0x7AC, 0x00 }, | ||
| 2119 | { 0x22, 0x7AD, 0x80 }, | ||
| 2120 | { 0x22, 0x7A6, 0x83 }, | ||
| 2121 | { 0x22, 0x7A7, 0x2F }, | ||
| 2122 | { 0x22, 0x7A8, 0xD1 }, | ||
| 2123 | { 0x22, 0x7A9, 0x83 }, | ||
| 2124 | { 0x22, 0x7AA, 0x2F }, | ||
| 2125 | { 0x22, 0x7AB, 0xD1 }, | ||
| 2126 | { 0x22, 0x7AC, 0x01 }, | ||
| 2127 | { 0x22, 0x7AD, 0x80 }, | ||
| 2128 | { 0x22, 0x7A6, 0x3E }, | ||
| 2129 | { 0x22, 0x7A7, 0x68 }, | ||
| 2130 | { 0x22, 0x7A8, 0x17 }, | ||
| 2131 | { 0x22, 0x7A9, 0x3E }, | ||
| 2132 | { 0x22, 0x7AA, 0x68 }, | ||
| 2133 | { 0x22, 0x7AB, 0x17 }, | ||
| 2134 | { 0x22, 0x7AC, 0x02 }, | ||
| 2135 | { 0x22, 0x7AD, 0x80 }, | ||
| 2136 | { 0x22, 0x7A6, 0x7C }, | ||
| 2137 | { 0x22, 0x7A7, 0xC6 }, | ||
| 2138 | { 0x22, 0x7A8, 0x0C }, | ||
| 2139 | { 0x22, 0x7A9, 0x7C }, | ||
| 2140 | { 0x22, 0x7AA, 0xC6 }, | ||
| 2141 | { 0x22, 0x7AB, 0x0C }, | ||
| 2142 | { 0x22, 0x7AC, 0x03 }, | ||
| 2143 | { 0x22, 0x7AD, 0x80 }, | ||
| 2144 | { 0x22, 0x7A6, 0xC3 }, | ||
| 2145 | { 0x22, 0x7A7, 0x25 }, | ||
| 2146 | { 0x22, 0x7A8, 0xAF }, | ||
| 2147 | { 0x22, 0x7A9, 0xC3 }, | ||
| 2148 | { 0x22, 0x7AA, 0x25 }, | ||
| 2149 | { 0x22, 0x7AB, 0xAF }, | ||
| 2150 | { 0x22, 0x7AC, 0x04 }, | ||
| 2151 | { 0x22, 0x7AD, 0x80 }, | ||
| 2152 | { 0x22, 0x7A6, 0x3E }, | ||
| 2153 | { 0x22, 0x7A7, 0x85 }, | ||
| 2154 | { 0x22, 0x7A8, 0x73 }, | ||
| 2155 | { 0x22, 0x7A9, 0x3E }, | ||
| 2156 | { 0x22, 0x7AA, 0x85 }, | ||
| 2157 | { 0x22, 0x7AB, 0x73 }, | ||
| 2158 | { 0x22, 0x7AC, 0x05 }, | ||
| 2159 | { 0x22, 0x7AD, 0x80 }, | ||
| 2160 | { 0x22, 0x7A6, 0x85 }, | ||
| 2161 | { 0x22, 0x7A7, 0x39 }, | ||
| 2162 | { 0x22, 0x7A8, 0xC7 }, | ||
| 2163 | { 0x22, 0x7A9, 0x85 }, | ||
| 2164 | { 0x22, 0x7AA, 0x39 }, | ||
| 2165 | { 0x22, 0x7AB, 0xC7 }, | ||
| 2166 | { 0x22, 0x7AC, 0x06 }, | ||
| 2167 | { 0x22, 0x7AD, 0x80 }, | ||
| 2168 | { 0x22, 0x7A6, 0x3C }, | ||
| 2169 | { 0x22, 0x7A7, 0x90 }, | ||
| 2170 | { 0x22, 0x7A8, 0xB0 }, | ||
| 2171 | { 0x22, 0x7A9, 0x3C }, | ||
| 2172 | { 0x22, 0x7AA, 0x90 }, | ||
| 2173 | { 0x22, 0x7AB, 0xB0 }, | ||
| 2174 | { 0x22, 0x7AC, 0x07 }, | ||
| 2175 | { 0x22, 0x7AD, 0x80 }, | ||
| 2176 | { 0x22, 0x7A6, 0x7A }, | ||
| 2177 | { 0x22, 0x7A7, 0xC6 }, | ||
| 2178 | { 0x22, 0x7A8, 0x39 }, | ||
| 2179 | { 0x22, 0x7A9, 0x7A }, | ||
| 2180 | { 0x22, 0x7AA, 0xC6 }, | ||
| 2181 | { 0x22, 0x7AB, 0x39 }, | ||
| 2182 | { 0x22, 0x7AC, 0x08 }, | ||
| 2183 | { 0x22, 0x7AD, 0x80 }, | ||
| 2184 | { 0x22, 0x7A6, 0xC4 }, | ||
| 2185 | { 0x22, 0x7A7, 0xE9 }, | ||
| 2186 | { 0x22, 0x7A8, 0xDC }, | ||
| 2187 | { 0x22, 0x7A9, 0xC4 }, | ||
| 2188 | { 0x22, 0x7AA, 0xE9 }, | ||
| 2189 | { 0x22, 0x7AB, 0xDC }, | ||
| 2190 | { 0x22, 0x7AC, 0x09 }, | ||
| 2191 | { 0x22, 0x7AD, 0x80 }, | ||
| 2192 | { 0x22, 0x7A6, 0x3D }, | ||
| 2193 | { 0x22, 0x7A7, 0xE1 }, | ||
| 2194 | { 0x22, 0x7A8, 0x0D }, | ||
| 2195 | { 0x22, 0x7A9, 0x3D }, | ||
| 2196 | { 0x22, 0x7AA, 0xE1 }, | ||
| 2197 | { 0x22, 0x7AB, 0x0D }, | ||
| 2198 | { 0x22, 0x7AC, 0x0A }, | ||
| 2199 | { 0x22, 0x7AD, 0x80 }, | ||
| 2200 | { 0x22, 0x7A6, 0x89 }, | ||
| 2201 | { 0x22, 0x7A7, 0xB6 }, | ||
| 2202 | { 0x22, 0x7A8, 0xEB }, | ||
| 2203 | { 0x22, 0x7A9, 0x89 }, | ||
| 2204 | { 0x22, 0x7AA, 0xB6 }, | ||
| 2205 | { 0x22, 0x7AB, 0xEB }, | ||
| 2206 | { 0x22, 0x7AC, 0x0B }, | ||
| 2207 | { 0x22, 0x7AD, 0x80 }, | ||
| 2208 | { 0x22, 0x7A6, 0x39 }, | ||
| 2209 | { 0x22, 0x7A7, 0x9D }, | ||
| 2210 | { 0x22, 0x7A8, 0xFE }, | ||
| 2211 | { 0x22, 0x7A9, 0x39 }, | ||
| 2212 | { 0x22, 0x7AA, 0x9D }, | ||
| 2213 | { 0x22, 0x7AB, 0xFE }, | ||
| 2214 | { 0x22, 0x7AC, 0x0C }, | ||
| 2215 | { 0x22, 0x7AD, 0x80 }, | ||
| 2216 | { 0x22, 0x7A6, 0x76 }, | ||
| 2217 | { 0x22, 0x7A7, 0x49 }, | ||
| 2218 | { 0x22, 0x7A8, 0x15 }, | ||
| 2219 | { 0x22, 0x7A9, 0x76 }, | ||
| 2220 | { 0x22, 0x7AA, 0x49 }, | ||
| 2221 | { 0x22, 0x7AB, 0x15 }, | ||
| 2222 | { 0x22, 0x7AC, 0x0D }, | ||
| 2223 | { 0x22, 0x7AD, 0x80 }, | ||
| 2224 | { 0x22, 0x7A6, 0xC8 }, | ||
| 2225 | { 0x22, 0x7A7, 0x80 }, | ||
| 2226 | { 0x22, 0x7A8, 0xF5 }, | ||
| 2227 | { 0x22, 0x7A9, 0xC8 }, | ||
| 2228 | { 0x22, 0x7AA, 0x80 }, | ||
| 2229 | { 0x22, 0x7AB, 0xF5 }, | ||
| 2230 | { 0x22, 0x7AC, 0x0E }, | ||
| 2231 | { 0x22, 0x7AD, 0x80 }, | ||
| 2232 | { 0x22, 0x7A6, 0x40 }, | ||
| 2233 | { 0x22, 0x7A7, 0x00 }, | ||
| 2234 | { 0x22, 0x7A8, 0x00 }, | ||
| 2235 | { 0x22, 0x7A9, 0x40 }, | ||
| 2236 | { 0x22, 0x7AA, 0x00 }, | ||
| 2237 | { 0x22, 0x7AB, 0x00 }, | ||
| 2238 | { 0x22, 0x7AC, 0x0F }, | ||
| 2239 | { 0x22, 0x7AD, 0x80 }, | ||
| 2240 | { 0x22, 0x7A6, 0x90 }, | ||
| 2241 | { 0x22, 0x7A7, 0x68 }, | ||
| 2242 | { 0x22, 0x7A8, 0xF1 }, | ||
| 2243 | { 0x22, 0x7A9, 0x90 }, | ||
| 2244 | { 0x22, 0x7AA, 0x68 }, | ||
| 2245 | { 0x22, 0x7AB, 0xF1 }, | ||
| 2246 | { 0x22, 0x7AC, 0x10 }, | ||
| 2247 | { 0x22, 0x7AD, 0x80 }, | ||
| 2248 | { 0x22, 0x7A6, 0x34 }, | ||
| 2249 | { 0x22, 0x7A7, 0x47 }, | ||
| 2250 | { 0x22, 0x7A8, 0x6C }, | ||
| 2251 | { 0x22, 0x7A9, 0x34 }, | ||
| 2252 | { 0x22, 0x7AA, 0x47 }, | ||
| 2253 | { 0x22, 0x7AB, 0x6C }, | ||
| 2254 | { 0x22, 0x7AC, 0x11 }, | ||
| 2255 | { 0x22, 0x7AD, 0x80 }, | ||
| 2256 | { 0x22, 0x7A6, 0x6F }, | ||
| 2257 | { 0x22, 0x7A7, 0x97 }, | ||
| 2258 | { 0x22, 0x7A8, 0x0F }, | ||
| 2259 | { 0x22, 0x7A9, 0x6F }, | ||
| 2260 | { 0x22, 0x7AA, 0x97 }, | ||
| 2261 | { 0x22, 0x7AB, 0x0F }, | ||
| 2262 | { 0x22, 0x7AC, 0x12 }, | ||
| 2263 | { 0x22, 0x7AD, 0x80 }, | ||
| 2264 | { 0x22, 0x7A6, 0xCB }, | ||
| 2265 | { 0x22, 0x7A7, 0xB8 }, | ||
| 2266 | { 0x22, 0x7A8, 0x94 }, | ||
| 2267 | { 0x22, 0x7A9, 0xCB }, | ||
| 2268 | { 0x22, 0x7AA, 0xB8 }, | ||
| 2269 | { 0x22, 0x7AB, 0x94 }, | ||
| 2270 | { 0x22, 0x7AC, 0x13 }, | ||
| 2271 | { 0x22, 0x7AD, 0x80 }, | ||
| 2272 | { 0x22, 0x7A6, 0x40 }, | ||
| 2273 | { 0x22, 0x7A7, 0x00 }, | ||
| 2274 | { 0x22, 0x7A8, 0x00 }, | ||
| 2275 | { 0x22, 0x7A9, 0x40 }, | ||
| 2276 | { 0x22, 0x7AA, 0x00 }, | ||
| 2277 | { 0x22, 0x7AB, 0x00 }, | ||
| 2278 | { 0x22, 0x7AC, 0x14 }, | ||
| 2279 | { 0x22, 0x7AD, 0x80 }, | ||
| 2280 | { 0x22, 0x7A6, 0x95 }, | ||
| 2281 | { 0x22, 0x7A7, 0x76 }, | ||
| 2282 | { 0x22, 0x7A8, 0x5B }, | ||
| 2283 | { 0x22, 0x7A9, 0x95 }, | ||
| 2284 | { 0x22, 0x7AA, 0x76 }, | ||
| 2285 | { 0x22, 0x7AB, 0x5B }, | ||
| 2286 | { 0x22, 0x7AC, 0x15 }, | ||
| 2287 | { 0x22, 0x7AD, 0x80 }, | ||
| 2288 | { 0x22, 0x7A6, 0x31 }, | ||
| 2289 | { 0x22, 0x7A7, 0xAC }, | ||
| 2290 | { 0x22, 0x7A8, 0x31 }, | ||
| 2291 | { 0x22, 0x7A9, 0x31 }, | ||
| 2292 | { 0x22, 0x7AA, 0xAC }, | ||
| 2293 | { 0x22, 0x7AB, 0x31 }, | ||
| 2294 | { 0x22, 0x7AC, 0x16 }, | ||
| 2295 | { 0x22, 0x7AD, 0x80 }, | ||
| 2296 | { 0x22, 0x7A6, 0x6A }, | ||
| 2297 | { 0x22, 0x7A7, 0x89 }, | ||
| 2298 | { 0x22, 0x7A8, 0xA5 }, | ||
| 2299 | { 0x22, 0x7A9, 0x6A }, | ||
| 2300 | { 0x22, 0x7AA, 0x89 }, | ||
| 2301 | { 0x22, 0x7AB, 0xA5 }, | ||
| 2302 | { 0x22, 0x7AC, 0x17 }, | ||
| 2303 | { 0x22, 0x7AD, 0x80 }, | ||
| 2304 | { 0x22, 0x7A6, 0xCE }, | ||
| 2305 | { 0x22, 0x7A7, 0x53 }, | ||
| 2306 | { 0x22, 0x7A8, 0xCF }, | ||
| 2307 | { 0x22, 0x7A9, 0xCE }, | ||
| 2308 | { 0x22, 0x7AA, 0x53 }, | ||
| 2309 | { 0x22, 0x7AB, 0xCF }, | ||
| 2310 | { 0x22, 0x7AC, 0x18 }, | ||
| 2311 | { 0x22, 0x7AD, 0x80 }, | ||
| 2312 | { 0x22, 0x7A6, 0x40 }, | ||
| 2313 | { 0x22, 0x7A7, 0x00 }, | ||
| 2314 | { 0x22, 0x7A8, 0x00 }, | ||
| 2315 | { 0x22, 0x7A9, 0x40 }, | ||
| 2316 | { 0x22, 0x7AA, 0x00 }, | ||
| 2317 | { 0x22, 0x7AB, 0x00 }, | ||
| 2318 | { 0x22, 0x7AC, 0x19 }, | ||
| 2319 | { 0x22, 0x7AD, 0x80 }, | ||
| 2320 | /* 48KHz base */ | ||
| 2321 | { 0x22, 0x7A6, 0x3E }, | ||
| 2322 | { 0x22, 0x7A7, 0x88 }, | ||
| 2323 | { 0x22, 0x7A8, 0xDC }, | ||
| 2324 | { 0x22, 0x7A9, 0x3E }, | ||
| 2325 | { 0x22, 0x7AA, 0x88 }, | ||
| 2326 | { 0x22, 0x7AB, 0xDC }, | ||
| 2327 | { 0x22, 0x7AC, 0x1A }, | ||
| 2328 | { 0x22, 0x7AD, 0x80 }, | ||
| 2329 | { 0x22, 0x7A6, 0x82 }, | ||
| 2330 | { 0x22, 0x7A7, 0xEE }, | ||
| 2331 | { 0x22, 0x7A8, 0x46 }, | ||
| 2332 | { 0x22, 0x7A9, 0x82 }, | ||
| 2333 | { 0x22, 0x7AA, 0xEE }, | ||
| 2334 | { 0x22, 0x7AB, 0x46 }, | ||
| 2335 | { 0x22, 0x7AC, 0x1B }, | ||
| 2336 | { 0x22, 0x7AD, 0x80 }, | ||
| 2337 | { 0x22, 0x7A6, 0x3E }, | ||
| 2338 | { 0x22, 0x7A7, 0x88 }, | ||
| 2339 | { 0x22, 0x7A8, 0xDC }, | ||
| 2340 | { 0x22, 0x7A9, 0x3E }, | ||
| 2341 | { 0x22, 0x7AA, 0x88 }, | ||
| 2342 | { 0x22, 0x7AB, 0xDC }, | ||
| 2343 | { 0x22, 0x7AC, 0x1C }, | ||
| 2344 | { 0x22, 0x7AD, 0x80 }, | ||
| 2345 | { 0x22, 0x7A6, 0x7D }, | ||
| 2346 | { 0x22, 0x7A7, 0x09 }, | ||
| 2347 | { 0x22, 0x7A8, 0x28 }, | ||
| 2348 | { 0x22, 0x7A9, 0x7D }, | ||
| 2349 | { 0x22, 0x7AA, 0x09 }, | ||
| 2350 | { 0x22, 0x7AB, 0x28 }, | ||
| 2351 | { 0x22, 0x7AC, 0x1D }, | ||
| 2352 | { 0x22, 0x7AD, 0x80 }, | ||
| 2353 | { 0x22, 0x7A6, 0xC2 }, | ||
| 2354 | { 0x22, 0x7A7, 0xE5 }, | ||
| 2355 | { 0x22, 0x7A8, 0xB4 }, | ||
| 2356 | { 0x22, 0x7A9, 0xC2 }, | ||
| 2357 | { 0x22, 0x7AA, 0xE5 }, | ||
| 2358 | { 0x22, 0x7AB, 0xB4 }, | ||
| 2359 | { 0x22, 0x7AC, 0x1E }, | ||
| 2360 | { 0x22, 0x7AD, 0x80 }, | ||
| 2361 | { 0x22, 0x7A6, 0x3E }, | ||
| 2362 | { 0x22, 0x7A7, 0xA3 }, | ||
| 2363 | { 0x22, 0x7A8, 0x1F }, | ||
| 2364 | { 0x22, 0x7A9, 0x3E }, | ||
| 2365 | { 0x22, 0x7AA, 0xA3 }, | ||
| 2366 | { 0x22, 0x7AB, 0x1F }, | ||
| 2367 | { 0x22, 0x7AC, 0x1F }, | ||
| 2368 | { 0x22, 0x7AD, 0x80 }, | ||
| 2369 | { 0x22, 0x7A6, 0x84 }, | ||
| 2370 | { 0x22, 0x7A7, 0xCA }, | ||
| 2371 | { 0x22, 0x7A8, 0xF1 }, | ||
| 2372 | { 0x22, 0x7A9, 0x84 }, | ||
| 2373 | { 0x22, 0x7AA, 0xCA }, | ||
| 2374 | { 0x22, 0x7AB, 0xF1 }, | ||
| 2375 | { 0x22, 0x7AC, 0x20 }, | ||
| 2376 | { 0x22, 0x7AD, 0x80 }, | ||
| 2377 | { 0x22, 0x7A6, 0x3C }, | ||
| 2378 | { 0x22, 0x7A7, 0xD5 }, | ||
| 2379 | { 0x22, 0x7A8, 0x9C }, | ||
| 2380 | { 0x22, 0x7A9, 0x3C }, | ||
| 2381 | { 0x22, 0x7AA, 0xD5 }, | ||
| 2382 | { 0x22, 0x7AB, 0x9C }, | ||
| 2383 | { 0x22, 0x7AC, 0x21 }, | ||
| 2384 | { 0x22, 0x7AD, 0x80 }, | ||
| 2385 | { 0x22, 0x7A6, 0x7B }, | ||
| 2386 | { 0x22, 0x7A7, 0x35 }, | ||
| 2387 | { 0x22, 0x7A8, 0x0F }, | ||
| 2388 | { 0x22, 0x7A9, 0x7B }, | ||
| 2389 | { 0x22, 0x7AA, 0x35 }, | ||
| 2390 | { 0x22, 0x7AB, 0x0F }, | ||
| 2391 | { 0x22, 0x7AC, 0x22 }, | ||
| 2392 | { 0x22, 0x7AD, 0x80 }, | ||
| 2393 | { 0x22, 0x7A6, 0xC4 }, | ||
| 2394 | { 0x22, 0x7A7, 0x87 }, | ||
| 2395 | { 0x22, 0x7A8, 0x45 }, | ||
| 2396 | { 0x22, 0x7A9, 0xC4 }, | ||
| 2397 | { 0x22, 0x7AA, 0x87 }, | ||
| 2398 | { 0x22, 0x7AB, 0x45 }, | ||
| 2399 | { 0x22, 0x7AC, 0x23 }, | ||
| 2400 | { 0x22, 0x7AD, 0x80 }, | ||
| 2401 | { 0x22, 0x7A6, 0x3E }, | ||
| 2402 | { 0x22, 0x7A7, 0x0A }, | ||
| 2403 | { 0x22, 0x7A8, 0x78 }, | ||
| 2404 | { 0x22, 0x7A9, 0x3E }, | ||
| 2405 | { 0x22, 0x7AA, 0x0A }, | ||
| 2406 | { 0x22, 0x7AB, 0x78 }, | ||
| 2407 | { 0x22, 0x7AC, 0x24 }, | ||
| 2408 | { 0x22, 0x7AD, 0x80 }, | ||
| 2409 | { 0x22, 0x7A6, 0x88 }, | ||
| 2410 | { 0x22, 0x7A7, 0xE2 }, | ||
| 2411 | { 0x22, 0x7A8, 0x05 }, | ||
| 2412 | { 0x22, 0x7A9, 0x88 }, | ||
| 2413 | { 0x22, 0x7AA, 0xE2 }, | ||
| 2414 | { 0x22, 0x7AB, 0x05 }, | ||
| 2415 | { 0x22, 0x7AC, 0x25 }, | ||
| 2416 | { 0x22, 0x7AD, 0x80 }, | ||
| 2417 | { 0x22, 0x7A6, 0x3A }, | ||
| 2418 | { 0x22, 0x7A7, 0x1A }, | ||
| 2419 | { 0x22, 0x7A8, 0xA3 }, | ||
| 2420 | { 0x22, 0x7A9, 0x3A }, | ||
| 2421 | { 0x22, 0x7AA, 0x1A }, | ||
| 2422 | { 0x22, 0x7AB, 0xA3 }, | ||
| 2423 | { 0x22, 0x7AC, 0x26 }, | ||
| 2424 | { 0x22, 0x7AD, 0x80 }, | ||
| 2425 | { 0x22, 0x7A6, 0x77 }, | ||
| 2426 | { 0x22, 0x7A7, 0x1D }, | ||
| 2427 | { 0x22, 0x7A8, 0xFB }, | ||
| 2428 | { 0x22, 0x7A9, 0x77 }, | ||
| 2429 | { 0x22, 0x7AA, 0x1D }, | ||
| 2430 | { 0x22, 0x7AB, 0xFB }, | ||
| 2431 | { 0x22, 0x7AC, 0x27 }, | ||
| 2432 | { 0x22, 0x7AD, 0x80 }, | ||
| 2433 | { 0x22, 0x7A6, 0xC7 }, | ||
| 2434 | { 0x22, 0x7A7, 0xDA }, | ||
| 2435 | { 0x22, 0x7A8, 0xE5 }, | ||
| 2436 | { 0x22, 0x7A9, 0xC7 }, | ||
| 2437 | { 0x22, 0x7AA, 0xDA }, | ||
| 2438 | { 0x22, 0x7AB, 0xE5 }, | ||
| 2439 | { 0x22, 0x7AC, 0x28 }, | ||
| 2440 | { 0x22, 0x7AD, 0x80 }, | ||
| 2441 | { 0x22, 0x7A6, 0x40 }, | ||
| 2442 | { 0x22, 0x7A7, 0x00 }, | ||
| 2443 | { 0x22, 0x7A8, 0x00 }, | ||
| 2444 | { 0x22, 0x7A9, 0x40 }, | ||
| 2445 | { 0x22, 0x7AA, 0x00 }, | ||
| 2446 | { 0x22, 0x7AB, 0x00 }, | ||
| 2447 | { 0x22, 0x7AC, 0x29 }, | ||
| 2448 | { 0x22, 0x7AD, 0x80 }, | ||
| 2449 | { 0x22, 0x7A6, 0x8E }, | ||
| 2450 | { 0x22, 0x7A7, 0xD7 }, | ||
| 2451 | { 0x22, 0x7A8, 0x22 }, | ||
| 2452 | { 0x22, 0x7A9, 0x8E }, | ||
| 2453 | { 0x22, 0x7AA, 0xD7 }, | ||
| 2454 | { 0x22, 0x7AB, 0x22 }, | ||
| 2455 | { 0x22, 0x7AC, 0x2A }, | ||
| 2456 | { 0x22, 0x7AD, 0x80 }, | ||
| 2457 | { 0x22, 0x7A6, 0x35 }, | ||
| 2458 | { 0x22, 0x7A7, 0x26 }, | ||
| 2459 | { 0x22, 0x7A8, 0xC6 }, | ||
| 2460 | { 0x22, 0x7A9, 0x35 }, | ||
| 2461 | { 0x22, 0x7AA, 0x26 }, | ||
| 2462 | { 0x22, 0x7AB, 0xC6 }, | ||
| 2463 | { 0x22, 0x7AC, 0x2B }, | ||
| 2464 | { 0x22, 0x7AD, 0x80 }, | ||
| 2465 | { 0x22, 0x7A6, 0x71 }, | ||
| 2466 | { 0x22, 0x7A7, 0x28 }, | ||
| 2467 | { 0x22, 0x7A8, 0xDE }, | ||
| 2468 | { 0x22, 0x7A9, 0x71 }, | ||
| 2469 | { 0x22, 0x7AA, 0x28 }, | ||
| 2470 | { 0x22, 0x7AB, 0xDE }, | ||
| 2471 | { 0x22, 0x7AC, 0x2C }, | ||
| 2472 | { 0x22, 0x7AD, 0x80 }, | ||
| 2473 | { 0x22, 0x7A6, 0xCA }, | ||
| 2474 | { 0x22, 0x7A7, 0xD9 }, | ||
| 2475 | { 0x22, 0x7A8, 0x3A }, | ||
| 2476 | { 0x22, 0x7A9, 0xCA }, | ||
| 2477 | { 0x22, 0x7AA, 0xD9 }, | ||
| 2478 | { 0x22, 0x7AB, 0x3A }, | ||
| 2479 | { 0x22, 0x7AC, 0x2D }, | ||
| 2480 | { 0x22, 0x7AD, 0x80 }, | ||
| 2481 | { 0x22, 0x7A6, 0x40 }, | ||
| 2482 | { 0x22, 0x7A7, 0x00 }, | ||
| 2483 | { 0x22, 0x7A8, 0x00 }, | ||
| 2484 | { 0x22, 0x7A9, 0x40 }, | ||
| 2485 | { 0x22, 0x7AA, 0x00 }, | ||
| 2486 | { 0x22, 0x7AB, 0x00 }, | ||
| 2487 | { 0x22, 0x7AC, 0x2E }, | ||
| 2488 | { 0x22, 0x7AD, 0x80 }, | ||
| 2489 | { 0x22, 0x7A6, 0x93 }, | ||
| 2490 | { 0x22, 0x7A7, 0x5E }, | ||
| 2491 | { 0x22, 0x7A8, 0xD8 }, | ||
| 2492 | { 0x22, 0x7A9, 0x93 }, | ||
| 2493 | { 0x22, 0x7AA, 0x5E }, | ||
| 2494 | { 0x22, 0x7AB, 0xD8 }, | ||
| 2495 | { 0x22, 0x7AC, 0x2F }, | ||
| 2496 | { 0x22, 0x7AD, 0x80 }, | ||
| 2497 | { 0x22, 0x7A6, 0x32 }, | ||
| 2498 | { 0x22, 0x7A7, 0xB7 }, | ||
| 2499 | { 0x22, 0x7A8, 0xB1 }, | ||
| 2500 | { 0x22, 0x7A9, 0x32 }, | ||
| 2501 | { 0x22, 0x7AA, 0xB7 }, | ||
| 2502 | { 0x22, 0x7AB, 0xB1 }, | ||
| 2503 | { 0x22, 0x7AC, 0x30 }, | ||
| 2504 | { 0x22, 0x7AD, 0x80 }, | ||
| 2505 | { 0x22, 0x7A6, 0x6C }, | ||
| 2506 | { 0x22, 0x7A7, 0xA1 }, | ||
| 2507 | { 0x22, 0x7A8, 0x28 }, | ||
| 2508 | { 0x22, 0x7A9, 0x6C }, | ||
| 2509 | { 0x22, 0x7AA, 0xA1 }, | ||
| 2510 | { 0x22, 0x7AB, 0x28 }, | ||
| 2511 | { 0x22, 0x7AC, 0x31 }, | ||
| 2512 | { 0x22, 0x7AD, 0x80 }, | ||
| 2513 | { 0x22, 0x7A6, 0xCD }, | ||
| 2514 | { 0x22, 0x7A7, 0x48 }, | ||
| 2515 | { 0x22, 0x7A8, 0x4F }, | ||
| 2516 | { 0x22, 0x7A9, 0xCD }, | ||
| 2517 | { 0x22, 0x7AA, 0x48 }, | ||
| 2518 | { 0x22, 0x7AB, 0x4F }, | ||
| 2519 | { 0x22, 0x7AC, 0x32 }, | ||
| 2520 | { 0x22, 0x7AD, 0x80 }, | ||
| 2521 | { 0x22, 0x7A6, 0x40 }, | ||
| 2522 | { 0x22, 0x7A7, 0x00 }, | ||
| 2523 | { 0x22, 0x7A8, 0x00 }, | ||
| 2524 | { 0x22, 0x7A9, 0x40 }, | ||
| 2525 | { 0x22, 0x7AA, 0x00 }, | ||
| 2526 | { 0x22, 0x7AB, 0x00 }, | ||
| 2527 | { 0x22, 0x7AC, 0x33 }, | ||
| 2528 | { 0x22, 0x7AD, 0x80 }, | ||
| 2529 | /* common */ | ||
| 2530 | { 0x22, 0x782, 0xC1 }, | ||
| 2531 | { 0x22, 0x771, 0x2C }, | ||
| 2532 | { 0x22, 0x772, 0x2C }, | ||
| 2533 | { 0x22, 0x788, 0x04 }, | ||
| 2534 | { 0x01, 0x7B0, 0x08 }, | ||
| 2535 | {} | ||
| 2536 | }; | ||
| 2537 | |||
| 2107 | static const struct hda_fixup stac92hd83xxx_fixups[] = { | 2538 | static const struct hda_fixup stac92hd83xxx_fixups[] = { |
| 2108 | [STAC_92HD83XXX_REF] = { | 2539 | [STAC_92HD83XXX_REF] = { |
| 2109 | .type = HDA_FIXUP_PINS, | 2540 | .type = HDA_FIXUP_PINS, |
| @@ -2172,6 +2603,12 @@ static const struct hda_fixup stac92hd83xxx_fixups[] = { | |||
| 2172 | {} | 2603 | {} |
| 2173 | }, | 2604 | }, |
| 2174 | }, | 2605 | }, |
| 2606 | [STAC_HP_BNB13_EQ] = { | ||
| 2607 | .type = HDA_FIXUP_VERBS, | ||
| 2608 | .v.verbs = hp_bnb13_eq_verbs, | ||
| 2609 | .chained = true, | ||
| 2610 | .chain_id = STAC_92HD83XXX_HP_MIC_LED, | ||
| 2611 | }, | ||
| 2175 | }; | 2612 | }; |
| 2176 | 2613 | ||
| 2177 | static const struct hda_model_fixup stac92hd83xxx_models[] = { | 2614 | static const struct hda_model_fixup stac92hd83xxx_models[] = { |
| @@ -2187,6 +2624,7 @@ static const struct hda_model_fixup stac92hd83xxx_models[] = { | |||
| 2187 | { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" }, | 2624 | { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" }, |
| 2188 | { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" }, | 2625 | { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" }, |
| 2189 | { .id = STAC_HP_ENVY_BASS, .name = "hp-envy-bass" }, | 2626 | { .id = STAC_HP_ENVY_BASS, .name = "hp-envy-bass" }, |
| 2627 | { .id = STAC_HP_BNB13_EQ, .name = "hp-bnb13-eq" }, | ||
| 2190 | {} | 2628 | {} |
| 2191 | }; | 2629 | }; |
| 2192 | 2630 | ||
| @@ -2233,7 +2671,101 @@ static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = { | |||
| 2233 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888, | 2671 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888, |
| 2234 | "HP Envy Spectre", STAC_HP_ENVY_BASS), | 2672 | "HP Envy Spectre", STAC_HP_ENVY_BASS), |
| 2235 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, | 2673 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, |
| 2236 | "HP Folio", STAC_92HD83XXX_HP_MIC_LED), | 2674 | "HP Folio", STAC_HP_BNB13_EQ), |
| 2675 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18F8, | ||
| 2676 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2677 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1909, | ||
| 2678 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2679 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x190A, | ||
| 2680 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2681 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1940, | ||
| 2682 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2683 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1941, | ||
| 2684 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2685 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1942, | ||
| 2686 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2687 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1943, | ||
| 2688 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2689 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1944, | ||
| 2690 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2691 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1945, | ||
| 2692 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2693 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1946, | ||
| 2694 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2695 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1948, | ||
| 2696 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2697 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1949, | ||
| 2698 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2699 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194A, | ||
| 2700 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2701 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194B, | ||
| 2702 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2703 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194C, | ||
| 2704 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2705 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194E, | ||
| 2706 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2707 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194F, | ||
| 2708 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2709 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1950, | ||
| 2710 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2711 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1951, | ||
| 2712 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2713 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195A, | ||
| 2714 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2715 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195B, | ||
| 2716 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2717 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195C, | ||
| 2718 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2719 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1991, | ||
| 2720 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2721 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2103, | ||
| 2722 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2723 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2104, | ||
| 2724 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2725 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2105, | ||
| 2726 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2727 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2106, | ||
| 2728 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2729 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2107, | ||
| 2730 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2731 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2108, | ||
| 2732 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2733 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2109, | ||
| 2734 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2735 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x210A, | ||
| 2736 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2737 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x210B, | ||
| 2738 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2739 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211C, | ||
| 2740 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2741 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211D, | ||
| 2742 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2743 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211E, | ||
| 2744 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2745 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211F, | ||
| 2746 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2747 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2120, | ||
| 2748 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2749 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2121, | ||
| 2750 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2751 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2122, | ||
| 2752 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2753 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2123, | ||
| 2754 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2755 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x213E, | ||
| 2756 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2757 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x213F, | ||
| 2758 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2759 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2140, | ||
| 2760 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2761 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B2, | ||
| 2762 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2763 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B3, | ||
| 2764 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2765 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B5, | ||
| 2766 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2767 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B6, | ||
| 2768 | "HP bNB13", STAC_HP_BNB13_EQ), | ||
| 2237 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x1900, | 2769 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x1900, |
| 2238 | "HP", STAC_92HD83XXX_HP_MIC_LED), | 2770 | "HP", STAC_92HD83XXX_HP_MIC_LED), |
| 2239 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2000, | 2771 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2000, |
diff --git a/sound/pci/ice1712/psc724.c b/sound/pci/ice1712/psc724.c index 302ac6ddd545..4019cf27d117 100644 --- a/sound/pci/ice1712/psc724.c +++ b/sound/pci/ice1712/psc724.c | |||
| @@ -203,12 +203,12 @@ static void psc724_set_jack_state(struct snd_ice1712 *ice, bool hp_connected) | |||
| 203 | /* notify about master speaker mute change */ | 203 | /* notify about master speaker mute change */ |
| 204 | memset(&elem_id, 0, sizeof(elem_id)); | 204 | memset(&elem_id, 0, sizeof(elem_id)); |
| 205 | elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 205 | elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 206 | strncpy(elem_id.name, "Master Speakers Playback Switch", | 206 | strlcpy(elem_id.name, "Master Speakers Playback Switch", |
| 207 | sizeof(elem_id.name)); | 207 | sizeof(elem_id.name)); |
| 208 | kctl = snd_ctl_find_id(ice->card, &elem_id); | 208 | kctl = snd_ctl_find_id(ice->card, &elem_id); |
| 209 | snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); | 209 | snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); |
| 210 | /* and headphone mute change */ | 210 | /* and headphone mute change */ |
| 211 | strncpy(elem_id.name, spec->wm8776.ctl[WM8776_CTL_HP_SW].name, | 211 | strlcpy(elem_id.name, spec->wm8776.ctl[WM8776_CTL_HP_SW].name, |
| 212 | sizeof(elem_id.name)); | 212 | sizeof(elem_id.name)); |
| 213 | kctl = snd_ctl_find_id(ice->card, &elem_id); | 213 | kctl = snd_ctl_find_id(ice->card, &elem_id); |
| 214 | snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); | 214 | snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); |
diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index 975e0357bd5a..71c6003ef338 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c | |||
| @@ -203,6 +203,7 @@ static const char * const ext_clock_names[3] = {"IEC958 In", "Word Clock 1xFS", | |||
| 203 | #define AK4620_DEEMVOL_REG 0x03 | 203 | #define AK4620_DEEMVOL_REG 0x03 |
| 204 | #define AK4620_SMUTE (1<<7) | 204 | #define AK4620_SMUTE (1<<7) |
| 205 | 205 | ||
| 206 | #ifdef CONFIG_PROC_FS | ||
| 206 | /* | 207 | /* |
| 207 | * Conversion from int value to its binary form. Used for debugging. | 208 | * Conversion from int value to its binary form. Used for debugging. |
| 208 | * The output buffer must be allocated prior to calling the function. | 209 | * The output buffer must be allocated prior to calling the function. |
| @@ -227,6 +228,7 @@ static char *get_binary(char *buffer, int value) | |||
| 227 | buffer[pos] = '\0'; | 228 | buffer[pos] = '\0'; |
| 228 | return buffer; | 229 | return buffer; |
| 229 | } | 230 | } |
| 231 | #endif /* CONFIG_PROC_FS */ | ||
| 230 | 232 | ||
| 231 | /* | 233 | /* |
| 232 | * Initial setup of the conversion array GPIO <-> rate | 234 | * Initial setup of the conversion array GPIO <-> rate |
diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c index e473f8a88f9c..21b373b2e260 100644 --- a/sound/pci/ice1712/wm8766.c +++ b/sound/pci/ice1712/wm8766.c | |||
| @@ -253,7 +253,8 @@ static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol, | |||
| 253 | } | 253 | } |
| 254 | if (wm->ctl[n].flags & WM8766_FLAG_INVERT) { | 254 | if (wm->ctl[n].flags & WM8766_FLAG_INVERT) { |
| 255 | val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); | 255 | val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); |
| 256 | val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); | 256 | if (wm->ctl[n].flags & WM8766_FLAG_STEREO) |
| 257 | val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); | ||
| 257 | } | 258 | } |
| 258 | ucontrol->value.integer.value[0] = val1; | 259 | ucontrol->value.integer.value[0] = val1; |
| 259 | if (wm->ctl[n].flags & WM8766_FLAG_STEREO) | 260 | if (wm->ctl[n].flags & WM8766_FLAG_STEREO) |
diff --git a/sound/pci/ice1712/wm8776.c b/sound/pci/ice1712/wm8776.c index a3c05fe5daf9..e66c0da62014 100644 --- a/sound/pci/ice1712/wm8776.c +++ b/sound/pci/ice1712/wm8776.c | |||
| @@ -52,7 +52,7 @@ static void snd_wm8776_activate_ctl(struct snd_wm8776 *wm, | |||
| 52 | unsigned int index_offset; | 52 | unsigned int index_offset; |
| 53 | 53 | ||
| 54 | memset(&elem_id, 0, sizeof(elem_id)); | 54 | memset(&elem_id, 0, sizeof(elem_id)); |
| 55 | strncpy(elem_id.name, ctl_name, sizeof(elem_id.name)); | 55 | strlcpy(elem_id.name, ctl_name, sizeof(elem_id.name)); |
| 56 | elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 56 | elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 57 | kctl = snd_ctl_find_id(card, &elem_id); | 57 | kctl = snd_ctl_find_id(card, &elem_id); |
| 58 | if (!kctl) | 58 | if (!kctl) |
| @@ -526,7 +526,8 @@ static int snd_wm8776_ctl_get(struct snd_kcontrol *kcontrol, | |||
| 526 | } | 526 | } |
| 527 | if (wm->ctl[n].flags & WM8776_FLAG_INVERT) { | 527 | if (wm->ctl[n].flags & WM8776_FLAG_INVERT) { |
| 528 | val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); | 528 | val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); |
| 529 | val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); | 529 | if (wm->ctl[n].flags & WM8776_FLAG_STEREO) |
| 530 | val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); | ||
| 530 | } | 531 | } |
| 531 | ucontrol->value.integer.value[0] = val1; | 532 | ucontrol->value.integer.value[0] = val1; |
| 532 | if (wm->ctl[n].flags & WM8776_FLAG_STEREO) | 533 | if (wm->ctl[n].flags & WM8776_FLAG_STEREO) |
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 59c8aaebb91e..08d8733604a2 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
| @@ -1541,17 +1541,16 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, | |||
| 1541 | snd_dma_pci_data(chip->pci), | 1541 | snd_dma_pci_data(chip->pci), |
| 1542 | rec->prealloc_size, rec->prealloc_max_size); | 1542 | rec->prealloc_size, rec->prealloc_max_size); |
| 1543 | 1543 | ||
| 1544 | if (rec->ac97_idx == ICHD_PCMOUT && rec->playback_ops) { | 1544 | if (rec->playback_ops && |
| 1545 | rec->playback_ops->open == snd_intel8x0_playback_open) { | ||
| 1545 | struct snd_pcm_chmap *chmap; | 1546 | struct snd_pcm_chmap *chmap; |
| 1546 | int chs = 2; | 1547 | int chs = 2; |
| 1547 | if (rec->ac97_idx == ICHD_PCMOUT) { | 1548 | if (chip->multi8) |
| 1548 | if (chip->multi8) | 1549 | chs = 8; |
| 1549 | chs = 8; | 1550 | else if (chip->multi6) |
| 1550 | else if (chip->multi6) | 1551 | chs = 6; |
| 1551 | chs = 6; | 1552 | else if (chip->multi4) |
| 1552 | else if (chip->multi4) | 1553 | chs = 4; |
| 1553 | chs = 4; | ||
| 1554 | } | ||
| 1555 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, | 1554 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
| 1556 | snd_pcm_alt_chmaps, chs, 0, | 1555 | snd_pcm_alt_chmaps, chs, 0, |
| 1557 | &chmap); | 1556 | &chmap); |
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c index 7307d97186cb..0568540dc8d3 100644 --- a/sound/pci/lola/lola.c +++ b/sound/pci/lola/lola.c | |||
| @@ -463,7 +463,7 @@ static int lola_parse_tree(struct lola *chip) | |||
| 463 | 463 | ||
| 464 | err = lola_read_param(chip, 1, LOLA_PAR_FUNCTION_TYPE, &val); | 464 | err = lola_read_param(chip, 1, LOLA_PAR_FUNCTION_TYPE, &val); |
| 465 | if (err < 0) { | 465 | if (err < 0) { |
| 466 | printk(KERN_ERR SFX "Can't read FUNCTION_TYPE for 0x%x\n", nid); | 466 | printk(KERN_ERR SFX "Can't read FUNCTION_TYPE\n"); |
| 467 | return err; | 467 | return err; |
| 468 | } | 468 | } |
| 469 | if (val != 1) { | 469 | if (val != 1) { |
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 3230e57f246c..5fcaaa6da4a8 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c | |||
| @@ -453,8 +453,8 @@ static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream) | |||
| 453 | lower_32_bits(buf), upper_32_bits(buf), | 453 | lower_32_bits(buf), upper_32_bits(buf), |
| 454 | &buffer_index); | 454 | &buffer_index); |
| 455 | 455 | ||
| 456 | snd_printdd(LXP "starting: buffer index %x on %p (%d bytes)\n", | 456 | snd_printdd(LXP "starting: buffer index %x on 0x%lx (%d bytes)\n", |
| 457 | buffer_index, (void *)buf, period_bytes); | 457 | buffer_index, (unsigned long)buf, period_bytes); |
| 458 | buf += period_bytes; | 458 | buf += period_bytes; |
| 459 | } | 459 | } |
| 460 | 460 | ||
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 633c8607d053..626ecad4dae7 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c | |||
| @@ -1191,8 +1191,8 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip, | |||
| 1191 | unpack_pointer(buf, &buf_lo, &buf_hi); | 1191 | unpack_pointer(buf, &buf_lo, &buf_hi); |
| 1192 | err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi, | 1192 | err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi, |
| 1193 | &buffer_index); | 1193 | &buffer_index); |
| 1194 | snd_printdd(LXP "interrupt: gave buffer index %x on %p (%d bytes)\n", | 1194 | snd_printdd(LXP "interrupt: gave buffer index %x on 0x%lx (%d bytes)\n", |
| 1195 | buffer_index, (void *)buf, period_bytes); | 1195 | buffer_index, (unsigned long)buf, period_bytes); |
| 1196 | 1196 | ||
| 1197 | lx_stream->frame_pos = next_pos; | 1197 | lx_stream->frame_pos = next_pos; |
| 1198 | spin_unlock_irqrestore(&chip->lock, flags); | 1198 | spin_unlock_irqrestore(&chip->lock, flags); |
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index bb9ebc5543d7..0236363c301f 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c | |||
| @@ -350,9 +350,8 @@ snd_rme96_playback_copy(struct snd_pcm_substream *substream, | |||
| 350 | struct rme96 *rme96 = snd_pcm_substream_chip(substream); | 350 | struct rme96 *rme96 = snd_pcm_substream_chip(substream); |
| 351 | count <<= rme96->playback_frlog; | 351 | count <<= rme96->playback_frlog; |
| 352 | pos <<= rme96->playback_frlog; | 352 | pos <<= rme96->playback_frlog; |
| 353 | copy_from_user_toio(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, src, | 353 | return copy_from_user_toio(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, src, |
| 354 | count); | 354 | count); |
| 355 | return 0; | ||
| 356 | } | 355 | } |
| 357 | 356 | ||
| 358 | static int | 357 | static int |
| @@ -365,9 +364,8 @@ snd_rme96_capture_copy(struct snd_pcm_substream *substream, | |||
| 365 | struct rme96 *rme96 = snd_pcm_substream_chip(substream); | 364 | struct rme96 *rme96 = snd_pcm_substream_chip(substream); |
| 366 | count <<= rme96->capture_frlog; | 365 | count <<= rme96->capture_frlog; |
| 367 | pos <<= rme96->capture_frlog; | 366 | pos <<= rme96->capture_frlog; |
| 368 | copy_to_user_fromio(dst, rme96->iobase + RME96_IO_REC_BUFFER + pos, | 367 | return copy_to_user_fromio(dst, rme96->iobase + RME96_IO_REC_BUFFER + pos, |
| 369 | count); | 368 | count); |
| 370 | return 0; | ||
| 371 | } | 369 | } |
| 372 | 370 | ||
| 373 | /* | 371 | /* |
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 3cde55b753e2..e98dc008de0b 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
| @@ -3996,7 +3996,6 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm) | |||
| 3996 | return 1; | 3996 | return 1; |
| 3997 | } | 3997 | } |
| 3998 | return 0; | 3998 | return 0; |
| 3999 | break; | ||
| 4000 | case AES32: | 3999 | case AES32: |
| 4001 | status = hdspm_read(hdspm, HDSPM_statusRegister); | 4000 | status = hdspm_read(hdspm, HDSPM_statusRegister); |
| 4002 | if (status & HDSPM_tcoLockAes) { | 4001 | if (status & HDSPM_tcoLockAes) { |
| @@ -4006,9 +4005,6 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm) | |||
| 4006 | return 1; | 4005 | return 1; |
| 4007 | } | 4006 | } |
| 4008 | return 0; | 4007 | return 0; |
| 4009 | |||
| 4010 | break; | ||
| 4011 | |||
| 4012 | case RayDAT: | 4008 | case RayDAT: |
| 4013 | case AIO: | 4009 | case AIO: |
| 4014 | status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); | 4010 | status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); |
| @@ -4018,7 +4014,6 @@ static int hdspm_tco_sync_check(struct hdspm *hdspm) | |||
| 4018 | if (status & 0x4000000) | 4014 | if (status & 0x4000000) |
| 4019 | return 1; /* Lock */ | 4015 | return 1; /* Lock */ |
| 4020 | return 0; /* No signal */ | 4016 | return 0; /* No signal */ |
| 4021 | break; | ||
| 4022 | 4017 | ||
| 4023 | default: | 4018 | default: |
| 4024 | break; | 4019 | break; |
| @@ -6405,7 +6400,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, | |||
| 6405 | memset(&hdspm_version, 0, sizeof(hdspm_version)); | 6400 | memset(&hdspm_version, 0, sizeof(hdspm_version)); |
| 6406 | 6401 | ||
| 6407 | hdspm_version.card_type = hdspm->io_type; | 6402 | hdspm_version.card_type = hdspm->io_type; |
| 6408 | strncpy(hdspm_version.cardname, hdspm->card_name, | 6403 | strlcpy(hdspm_version.cardname, hdspm->card_name, |
| 6409 | sizeof(hdspm_version.cardname)); | 6404 | sizeof(hdspm_version.cardname)); |
| 6410 | hdspm_version.serial = hdspm->serial; | 6405 | hdspm_version.serial = hdspm->serial; |
| 6411 | hdspm_version.firmware_rev = hdspm->firmware_rev; | 6406 | hdspm_version.firmware_rev = hdspm->firmware_rev; |
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index 8c7dcbe0118d..ebb76f2d90d7 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c | |||
| @@ -933,8 +933,10 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev) | |||
| 933 | int i, ret; | 933 | int i, ret; |
| 934 | u64 lpar_addr, lpar_size; | 934 | u64 lpar_addr, lpar_size; |
| 935 | 935 | ||
| 936 | BUG_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1)); | 936 | if (WARN_ON(!firmware_has_feature(FW_FEATURE_PS3_LV1))) |
| 937 | BUG_ON(dev->match_id != PS3_MATCH_ID_SOUND); | 937 | return -ENODEV; |
| 938 | if (WARN_ON(dev->match_id != PS3_MATCH_ID_SOUND)) | ||
| 939 | return -ENODEV; | ||
| 938 | 940 | ||
| 939 | the_card.ps3_dev = dev; | 941 | the_card.ps3_dev = dev; |
| 940 | 942 | ||
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index bb53dea85b17..8697cedccd21 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c | |||
| @@ -777,7 +777,7 @@ static int asoc_ssc_init(struct device *dev) | |||
| 777 | if (ret) { | 777 | if (ret) { |
| 778 | dev_err(dev, "Could not register PCM: %d\n", ret); | 778 | dev_err(dev, "Could not register PCM: %d\n", ret); |
| 779 | goto err_unregister_dai; | 779 | goto err_unregister_dai; |
| 780 | }; | 780 | } |
| 781 | 781 | ||
| 782 | return 0; | 782 | return 0; |
| 783 | 783 | ||
diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c index 695351241db8..9dfa1241ea66 100644 --- a/sound/soc/blackfin/bf5xx-sport.c +++ b/sound/soc/blackfin/bf5xx-sport.c | |||
| @@ -179,8 +179,9 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) | |||
| 179 | struct dmasg *desc, temp_desc; | 179 | struct dmasg *desc, temp_desc; |
| 180 | unsigned long flags; | 180 | unsigned long flags; |
| 181 | 181 | ||
| 182 | BUG_ON(sport->dummy_rx_desc == NULL); | 182 | if (WARN_ON(!sport->dummy_rx_desc) || |
| 183 | BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); | 183 | WARN_ON(sport->curr_rx_desc == sport->dummy_rx_desc)) |
| 184 | return -EINVAL; | ||
| 184 | 185 | ||
| 185 | /* Maybe the dummy buffer descriptor ring is damaged */ | 186 | /* Maybe the dummy buffer descriptor ring is damaged */ |
| 186 | sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; | 187 | sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; |
| @@ -250,8 +251,9 @@ int sport_rx_start(struct sport_device *sport) | |||
| 250 | return -EBUSY; | 251 | return -EBUSY; |
| 251 | if (sport->tx_run) { | 252 | if (sport->tx_run) { |
| 252 | /* tx is running, rx is not running */ | 253 | /* tx is running, rx is not running */ |
| 253 | BUG_ON(sport->dma_rx_desc == NULL); | 254 | if (WARN_ON(!sport->dma_rx_desc) || |
| 254 | BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); | 255 | WARN_ON(sport->curr_rx_desc != sport->dummy_rx_desc)) |
| 256 | return -EINVAL; | ||
| 255 | local_irq_save(flags); | 257 | local_irq_save(flags); |
| 256 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - | 258 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - |
| 257 | sizeof(struct dmasg)) != sport->dummy_rx_desc) | 259 | sizeof(struct dmasg)) != sport->dummy_rx_desc) |
| @@ -298,8 +300,9 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) | |||
| 298 | struct dmasg *desc, temp_desc; | 300 | struct dmasg *desc, temp_desc; |
| 299 | unsigned long flags; | 301 | unsigned long flags; |
| 300 | 302 | ||
| 301 | BUG_ON(sport->dummy_tx_desc == NULL); | 303 | if (WARN_ON(!sport->dummy_tx_desc) || |
| 302 | BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); | 304 | WARN_ON(sport->curr_tx_desc == sport->dummy_tx_desc)) |
| 305 | return -EINVAL; | ||
| 303 | 306 | ||
| 304 | sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; | 307 | sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; |
| 305 | 308 | ||
| @@ -331,8 +334,9 @@ int sport_tx_start(struct sport_device *sport) | |||
| 331 | if (sport->tx_run) | 334 | if (sport->tx_run) |
| 332 | return -EBUSY; | 335 | return -EBUSY; |
| 333 | if (sport->rx_run) { | 336 | if (sport->rx_run) { |
| 334 | BUG_ON(sport->dma_tx_desc == NULL); | 337 | if (WARN_ON(!sport->dma_tx_desc) || |
| 335 | BUG_ON(sport->curr_tx_desc != sport->dummy_tx_desc); | 338 | WARN_ON(sport->curr_tx_desc != sport->dummy_tx_desc)) |
| 339 | return -EINVAL; | ||
| 336 | /* Hook the normal buffer descriptor */ | 340 | /* Hook the normal buffer descriptor */ |
| 337 | local_irq_save(flags); | 341 | local_irq_save(flags); |
| 338 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - | 342 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - |
| @@ -767,7 +771,8 @@ static irqreturn_t err_handler(int irq, void *dev_id) | |||
| 767 | int sport_set_rx_callback(struct sport_device *sport, | 771 | int sport_set_rx_callback(struct sport_device *sport, |
| 768 | void (*rx_callback)(void *), void *rx_data) | 772 | void (*rx_callback)(void *), void *rx_data) |
| 769 | { | 773 | { |
| 770 | BUG_ON(rx_callback == NULL); | 774 | if (WARN_ON(!rx_callback)) |
| 775 | return -EINVAL; | ||
| 771 | sport->rx_callback = rx_callback; | 776 | sport->rx_callback = rx_callback; |
| 772 | sport->rx_data = rx_data; | 777 | sport->rx_data = rx_data; |
| 773 | 778 | ||
| @@ -778,7 +783,8 @@ EXPORT_SYMBOL(sport_set_rx_callback); | |||
| 778 | int sport_set_tx_callback(struct sport_device *sport, | 783 | int sport_set_tx_callback(struct sport_device *sport, |
| 779 | void (*tx_callback)(void *), void *tx_data) | 784 | void (*tx_callback)(void *), void *tx_data) |
| 780 | { | 785 | { |
| 781 | BUG_ON(tx_callback == NULL); | 786 | if (WARN_ON(!tx_callback)) |
| 787 | return -EINVAL; | ||
| 782 | sport->tx_callback = tx_callback; | 788 | sport->tx_callback = tx_callback; |
| 783 | sport->tx_data = tx_data; | 789 | sport->tx_data = tx_data; |
| 784 | 790 | ||
| @@ -789,7 +795,8 @@ EXPORT_SYMBOL(sport_set_tx_callback); | |||
| 789 | int sport_set_err_callback(struct sport_device *sport, | 795 | int sport_set_err_callback(struct sport_device *sport, |
| 790 | void (*err_callback)(void *), void *err_data) | 796 | void (*err_callback)(void *), void *err_data) |
| 791 | { | 797 | { |
| 792 | BUG_ON(err_callback == NULL); | 798 | if (WARN_ON(!err_callback)) |
| 799 | return -EINVAL; | ||
| 793 | sport->err_callback = err_callback; | 800 | sport->err_callback = err_callback; |
| 794 | sport->err_data = err_data; | 801 | sport->err_data = err_data; |
| 795 | 802 | ||
| @@ -856,7 +863,8 @@ struct sport_device *sport_init(struct platform_device *pdev, | |||
| 856 | 863 | ||
| 857 | param.wdsize = wdsize; | 864 | param.wdsize = wdsize; |
| 858 | param.dummy_count = dummy_count; | 865 | param.dummy_count = dummy_count; |
| 859 | BUG_ON(param.wdsize == 0 || param.dummy_count == 0); | 866 | if (WARN_ON(param.wdsize == 0 || param.dummy_count == 0)) |
| 867 | return NULL; | ||
| 860 | 868 | ||
| 861 | ret = sport_config_pdev(pdev, ¶m); | 869 | ret = sport_config_pdev(pdev, ¶m); |
| 862 | if (ret) | 870 | if (ret) |
diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 5f9af1fb76e8..49cc5f6d6dba 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c | |||
| @@ -328,7 +328,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 328 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 328 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 329 | ak4641->playback_fs = rate; | 329 | ak4641->playback_fs = rate; |
| 330 | ak4641_set_deemph(codec); | 330 | ak4641_set_deemph(codec); |
| 331 | }; | 331 | } |
| 332 | 332 | ||
| 333 | return 0; | 333 | return 0; |
| 334 | } | 334 | } |
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 66ceee22fdad..53d7dab4e054 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c | |||
| @@ -568,8 +568,9 @@ static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai, | |||
| 568 | unsigned int eq_reg; | 568 | unsigned int eq_reg; |
| 569 | unsigned int i; | 569 | unsigned int i; |
| 570 | 570 | ||
| 571 | BUG_ON(band > 4); | 571 | if (WARN_ON(band > 4) || |
| 572 | BUG_ON(dai > 1); | 572 | WARN_ON(dai > 1)) |
| 573 | return; | ||
| 573 | 574 | ||
| 574 | /* Load the base register address */ | 575 | /* Load the base register address */ |
| 575 | eq_reg = dai ? M98088_REG_84_DAI2_EQ_BASE : M98088_REG_52_DAI1_EQ_BASE; | 576 | eq_reg = dai ? M98088_REG_84_DAI2_EQ_BASE : M98088_REG_52_DAI1_EQ_BASE; |
| @@ -909,7 +910,8 @@ static int max98088_line_pga(struct snd_soc_dapm_widget *w, | |||
| 909 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 910 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
| 910 | u8 *state; | 911 | u8 *state; |
| 911 | 912 | ||
| 912 | BUG_ON(!((channel == 1) || (channel == 2))); | 913 | if (WARN_ON(!(channel == 1 || channel == 2))) |
| 914 | return -EINVAL; | ||
| 913 | 915 | ||
| 914 | switch (line) { | 916 | switch (line) { |
| 915 | case LINE_INA: | 917 | case LINE_INA: |
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 8fb072455802..67244315c721 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c | |||
| @@ -516,8 +516,9 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai, | |||
| 516 | unsigned int eq_reg; | 516 | unsigned int eq_reg; |
| 517 | unsigned int i; | 517 | unsigned int i; |
| 518 | 518 | ||
| 519 | BUG_ON(band > 4); | 519 | if (WARN_ON(band > 4) || |
| 520 | BUG_ON(dai > 1); | 520 | WARN_ON(dai > 1)) |
| 521 | return; | ||
| 521 | 522 | ||
| 522 | /* Load the base register address */ | 523 | /* Load the base register address */ |
| 523 | eq_reg = dai ? M98095_142_DAI2_EQ_BASE : M98095_110_DAI1_EQ_BASE; | 524 | eq_reg = dai ? M98095_142_DAI2_EQ_BASE : M98095_110_DAI1_EQ_BASE; |
| @@ -541,8 +542,9 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai, | |||
| 541 | unsigned int bq_reg; | 542 | unsigned int bq_reg; |
| 542 | unsigned int i; | 543 | unsigned int i; |
| 543 | 544 | ||
| 544 | BUG_ON(band > 1); | 545 | if (WARN_ON(band > 1) || |
| 545 | BUG_ON(dai > 1); | 546 | WARN_ON(dai > 1)) |
| 547 | return; | ||
| 546 | 548 | ||
| 547 | /* Load the base register address */ | 549 | /* Load the base register address */ |
| 548 | bq_reg = dai ? M98095_17E_DAI2_BQ_BASE : M98095_174_DAI1_BQ_BASE; | 550 | bq_reg = dai ? M98095_17E_DAI2_BQ_BASE : M98095_174_DAI1_BQ_BASE; |
| @@ -890,7 +892,8 @@ static int max98095_line_pga(struct snd_soc_dapm_widget *w, | |||
| 890 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 892 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
| 891 | u8 *state; | 893 | u8 *state; |
| 892 | 894 | ||
| 893 | BUG_ON(!((channel == 1) || (channel == 2))); | 895 | if (WARN_ON(!(channel == 1 || channel == 2))) |
| 896 | return -EINVAL; | ||
| 894 | 897 | ||
| 895 | state = &max98095->lin_state; | 898 | state = &max98095->lin_state; |
| 896 | 899 | ||
| @@ -1740,7 +1743,8 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, | |||
| 1740 | int fs, best, best_val, i; | 1743 | int fs, best, best_val, i; |
| 1741 | int regmask, regsave; | 1744 | int regmask, regsave; |
| 1742 | 1745 | ||
| 1743 | BUG_ON(channel > 1); | 1746 | if (WARN_ON(channel > 1)) |
| 1747 | return -EINVAL; | ||
| 1744 | 1748 | ||
| 1745 | if (!pdata || !max98095->eq_textcnt) | 1749 | if (!pdata || !max98095->eq_textcnt) |
| 1746 | return 0; | 1750 | return 0; |
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index f5472adee674..bae60164c7b7 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c | |||
| @@ -343,7 +343,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, | |||
| 343 | break; | 343 | break; |
| 344 | default: | 344 | default: |
| 345 | return -EINVAL; | 345 | return -EINVAL; |
| 346 | }; | 346 | } |
| 347 | 347 | ||
| 348 | snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); | 348 | snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); |
| 349 | 349 | ||
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index fe4d29d88564..a895a5e4bdf2 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c | |||
| @@ -432,7 +432,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
| 432 | default: | 432 | default: |
| 433 | dev_err(codec->dev, "Invalid bit width\n"); | 433 | dev_err(codec->dev, "Invalid bit width\n"); |
| 434 | return -EINVAL; | 434 | return -EINVAL; |
| 435 | }; | 435 | } |
| 436 | 436 | ||
| 437 | ret = regmap_write(priv->regmap, TAS5086_SERIAL_DATA_IF, val); | 437 | ret = regmap_write(priv->regmap, TAS5086_SERIAL_DATA_IF, val); |
| 438 | if (ret < 0) | 438 | if (ret < 0) |
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 998555f2a8aa..b27c396037d4 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
| @@ -56,7 +56,8 @@ static int tpa6130a2_i2c_read(int reg) | |||
| 56 | struct tpa6130a2_data *data; | 56 | struct tpa6130a2_data *data; |
| 57 | int val; | 57 | int val; |
| 58 | 58 | ||
| 59 | BUG_ON(tpa6130a2_client == NULL); | 59 | if (WARN_ON(!tpa6130a2_client)) |
| 60 | return -EINVAL; | ||
| 60 | data = i2c_get_clientdata(tpa6130a2_client); | 61 | data = i2c_get_clientdata(tpa6130a2_client); |
| 61 | 62 | ||
| 62 | /* If powered off, return the cached value */ | 63 | /* If powered off, return the cached value */ |
| @@ -78,7 +79,8 @@ static int tpa6130a2_i2c_write(int reg, u8 value) | |||
| 78 | struct tpa6130a2_data *data; | 79 | struct tpa6130a2_data *data; |
| 79 | int val = 0; | 80 | int val = 0; |
| 80 | 81 | ||
| 81 | BUG_ON(tpa6130a2_client == NULL); | 82 | if (WARN_ON(!tpa6130a2_client)) |
| 83 | return -EINVAL; | ||
| 82 | data = i2c_get_clientdata(tpa6130a2_client); | 84 | data = i2c_get_clientdata(tpa6130a2_client); |
| 83 | 85 | ||
| 84 | if (data->power_state) { | 86 | if (data->power_state) { |
| @@ -99,7 +101,8 @@ static u8 tpa6130a2_read(int reg) | |||
| 99 | { | 101 | { |
| 100 | struct tpa6130a2_data *data; | 102 | struct tpa6130a2_data *data; |
| 101 | 103 | ||
| 102 | BUG_ON(tpa6130a2_client == NULL); | 104 | if (WARN_ON(!tpa6130a2_client)) |
| 105 | return 0; | ||
| 103 | data = i2c_get_clientdata(tpa6130a2_client); | 106 | data = i2c_get_clientdata(tpa6130a2_client); |
| 104 | 107 | ||
| 105 | return data->regs[reg]; | 108 | return data->regs[reg]; |
| @@ -110,7 +113,8 @@ static int tpa6130a2_initialize(void) | |||
| 110 | struct tpa6130a2_data *data; | 113 | struct tpa6130a2_data *data; |
| 111 | int i, ret = 0; | 114 | int i, ret = 0; |
| 112 | 115 | ||
| 113 | BUG_ON(tpa6130a2_client == NULL); | 116 | if (WARN_ON(!tpa6130a2_client)) |
| 117 | return -EINVAL; | ||
| 114 | data = i2c_get_clientdata(tpa6130a2_client); | 118 | data = i2c_get_clientdata(tpa6130a2_client); |
| 115 | 119 | ||
| 116 | for (i = 1; i < TPA6130A2_REG_VERSION; i++) { | 120 | for (i = 1; i < TPA6130A2_REG_VERSION; i++) { |
| @@ -128,7 +132,8 @@ static int tpa6130a2_power(u8 power) | |||
| 128 | u8 val; | 132 | u8 val; |
| 129 | int ret = 0; | 133 | int ret = 0; |
| 130 | 134 | ||
| 131 | BUG_ON(tpa6130a2_client == NULL); | 135 | if (WARN_ON(!tpa6130a2_client)) |
| 136 | return -EINVAL; | ||
| 132 | data = i2c_get_clientdata(tpa6130a2_client); | 137 | data = i2c_get_clientdata(tpa6130a2_client); |
| 133 | 138 | ||
| 134 | mutex_lock(&data->mutex); | 139 | mutex_lock(&data->mutex); |
| @@ -194,7 +199,8 @@ static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol, | |||
| 194 | unsigned int mask = (1 << fls(max)) - 1; | 199 | unsigned int mask = (1 << fls(max)) - 1; |
| 195 | unsigned int invert = mc->invert; | 200 | unsigned int invert = mc->invert; |
| 196 | 201 | ||
| 197 | BUG_ON(tpa6130a2_client == NULL); | 202 | if (WARN_ON(!tpa6130a2_client)) |
| 203 | return -EINVAL; | ||
| 198 | data = i2c_get_clientdata(tpa6130a2_client); | 204 | data = i2c_get_clientdata(tpa6130a2_client); |
| 199 | 205 | ||
| 200 | mutex_lock(&data->mutex); | 206 | mutex_lock(&data->mutex); |
| @@ -224,7 +230,8 @@ static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol, | |||
| 224 | unsigned int val = (ucontrol->value.integer.value[0] & mask); | 230 | unsigned int val = (ucontrol->value.integer.value[0] & mask); |
| 225 | unsigned int val_reg; | 231 | unsigned int val_reg; |
| 226 | 232 | ||
| 227 | BUG_ON(tpa6130a2_client == NULL); | 233 | if (WARN_ON(!tpa6130a2_client)) |
| 234 | return -EINVAL; | ||
| 228 | data = i2c_get_clientdata(tpa6130a2_client); | 235 | data = i2c_get_clientdata(tpa6130a2_client); |
| 229 | 236 | ||
| 230 | if (invert) | 237 | if (invert) |
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index bf7804a12863..71ce3159a62e 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c | |||
| @@ -372,7 +372,8 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) | |||
| 372 | offset = 0; | 372 | offset = 0; |
| 373 | dsp = inforec->dsp_target; | 373 | dsp = inforec->dsp_target; |
| 374 | wm0010->boot_failed = false; | 374 | wm0010->boot_failed = false; |
| 375 | BUG_ON(!list_empty(&xfer_list)); | 375 | if (WARN_ON(!list_empty(&xfer_list))) |
| 376 | return -EINVAL; | ||
| 376 | init_completion(&done); | 377 | init_completion(&done); |
| 377 | 378 | ||
| 378 | /* First record should be INFO */ | 379 | /* First record should be INFO */ |
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 7fefd766b582..8ae50274ea8f 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
| @@ -137,7 +137,8 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue) | |||
| 137 | unsigned long rate; | 137 | unsigned long rate; |
| 138 | int ret; | 138 | int ret; |
| 139 | 139 | ||
| 140 | BUG_ON(wm2000->anc_mode != ANC_OFF); | 140 | if (WARN_ON(wm2000->anc_mode != ANC_OFF)) |
| 141 | return -EINVAL; | ||
| 141 | 142 | ||
| 142 | dev_dbg(&i2c->dev, "Beginning power up\n"); | 143 | dev_dbg(&i2c->dev, "Beginning power up\n"); |
| 143 | 144 | ||
| @@ -277,7 +278,8 @@ static int wm2000_enter_bypass(struct i2c_client *i2c, int analogue) | |||
| 277 | { | 278 | { |
| 278 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 279 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
| 279 | 280 | ||
| 280 | BUG_ON(wm2000->anc_mode != ANC_ACTIVE); | 281 | if (WARN_ON(wm2000->anc_mode != ANC_ACTIVE)) |
| 282 | return -EINVAL; | ||
| 281 | 283 | ||
| 282 | if (analogue) { | 284 | if (analogue) { |
| 283 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 285 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
| @@ -315,7 +317,8 @@ static int wm2000_exit_bypass(struct i2c_client *i2c, int analogue) | |||
| 315 | { | 317 | { |
| 316 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 318 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
| 317 | 319 | ||
| 318 | BUG_ON(wm2000->anc_mode != ANC_BYPASS); | 320 | if (WARN_ON(wm2000->anc_mode != ANC_BYPASS)) |
| 321 | return -EINVAL; | ||
| 319 | 322 | ||
| 320 | wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); | 323 | wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); |
| 321 | 324 | ||
| @@ -349,7 +352,8 @@ static int wm2000_enter_standby(struct i2c_client *i2c, int analogue) | |||
| 349 | { | 352 | { |
| 350 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 353 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
| 351 | 354 | ||
| 352 | BUG_ON(wm2000->anc_mode != ANC_ACTIVE); | 355 | if (WARN_ON(wm2000->anc_mode != ANC_ACTIVE)) |
| 356 | return -EINVAL; | ||
| 353 | 357 | ||
| 354 | if (analogue) { | 358 | if (analogue) { |
| 355 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); | 359 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); |
| @@ -392,7 +396,8 @@ static int wm2000_exit_standby(struct i2c_client *i2c, int analogue) | |||
| 392 | { | 396 | { |
| 393 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 397 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
| 394 | 398 | ||
| 395 | BUG_ON(wm2000->anc_mode != ANC_STANDBY); | 399 | if (WARN_ON(wm2000->anc_mode != ANC_STANDBY)) |
| 400 | return -EINVAL; | ||
| 396 | 401 | ||
| 397 | wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); | 402 | wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); |
| 398 | 403 | ||
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index ac1745d030d6..4cf91deabc02 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c | |||
| @@ -1972,7 +1972,8 @@ static void wm5100_set_detect_mode(struct wm5100_priv *wm5100, int the_mode) | |||
| 1972 | { | 1972 | { |
| 1973 | struct wm5100_jack_mode *mode = &wm5100->pdata.jack_modes[the_mode]; | 1973 | struct wm5100_jack_mode *mode = &wm5100->pdata.jack_modes[the_mode]; |
| 1974 | 1974 | ||
| 1975 | BUG_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes)); | 1975 | if (WARN_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes))) |
| 1976 | return; | ||
| 1976 | 1977 | ||
| 1977 | gpio_set_value_cansleep(wm5100->pdata.hp_pol, mode->hp_pol); | 1978 | gpio_set_value_cansleep(wm5100->pdata.hp_pol, mode->hp_pol); |
| 1978 | regmap_update_bits(wm5100->regmap, WM5100_ACCESSORY_DETECT_MODE_1, | 1979 | regmap_update_bits(wm5100->regmap, WM5100_ACCESSORY_DETECT_MODE_1, |
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 8bbddc151aa8..a08e8bf6d07c 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
| @@ -685,13 +685,13 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), | |||
| 685 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), | 685 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), |
| 686 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), | 686 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), |
| 687 | 687 | ||
| 688 | SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21, | 688 | SND_SOC_BYTES_MASK("EQ1 Coefficients", ARIZONA_EQ1_1, 21, |
| 689 | ARIZONA_EQ1_ENA_MASK), | 689 | ARIZONA_EQ1_ENA_MASK), |
| 690 | SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21, | 690 | SND_SOC_BYTES_MASK("EQ2 Coefficients", ARIZONA_EQ2_1, 21, |
| 691 | ARIZONA_EQ2_ENA_MASK), | 691 | ARIZONA_EQ2_ENA_MASK), |
| 692 | SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21, | 692 | SND_SOC_BYTES_MASK("EQ3 Coefficients", ARIZONA_EQ3_1, 21, |
| 693 | ARIZONA_EQ3_ENA_MASK), | 693 | ARIZONA_EQ3_ENA_MASK), |
| 694 | SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21, | 694 | SND_SOC_BYTES_MASK("EQ4 Coefficients", ARIZONA_EQ4_1, 21, |
| 695 | ARIZONA_EQ4_ENA_MASK), | 695 | ARIZONA_EQ4_ENA_MASK), |
| 696 | 696 | ||
| 697 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, | 697 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, |
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 9cef204278a6..c3c7396a6181 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c | |||
| @@ -142,13 +142,13 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), | |||
| 142 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), | 142 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), |
| 143 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), | 143 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), |
| 144 | 144 | ||
| 145 | SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21, | 145 | SND_SOC_BYTES_MASK("EQ1 Coefficients", ARIZONA_EQ1_1, 21, |
| 146 | ARIZONA_EQ1_ENA_MASK), | 146 | ARIZONA_EQ1_ENA_MASK), |
| 147 | SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21, | 147 | SND_SOC_BYTES_MASK("EQ2 Coefficients", ARIZONA_EQ2_1, 21, |
| 148 | ARIZONA_EQ2_ENA_MASK), | 148 | ARIZONA_EQ2_ENA_MASK), |
| 149 | SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21, | 149 | SND_SOC_BYTES_MASK("EQ3 Coefficients", ARIZONA_EQ3_1, 21, |
| 150 | ARIZONA_EQ3_ENA_MASK), | 150 | ARIZONA_EQ3_ENA_MASK), |
| 151 | SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21, | 151 | SND_SOC_BYTES_MASK("EQ4 Coefficients", ARIZONA_EQ4_1, 21, |
| 152 | ARIZONA_EQ4_ENA_MASK), | 152 | ARIZONA_EQ4_ENA_MASK), |
| 153 | 153 | ||
| 154 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, | 154 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, |
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index af1318ddb062..a183dcf3d5c1 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
| @@ -274,7 +274,7 @@ static int pga_event(struct snd_soc_dapm_widget *w, | |||
| 274 | break; | 274 | break; |
| 275 | 275 | ||
| 276 | default: | 276 | default: |
| 277 | BUG(); | 277 | WARN(1, "Invalid shift %d\n", w->shift); |
| 278 | return -1; | 278 | return -1; |
| 279 | } | 279 | } |
| 280 | 280 | ||
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 5e9c40fa7eb2..08a414b57b1e 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
| @@ -736,7 +736,7 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, | |||
| 736 | break; | 736 | break; |
| 737 | 737 | ||
| 738 | default: | 738 | default: |
| 739 | BUG_ON("Unknown DAI driver ID\n"); | 739 | WARN(1, "Unknown DAI driver ID\n"); |
| 740 | return -EINVAL; | 740 | return -EINVAL; |
| 741 | } | 741 | } |
| 742 | 742 | ||
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index f31017ed1381..942d58e455f3 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c | |||
| @@ -325,7 +325,8 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai, | |||
| 325 | struct snd_soc_codec *codec = dai->codec; | 325 | struct snd_soc_codec *codec = dai->codec; |
| 326 | struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); | 326 | struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); |
| 327 | 327 | ||
| 328 | BUG_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk)); | 328 | if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk))) |
| 329 | return -EINVAL; | ||
| 329 | 330 | ||
| 330 | wm8776->sysclk[dai->driver->id] = freq; | 331 | wm8776->sysclk[dai->driver->id] = freq; |
| 331 | 332 | ||
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 7c8257c5a17b..734209e252c3 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
| @@ -279,7 +279,8 @@ static int wm8900_hp_event(struct snd_soc_dapm_widget *w, | |||
| 279 | break; | 279 | break; |
| 280 | 280 | ||
| 281 | default: | 281 | default: |
| 282 | BUG(); | 282 | WARN(1, "Invalid event %d\n", event); |
| 283 | break; | ||
| 283 | } | 284 | } |
| 284 | 285 | ||
| 285 | return 0; | 286 | return 0; |
| @@ -691,7 +692,8 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, | |||
| 691 | unsigned int K, Ndiv, Nmod, target; | 692 | unsigned int K, Ndiv, Nmod, target; |
| 692 | unsigned int div; | 693 | unsigned int div; |
| 693 | 694 | ||
| 694 | BUG_ON(!Fout); | 695 | if (WARN_ON(!Fout)) |
| 696 | return -EINVAL; | ||
| 695 | 697 | ||
| 696 | /* The FLL must run at 90-100MHz which is then scaled down to | 698 | /* The FLL must run at 90-100MHz which is then scaled down to |
| 697 | * the output value by FLLCLK_DIV. */ | 699 | * the output value by FLLCLK_DIV. */ |
| @@ -742,8 +744,9 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, | |||
| 742 | /* Move down to proper range now rounding is done */ | 744 | /* Move down to proper range now rounding is done */ |
| 743 | fll_div->k = K / 10; | 745 | fll_div->k = K / 10; |
| 744 | 746 | ||
| 745 | BUG_ON(target != Fout * (fll_div->fllclk_div << 2)); | 747 | if (WARN_ON(target != Fout * (fll_div->fllclk_div << 2)) || |
| 746 | BUG_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n); | 748 | WARN_ON(!K && target != Fref * fll_div->fll_ratio * fll_div->n)) |
| 749 | return -EINVAL; | ||
| 747 | 750 | ||
| 748 | return 0; | 751 | return 0; |
| 749 | } | 752 | } |
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4dfa8dceeabf..3938fb1c203e 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c | |||
| @@ -658,7 +658,8 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8904_EQ6, 0, 24, 0, eq_tlv), | |||
| 658 | static int cp_event(struct snd_soc_dapm_widget *w, | 658 | static int cp_event(struct snd_soc_dapm_widget *w, |
| 659 | struct snd_kcontrol *kcontrol, int event) | 659 | struct snd_kcontrol *kcontrol, int event) |
| 660 | { | 660 | { |
| 661 | BUG_ON(event != SND_SOC_DAPM_POST_PMU); | 661 | if (WARN_ON(event != SND_SOC_DAPM_POST_PMU)) |
| 662 | return -EINVAL; | ||
| 662 | 663 | ||
| 663 | /* Maximum startup time */ | 664 | /* Maximum startup time */ |
| 664 | udelay(500); | 665 | udelay(500); |
| @@ -740,7 +741,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, | |||
| 740 | dcs_r = 3; | 741 | dcs_r = 3; |
| 741 | break; | 742 | break; |
| 742 | default: | 743 | default: |
| 743 | BUG(); | 744 | WARN(1, "Invalid reg %d\n", reg); |
| 744 | return -EINVAL; | 745 | return -EINVAL; |
| 745 | } | 746 | } |
| 746 | 747 | ||
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index b0710d817a65..b7488f190d2b 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c | |||
| @@ -348,7 +348,7 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) | |||
| 348 | aif = 1; | 348 | aif = 1; |
| 349 | break; | 349 | break; |
| 350 | default: | 350 | default: |
| 351 | BUG(); | 351 | WARN(1, "Invalid path %d\n", path); |
| 352 | return; | 352 | return; |
| 353 | } | 353 | } |
| 354 | 354 | ||
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 48dce72fed1d..543c5c2631b6 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
| @@ -1853,7 +1853,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, | |||
| 1853 | break; | 1853 | break; |
| 1854 | 1854 | ||
| 1855 | default: | 1855 | default: |
| 1856 | BUG(); | 1856 | WARN(1, "Invalid event %d\n", event); |
| 1857 | return -EINVAL; | 1857 | return -EINVAL; |
| 1858 | } | 1858 | } |
| 1859 | 1859 | ||
| @@ -1945,7 +1945,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, | |||
| 1945 | break; | 1945 | break; |
| 1946 | 1946 | ||
| 1947 | default: | 1947 | default: |
| 1948 | BUG(); | 1948 | WARN(1, "Invalid event %d\n", event); |
| 1949 | return -EINVAL; | 1949 | return -EINVAL; |
| 1950 | 1950 | ||
| 1951 | } | 1951 | } |
| @@ -1974,7 +1974,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, | |||
| 1974 | reg = WM8962_SPKOUTL_VOLUME; | 1974 | reg = WM8962_SPKOUTL_VOLUME; |
| 1975 | break; | 1975 | break; |
| 1976 | default: | 1976 | default: |
| 1977 | BUG(); | 1977 | WARN(1, "Invalid shift %d\n", w->shift); |
| 1978 | return -EINVAL; | 1978 | return -EINVAL; |
| 1979 | } | 1979 | } |
| 1980 | 1980 | ||
| @@ -1982,7 +1982,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, | |||
| 1982 | case SND_SOC_DAPM_POST_PMU: | 1982 | case SND_SOC_DAPM_POST_PMU: |
| 1983 | return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); | 1983 | return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); |
| 1984 | default: | 1984 | default: |
| 1985 | BUG(); | 1985 | WARN(1, "Invalid event %d\n", event); |
| 1986 | return -EINVAL; | 1986 | return -EINVAL; |
| 1987 | } | 1987 | } |
| 1988 | } | 1988 | } |
| @@ -2005,7 +2005,7 @@ static int dsp2_event(struct snd_soc_dapm_widget *w, | |||
| 2005 | break; | 2005 | break; |
| 2006 | 2006 | ||
| 2007 | default: | 2007 | default: |
| 2008 | BUG(); | 2008 | WARN(1, "Invalid event %d\n", event); |
| 2009 | return -EINVAL; | 2009 | return -EINVAL; |
| 2010 | } | 2010 | } |
| 2011 | 2011 | ||
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index b70379ebd142..1a7655b0aa22 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c | |||
| @@ -610,7 +610,7 @@ static int bg_event(struct snd_soc_dapm_widget *w, | |||
| 610 | wm8996_bg_disable(codec); | 610 | wm8996_bg_disable(codec); |
| 611 | break; | 611 | break; |
| 612 | default: | 612 | default: |
| 613 | BUG(); | 613 | WARN(1, "Invalid event %d\n", event); |
| 614 | ret = -EINVAL; | 614 | ret = -EINVAL; |
| 615 | } | 615 | } |
| 616 | 616 | ||
| @@ -627,7 +627,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, | |||
| 627 | msleep(5); | 627 | msleep(5); |
| 628 | break; | 628 | break; |
| 629 | default: | 629 | default: |
| 630 | BUG(); | 630 | WARN(1, "Invalid event %d\n", event); |
| 631 | ret = -EINVAL; | 631 | ret = -EINVAL; |
| 632 | } | 632 | } |
| 633 | 633 | ||
| @@ -648,7 +648,7 @@ static int rmv_short_event(struct snd_soc_dapm_widget *w, | |||
| 648 | wm8996->hpout_pending |= w->shift; | 648 | wm8996->hpout_pending |= w->shift; |
| 649 | break; | 649 | break; |
| 650 | default: | 650 | default: |
| 651 | BUG(); | 651 | WARN(1, "Invalid event %d\n", event); |
| 652 | return -EINVAL; | 652 | return -EINVAL; |
| 653 | } | 653 | } |
| 654 | 654 | ||
| @@ -769,7 +769,7 @@ static int dcs_start(struct snd_soc_dapm_widget *w, | |||
| 769 | wm8996->dcs_pending |= 1 << w->shift; | 769 | wm8996->dcs_pending |= 1 << w->shift; |
| 770 | break; | 770 | break; |
| 771 | default: | 771 | default: |
| 772 | BUG(); | 772 | WARN(1, "Invalid event %d\n", event); |
| 773 | return -EINVAL; | 773 | return -EINVAL; |
| 774 | } | 774 | } |
| 775 | 775 | ||
| @@ -1658,7 +1658,7 @@ static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
| 1658 | lrclk_rx_reg = WM8996_AIF2_RX_LRCLK_2; | 1658 | lrclk_rx_reg = WM8996_AIF2_RX_LRCLK_2; |
| 1659 | break; | 1659 | break; |
| 1660 | default: | 1660 | default: |
| 1661 | BUG(); | 1661 | WARN(1, "Invalid dai id %d\n", dai->id); |
| 1662 | return -EINVAL; | 1662 | return -EINVAL; |
| 1663 | } | 1663 | } |
| 1664 | 1664 | ||
| @@ -1770,7 +1770,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, | |||
| 1770 | dsp_shift = WM8996_DSP2_DIV_SHIFT; | 1770 | dsp_shift = WM8996_DSP2_DIV_SHIFT; |
| 1771 | break; | 1771 | break; |
| 1772 | default: | 1772 | default: |
| 1773 | BUG(); | 1773 | WARN(1, "Invalid dai id %d\n", dai->id); |
| 1774 | return -EINVAL; | 1774 | return -EINVAL; |
| 1775 | } | 1775 | } |
| 1776 | 1776 | ||
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 6ec3de3efa4f..1392bb3c9254 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c | |||
| @@ -170,13 +170,13 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), | |||
| 170 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), | 170 | ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), |
| 171 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), | 171 | ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), |
| 172 | 172 | ||
| 173 | SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21, | 173 | SND_SOC_BYTES_MASK("EQ1 Coefficients", ARIZONA_EQ1_1, 21, |
| 174 | ARIZONA_EQ1_ENA_MASK), | 174 | ARIZONA_EQ1_ENA_MASK), |
| 175 | SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21, | 175 | SND_SOC_BYTES_MASK("EQ2 Coefficients", ARIZONA_EQ2_1, 21, |
| 176 | ARIZONA_EQ2_ENA_MASK), | 176 | ARIZONA_EQ2_ENA_MASK), |
| 177 | SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21, | 177 | SND_SOC_BYTES_MASK("EQ3 Coefficients", ARIZONA_EQ3_1, 21, |
| 178 | ARIZONA_EQ3_ENA_MASK), | 178 | ARIZONA_EQ3_ENA_MASK), |
| 179 | SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21, | 179 | SND_SOC_BYTES_MASK("EQ4 Coefficients", ARIZONA_EQ4_1, 21, |
| 180 | ARIZONA_EQ4_ENA_MASK), | 180 | ARIZONA_EQ4_ENA_MASK), |
| 181 | 181 | ||
| 182 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, | 182 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, |
| @@ -887,7 +887,7 @@ static const struct snd_soc_dapm_route wm8997_dapm_routes[] = { | |||
| 887 | ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Mic"), | 887 | ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Mic"), |
| 888 | 888 | ||
| 889 | ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), | 889 | ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), |
| 890 | ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC2INT2"), | 890 | ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), |
| 891 | 891 | ||
| 892 | ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), | 892 | ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), |
| 893 | ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), | 893 | ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), |
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index a53e175c015a..acea8927905b 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
| @@ -221,7 +221,8 @@ static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, | |||
| 221 | struct snd_soc_codec *codec = w->codec; | 221 | struct snd_soc_codec *codec = w->codec; |
| 222 | u16 status, rate; | 222 | u16 status, rate; |
| 223 | 223 | ||
| 224 | BUG_ON(event != SND_SOC_DAPM_PRE_PMD); | 224 | if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) |
| 225 | return -EINVAL; | ||
| 225 | 226 | ||
| 226 | /* Gracefully shut down the voice interface. */ | 227 | /* Gracefully shut down the voice interface. */ |
| 227 | status = ac97_read(codec, AC97_EXTENDED_MID) | 0x1000; | 228 | status = ac97_read(codec, AC97_EXTENDED_MID) | 0x1000; |
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 53b6033658a6..46ec0e9744d4 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
| @@ -341,6 +341,8 @@ static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, | |||
| 341 | static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *region, | 341 | static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *region, |
| 342 | unsigned int offset) | 342 | unsigned int offset) |
| 343 | { | 343 | { |
| 344 | if (WARN_ON(!region)) | ||
| 345 | return offset; | ||
| 344 | switch (region->type) { | 346 | switch (region->type) { |
| 345 | case WMFW_ADSP1_PM: | 347 | case WMFW_ADSP1_PM: |
| 346 | return region->base + (offset * 3); | 348 | return region->base + (offset * 3); |
| @@ -353,7 +355,7 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *region, | |||
| 353 | case WMFW_ADSP1_ZM: | 355 | case WMFW_ADSP1_ZM: |
| 354 | return region->base + (offset * 2); | 356 | return region->base + (offset * 2); |
| 355 | default: | 357 | default: |
| 356 | WARN_ON(NULL != "Unknown memory region type"); | 358 | WARN(1, "Unknown memory region type"); |
| 357 | return offset; | 359 | return offset; |
| 358 | } | 360 | } |
| 359 | } | 361 | } |
| @@ -605,7 +607,7 @@ static int wm_adsp_load(struct wm_adsp *dsp) | |||
| 605 | break; | 607 | break; |
| 606 | 608 | ||
| 607 | default: | 609 | default: |
| 608 | BUG_ON(NULL == "Unknown DSP type"); | 610 | WARN(1, "Unknown DSP type"); |
| 609 | goto out_fw; | 611 | goto out_fw; |
| 610 | } | 612 | } |
| 611 | 613 | ||
| @@ -645,27 +647,22 @@ static int wm_adsp_load(struct wm_adsp *dsp) | |||
| 645 | reg = offset; | 647 | reg = offset; |
| 646 | break; | 648 | break; |
| 647 | case WMFW_ADSP1_PM: | 649 | case WMFW_ADSP1_PM: |
| 648 | BUG_ON(!mem); | ||
| 649 | region_name = "PM"; | 650 | region_name = "PM"; |
| 650 | reg = wm_adsp_region_to_reg(mem, offset); | 651 | reg = wm_adsp_region_to_reg(mem, offset); |
| 651 | break; | 652 | break; |
| 652 | case WMFW_ADSP1_DM: | 653 | case WMFW_ADSP1_DM: |
| 653 | BUG_ON(!mem); | ||
| 654 | region_name = "DM"; | 654 | region_name = "DM"; |
| 655 | reg = wm_adsp_region_to_reg(mem, offset); | 655 | reg = wm_adsp_region_to_reg(mem, offset); |
| 656 | break; | 656 | break; |
| 657 | case WMFW_ADSP2_XM: | 657 | case WMFW_ADSP2_XM: |
| 658 | BUG_ON(!mem); | ||
| 659 | region_name = "XM"; | 658 | region_name = "XM"; |
| 660 | reg = wm_adsp_region_to_reg(mem, offset); | 659 | reg = wm_adsp_region_to_reg(mem, offset); |
| 661 | break; | 660 | break; |
| 662 | case WMFW_ADSP2_YM: | 661 | case WMFW_ADSP2_YM: |
| 663 | BUG_ON(!mem); | ||
| 664 | region_name = "YM"; | 662 | region_name = "YM"; |
| 665 | reg = wm_adsp_region_to_reg(mem, offset); | 663 | reg = wm_adsp_region_to_reg(mem, offset); |
| 666 | break; | 664 | break; |
| 667 | case WMFW_ADSP1_ZM: | 665 | case WMFW_ADSP1_ZM: |
| 668 | BUG_ON(!mem); | ||
| 669 | region_name = "ZM"; | 666 | region_name = "ZM"; |
| 670 | reg = wm_adsp_region_to_reg(mem, offset); | 667 | reg = wm_adsp_region_to_reg(mem, offset); |
| 671 | break; | 668 | break; |
| @@ -905,10 +902,8 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 905 | break; | 902 | break; |
| 906 | } | 903 | } |
| 907 | 904 | ||
| 908 | if (mem == NULL) { | 905 | if (WARN_ON(!mem)) |
| 909 | BUG_ON(mem != NULL); | ||
| 910 | return -EINVAL; | 906 | return -EINVAL; |
| 911 | } | ||
| 912 | 907 | ||
| 913 | switch (dsp->type) { | 908 | switch (dsp->type) { |
| 914 | case WMFW_ADSP1: | 909 | case WMFW_ADSP1: |
| @@ -1002,7 +997,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 1002 | break; | 997 | break; |
| 1003 | 998 | ||
| 1004 | default: | 999 | default: |
| 1005 | BUG_ON(NULL == "Unknown DSP type"); | 1000 | WARN(1, "Unknown DSP type"); |
| 1006 | return -EINVAL; | 1001 | return -EINVAL; |
| 1007 | } | 1002 | } |
| 1008 | 1003 | ||
| @@ -1066,6 +1061,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 1066 | if (i + 1 < algs) { | 1061 | if (i + 1 < algs) { |
| 1067 | region->len = be32_to_cpu(adsp1_alg[i + 1].dm); | 1062 | region->len = be32_to_cpu(adsp1_alg[i + 1].dm); |
| 1068 | region->len -= be32_to_cpu(adsp1_alg[i].dm); | 1063 | region->len -= be32_to_cpu(adsp1_alg[i].dm); |
| 1064 | region->len *= 4; | ||
| 1069 | wm_adsp_create_control(dsp, region); | 1065 | wm_adsp_create_control(dsp, region); |
| 1070 | } else { | 1066 | } else { |
| 1071 | adsp_warn(dsp, "Missing length info for region DM with ID %x\n", | 1067 | adsp_warn(dsp, "Missing length info for region DM with ID %x\n", |
| @@ -1083,6 +1079,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 1083 | if (i + 1 < algs) { | 1079 | if (i + 1 < algs) { |
| 1084 | region->len = be32_to_cpu(adsp1_alg[i + 1].zm); | 1080 | region->len = be32_to_cpu(adsp1_alg[i + 1].zm); |
| 1085 | region->len -= be32_to_cpu(adsp1_alg[i].zm); | 1081 | region->len -= be32_to_cpu(adsp1_alg[i].zm); |
| 1082 | region->len *= 4; | ||
| 1086 | wm_adsp_create_control(dsp, region); | 1083 | wm_adsp_create_control(dsp, region); |
| 1087 | } else { | 1084 | } else { |
| 1088 | adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", | 1085 | adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", |
| @@ -1112,6 +1109,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 1112 | if (i + 1 < algs) { | 1109 | if (i + 1 < algs) { |
| 1113 | region->len = be32_to_cpu(adsp2_alg[i + 1].xm); | 1110 | region->len = be32_to_cpu(adsp2_alg[i + 1].xm); |
| 1114 | region->len -= be32_to_cpu(adsp2_alg[i].xm); | 1111 | region->len -= be32_to_cpu(adsp2_alg[i].xm); |
| 1112 | region->len *= 4; | ||
| 1115 | wm_adsp_create_control(dsp, region); | 1113 | wm_adsp_create_control(dsp, region); |
| 1116 | } else { | 1114 | } else { |
| 1117 | adsp_warn(dsp, "Missing length info for region XM with ID %x\n", | 1115 | adsp_warn(dsp, "Missing length info for region XM with ID %x\n", |
| @@ -1129,6 +1127,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 1129 | if (i + 1 < algs) { | 1127 | if (i + 1 < algs) { |
| 1130 | region->len = be32_to_cpu(adsp2_alg[i + 1].ym); | 1128 | region->len = be32_to_cpu(adsp2_alg[i + 1].ym); |
| 1131 | region->len -= be32_to_cpu(adsp2_alg[i].ym); | 1129 | region->len -= be32_to_cpu(adsp2_alg[i].ym); |
| 1130 | region->len *= 4; | ||
| 1132 | wm_adsp_create_control(dsp, region); | 1131 | wm_adsp_create_control(dsp, region); |
| 1133 | } else { | 1132 | } else { |
| 1134 | adsp_warn(dsp, "Missing length info for region YM with ID %x\n", | 1133 | adsp_warn(dsp, "Missing length info for region YM with ID %x\n", |
| @@ -1146,6 +1145,7 @@ static int wm_adsp_setup_algs(struct wm_adsp *dsp) | |||
| 1146 | if (i + 1 < algs) { | 1145 | if (i + 1 < algs) { |
| 1147 | region->len = be32_to_cpu(adsp2_alg[i + 1].zm); | 1146 | region->len = be32_to_cpu(adsp2_alg[i + 1].zm); |
| 1148 | region->len -= be32_to_cpu(adsp2_alg[i].zm); | 1147 | region->len -= be32_to_cpu(adsp2_alg[i].zm); |
| 1148 | region->len *= 4; | ||
| 1149 | wm_adsp_create_control(dsp, region); | 1149 | wm_adsp_create_control(dsp, region); |
| 1150 | } else { | 1150 | } else { |
| 1151 | adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", | 1151 | adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", |
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index 01daf655e20b..b371066dd5bc 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c | |||
| @@ -611,7 +611,7 @@ static int earpiece_event(struct snd_soc_dapm_widget *w, | |||
| 611 | break; | 611 | break; |
| 612 | 612 | ||
| 613 | default: | 613 | default: |
| 614 | BUG(); | 614 | WARN(1, "Invalid event %d\n", event); |
| 615 | break; | 615 | break; |
| 616 | } | 616 | } |
| 617 | 617 | ||
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 76c742a09ef9..55193a5596ca 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c | |||
| @@ -1107,11 +1107,6 @@ static int fsl_spdif_probe(struct platform_device *pdev) | |||
| 1107 | 1107 | ||
| 1108 | /* Get the addresses and IRQ */ | 1108 | /* Get the addresses and IRQ */ |
| 1109 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1109 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1110 | if (!res) { | ||
| 1111 | dev_err(&pdev->dev, "could not determine device resources\n"); | ||
| 1112 | return -ENXIO; | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | regs = devm_ioremap_resource(&pdev->dev, res); | 1110 | regs = devm_ioremap_resource(&pdev->dev, res); |
| 1116 | if (IS_ERR(regs)) | 1111 | if (IS_ERR(regs)) |
| 1117 | return PTR_ERR(regs); | 1112 | return PTR_ERR(regs); |
diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 2fc872b2deff..f00b512dbada 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c | |||
| @@ -39,8 +39,6 @@ struct imx_pcm_runtime_data { | |||
| 39 | unsigned int period; | 39 | unsigned int period; |
| 40 | int periods; | 40 | int periods; |
| 41 | unsigned long offset; | 41 | unsigned long offset; |
| 42 | unsigned long last_offset; | ||
| 43 | unsigned long size; | ||
| 44 | struct hrtimer hrt; | 42 | struct hrtimer hrt; |
| 45 | int poll_time_ns; | 43 | int poll_time_ns; |
| 46 | struct snd_pcm_substream *substream; | 44 | struct snd_pcm_substream *substream; |
| @@ -53,9 +51,7 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) | |||
| 53 | struct imx_pcm_runtime_data *iprtd = | 51 | struct imx_pcm_runtime_data *iprtd = |
| 54 | container_of(hrt, struct imx_pcm_runtime_data, hrt); | 52 | container_of(hrt, struct imx_pcm_runtime_data, hrt); |
| 55 | struct snd_pcm_substream *substream = iprtd->substream; | 53 | struct snd_pcm_substream *substream = iprtd->substream; |
| 56 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 57 | struct pt_regs regs; | 54 | struct pt_regs regs; |
| 58 | unsigned long delta; | ||
| 59 | 55 | ||
| 60 | if (!atomic_read(&iprtd->playing) && !atomic_read(&iprtd->capturing)) | 56 | if (!atomic_read(&iprtd->playing) && !atomic_read(&iprtd->capturing)) |
| 61 | return HRTIMER_NORESTART; | 57 | return HRTIMER_NORESTART; |
| @@ -67,19 +63,7 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) | |||
| 67 | else | 63 | else |
| 68 | iprtd->offset = regs.ARM_r9 & 0xffff; | 64 | iprtd->offset = regs.ARM_r9 & 0xffff; |
| 69 | 65 | ||
| 70 | /* How much data have we transferred since the last period report? */ | 66 | snd_pcm_period_elapsed(substream); |
| 71 | if (iprtd->offset >= iprtd->last_offset) | ||
| 72 | delta = iprtd->offset - iprtd->last_offset; | ||
| 73 | else | ||
| 74 | delta = runtime->buffer_size + iprtd->offset | ||
| 75 | - iprtd->last_offset; | ||
| 76 | |||
| 77 | /* If we've transferred at least a period then report it and | ||
| 78 | * reset our poll time */ | ||
| 79 | if (delta >= iprtd->period) { | ||
| 80 | snd_pcm_period_elapsed(substream); | ||
| 81 | iprtd->last_offset = iprtd->offset; | ||
| 82 | } | ||
| 83 | 67 | ||
| 84 | hrtimer_forward_now(hrt, ns_to_ktime(iprtd->poll_time_ns)); | 68 | hrtimer_forward_now(hrt, ns_to_ktime(iprtd->poll_time_ns)); |
| 85 | 69 | ||
| @@ -96,11 +80,9 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 96 | struct snd_pcm_runtime *runtime = substream->runtime; | 80 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 97 | struct imx_pcm_runtime_data *iprtd = runtime->private_data; | 81 | struct imx_pcm_runtime_data *iprtd = runtime->private_data; |
| 98 | 82 | ||
| 99 | iprtd->size = params_buffer_bytes(params); | ||
| 100 | iprtd->periods = params_periods(params); | 83 | iprtd->periods = params_periods(params); |
| 101 | iprtd->period = params_period_bytes(params) ; | 84 | iprtd->period = params_period_bytes(params); |
| 102 | iprtd->offset = 0; | 85 | iprtd->offset = 0; |
| 103 | iprtd->last_offset = 0; | ||
| 104 | iprtd->poll_time_ns = 1000000000 / params_rate(params) * | 86 | iprtd->poll_time_ns = 1000000000 / params_rate(params) * |
| 105 | params_period_size(params); | 87 | params_period_size(params); |
| 106 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | 88 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c index 72064e995687..361f94f09b11 100644 --- a/sound/soc/fsl/imx-wm8962.c +++ b/sound/soc/fsl/imx-wm8962.c | |||
| @@ -279,8 +279,7 @@ static int imx_wm8962_probe(struct platform_device *pdev) | |||
| 279 | return 0; | 279 | return 0; |
| 280 | 280 | ||
| 281 | clk_fail: | 281 | clk_fail: |
| 282 | if (!IS_ERR(data->codec_clk)) | 282 | clk_disable_unprepare(data->codec_clk); |
| 283 | clk_disable_unprepare(data->codec_clk); | ||
| 284 | fail: | 283 | fail: |
| 285 | if (ssi_np) | 284 | if (ssi_np) |
| 286 | of_node_put(ssi_np); | 285 | of_node_put(ssi_np); |
diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/mid-x86/sst_platform.c index 392fc0b8f5b8..b6b5eb698d33 100644 --- a/sound/soc/mid-x86/sst_platform.c +++ b/sound/soc/mid-x86/sst_platform.c | |||
| @@ -40,7 +40,8 @@ static DEFINE_MUTEX(sst_lock); | |||
| 40 | 40 | ||
| 41 | int sst_register_dsp(struct sst_device *dev) | 41 | int sst_register_dsp(struct sst_device *dev) |
| 42 | { | 42 | { |
| 43 | BUG_ON(!dev); | 43 | if (WARN_ON(!dev)) |
| 44 | return -EINVAL; | ||
| 44 | if (!try_module_get(dev->dev->driver->owner)) | 45 | if (!try_module_get(dev->dev->driver->owner)) |
| 45 | return -ENODEV; | 46 | return -ENODEV; |
| 46 | mutex_lock(&sst_lock); | 47 | mutex_lock(&sst_lock); |
| @@ -59,7 +60,8 @@ EXPORT_SYMBOL_GPL(sst_register_dsp); | |||
| 59 | 60 | ||
| 60 | int sst_unregister_dsp(struct sst_device *dev) | 61 | int sst_unregister_dsp(struct sst_device *dev) |
| 61 | { | 62 | { |
| 62 | BUG_ON(!dev); | 63 | if (WARN_ON(!dev)) |
| 64 | return -EINVAL; | ||
| 63 | if (dev != sst) | 65 | if (dev != sst) |
| 64 | return -EINVAL; | 66 | return -EINVAL; |
| 65 | 67 | ||
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 5e8d640d314f..6d216cb6c19b 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c | |||
| @@ -344,8 +344,11 @@ static int __init n810_soc_init(void) | |||
| 344 | clk_set_parent(sys_clkout2_src, func96m_clk); | 344 | clk_set_parent(sys_clkout2_src, func96m_clk); |
| 345 | clk_set_rate(sys_clkout2, 12000000); | 345 | clk_set_rate(sys_clkout2, 12000000); |
| 346 | 346 | ||
| 347 | BUG_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) || | 347 | if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) || |
| 348 | (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0)); | 348 | (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) { |
| 349 | err = -EINVAL; | ||
| 350 | goto err4; | ||
| 351 | } | ||
| 349 | 352 | ||
| 350 | gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); | 353 | gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); |
| 351 | gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0); | 354 | gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0); |
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index d5340a088858..c0d648d3339f 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c | |||
| @@ -165,7 +165,8 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 165 | { | 165 | { |
| 166 | struct snd_dmaengine_dai_dma_data *dma_data; | 166 | struct snd_dmaengine_dai_dma_data *dma_data; |
| 167 | 167 | ||
| 168 | BUG_ON(IS_ERR(clk_i2s)); | 168 | if (WARN_ON(IS_ERR(clk_i2s))) |
| 169 | return -EINVAL; | ||
| 169 | clk_prepare_enable(clk_i2s); | 170 | clk_prepare_enable(clk_i2s); |
| 170 | clk_ena = 1; | 171 | clk_ena = 1; |
| 171 | pxa_i2s_wait(); | 172 | pxa_i2s_wait(); |
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c index d0740a762963..5cfaa5464eba 100644 --- a/sound/soc/s6000/s6000-pcm.c +++ b/sound/soc/s6000/s6000-pcm.c | |||
| @@ -90,7 +90,8 @@ static void s6000_pcm_enqueue_dma(struct snd_pcm_substream *substream) | |||
| 90 | return; | 90 | return; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | BUG_ON(period_size & 15); | 93 | if (WARN_ON(period_size & 15)) |
| 94 | return; | ||
| 94 | s6dmac_put_fifo(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel), | 95 | s6dmac_put_fifo(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel), |
| 95 | src, dst, period_size); | 96 | src, dst, period_size); |
| 96 | 97 | ||
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index 56d8ff6a402d..14011d90d70a 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig | |||
| @@ -37,7 +37,6 @@ config SND_SOC_SH4_SIU | |||
| 37 | config SND_SOC_RCAR | 37 | config SND_SOC_RCAR |
| 38 | tristate "R-Car series SRU/SCU/SSIU/SSI support" | 38 | tristate "R-Car series SRU/SCU/SSIU/SSI support" |
| 39 | select SND_SIMPLE_CARD | 39 | select SND_SIMPLE_CARD |
| 40 | select RCAR_CLK_ADG | ||
| 41 | help | 40 | help |
| 42 | This option enables R-Car SUR/SCU/SSIU/SSI sound support | 41 | This option enables R-Car SUR/SCU/SSIU/SSI sound support |
| 43 | 42 | ||
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index 5e46ef2e8bb8..fa8fa15860b9 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c | |||
| @@ -198,7 +198,8 @@ static struct rsnd_mod_ops rsnd_scu_ops = { | |||
| 198 | 198 | ||
| 199 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id) | 199 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id) |
| 200 | { | 200 | { |
| 201 | BUG_ON(id < 0 || id >= rsnd_scu_nr(priv)); | 201 | if (WARN_ON(id < 0 || id >= rsnd_scu_nr(priv))) |
| 202 | id = 0; | ||
| 202 | 203 | ||
| 203 | return &((struct rsnd_scu *)(priv->scu) + id)->mod; | 204 | return &((struct rsnd_scu *)(priv->scu) + id)->mod; |
| 204 | } | 205 | } |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index b71cf9d7dd3f..5ac20cd5e006 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
| @@ -611,7 +611,8 @@ struct rsnd_mod *rsnd_ssi_mod_get_frm_dai(struct rsnd_priv *priv, | |||
| 611 | 611 | ||
| 612 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id) | 612 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id) |
| 613 | { | 613 | { |
| 614 | BUG_ON(id < 0 || id >= rsnd_ssi_nr(priv)); | 614 | if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv))) |
| 615 | id = 0; | ||
| 615 | 616 | ||
| 616 | return &(((struct rsnd_ssiu *)(priv->ssiu))->ssi + id)->mod; | 617 | return &(((struct rsnd_ssiu *)(priv->ssiu))->ssi + id)->mod; |
| 617 | } | 618 | } |
diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index 9dc24ffa892a..d55babee14f8 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c | |||
| @@ -543,7 +543,8 @@ static void siu_dai_shutdown(struct snd_pcm_substream *substream, | |||
| 543 | /* Stop the siu if the other stream is not using it */ | 543 | /* Stop the siu if the other stream is not using it */ |
| 544 | if (!port_info->play_cap) { | 544 | if (!port_info->play_cap) { |
| 545 | /* during stmread or stmwrite ? */ | 545 | /* during stmread or stmwrite ? */ |
| 546 | BUG_ON(port_info->playback.rw_flg || port_info->capture.rw_flg); | 546 | if (WARN_ON(port_info->playback.rw_flg || port_info->capture.rw_flg)) |
| 547 | return; | ||
| 547 | siu_dai_spbstop(port_info); | 548 | siu_dai_spbstop(port_info); |
| 548 | siu_dai_stop(port_info); | 549 | siu_dai_stop(port_info); |
| 549 | } | 550 | } |
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 1b6663f45b34..375dc6dfba4e 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
| @@ -36,7 +36,8 @@ static bool snd_soc_set_cache_val(void *base, unsigned int idx, | |||
| 36 | break; | 36 | break; |
| 37 | } | 37 | } |
| 38 | default: | 38 | default: |
| 39 | BUG(); | 39 | WARN(1, "Invalid word_size %d\n", word_size); |
| 40 | break; | ||
| 40 | } | 41 | } |
| 41 | return false; | 42 | return false; |
| 42 | } | 43 | } |
| @@ -57,7 +58,8 @@ static unsigned int snd_soc_get_cache_val(const void *base, unsigned int idx, | |||
| 57 | return cache[idx]; | 58 | return cache[idx]; |
| 58 | } | 59 | } |
| 59 | default: | 60 | default: |
| 60 | BUG(); | 61 | WARN(1, "Invalid word_size %d\n", word_size); |
| 62 | break; | ||
| 61 | } | 63 | } |
| 62 | /* unreachable */ | 64 | /* unreachable */ |
| 63 | return -1; | 65 | return -1; |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index bdc1d74eb7b0..4e53d87e881d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -662,6 +662,8 @@ int snd_soc_suspend(struct device *dev) | |||
| 662 | codec->cache_sync = 1; | 662 | codec->cache_sync = 1; |
| 663 | if (codec->using_regmap) | 663 | if (codec->using_regmap) |
| 664 | regcache_mark_dirty(codec->control_data); | 664 | regcache_mark_dirty(codec->control_data); |
| 665 | /* deactivate pins to sleep state */ | ||
| 666 | pinctrl_pm_select_sleep_state(codec->dev); | ||
| 665 | break; | 667 | break; |
| 666 | default: | 668 | default: |
| 667 | dev_dbg(codec->dev, | 669 | dev_dbg(codec->dev, |
| @@ -679,6 +681,9 @@ int snd_soc_suspend(struct device *dev) | |||
| 679 | 681 | ||
| 680 | if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control) | 682 | if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control) |
| 681 | cpu_dai->driver->suspend(cpu_dai); | 683 | cpu_dai->driver->suspend(cpu_dai); |
| 684 | |||
| 685 | /* deactivate pins to sleep state */ | ||
| 686 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | ||
| 682 | } | 687 | } |
| 683 | 688 | ||
| 684 | if (card->suspend_post) | 689 | if (card->suspend_post) |
| @@ -807,6 +812,16 @@ int snd_soc_resume(struct device *dev) | |||
| 807 | if (list_empty(&card->codec_dev_list)) | 812 | if (list_empty(&card->codec_dev_list)) |
| 808 | return 0; | 813 | return 0; |
| 809 | 814 | ||
| 815 | /* activate pins from sleep state */ | ||
| 816 | for (i = 0; i < card->num_rtd; i++) { | ||
| 817 | struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; | ||
| 818 | struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; | ||
| 819 | if (cpu_dai->active) | ||
| 820 | pinctrl_pm_select_default_state(cpu_dai->dev); | ||
| 821 | if (codec_dai->active) | ||
| 822 | pinctrl_pm_select_default_state(codec_dai->dev); | ||
| 823 | } | ||
| 824 | |||
| 810 | /* AC97 devices might have other drivers hanging off them so | 825 | /* AC97 devices might have other drivers hanging off them so |
| 811 | * need to resume immediately. Other drivers don't have that | 826 | * need to resume immediately. Other drivers don't have that |
| 812 | * problem and may take a substantial amount of time to resume | 827 | * problem and may take a substantial amount of time to resume |
| @@ -1929,6 +1944,14 @@ int snd_soc_poweroff(struct device *dev) | |||
| 1929 | 1944 | ||
| 1930 | snd_soc_dapm_shutdown(card); | 1945 | snd_soc_dapm_shutdown(card); |
| 1931 | 1946 | ||
| 1947 | /* deactivate pins to sleep state */ | ||
| 1948 | for (i = 0; i < card->num_rtd; i++) { | ||
| 1949 | struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; | ||
| 1950 | struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; | ||
| 1951 | pinctrl_pm_select_sleep_state(codec_dai->dev); | ||
| 1952 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | ||
| 1953 | } | ||
| 1954 | |||
| 1932 | return 0; | 1955 | return 0; |
| 1933 | } | 1956 | } |
| 1934 | EXPORT_SYMBOL_GPL(snd_soc_poweroff); | 1957 | EXPORT_SYMBOL_GPL(snd_soc_poweroff); |
| @@ -3767,6 +3790,16 @@ int snd_soc_register_card(struct snd_soc_card *card) | |||
| 3767 | if (ret != 0) | 3790 | if (ret != 0) |
| 3768 | soc_cleanup_card_debugfs(card); | 3791 | soc_cleanup_card_debugfs(card); |
| 3769 | 3792 | ||
| 3793 | /* deactivate pins to sleep state */ | ||
| 3794 | for (i = 0; i < card->num_rtd; i++) { | ||
| 3795 | struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; | ||
| 3796 | struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; | ||
| 3797 | if (!codec_dai->active) | ||
| 3798 | pinctrl_pm_select_sleep_state(codec_dai->dev); | ||
| 3799 | if (!cpu_dai->active) | ||
| 3800 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | ||
| 3801 | } | ||
| 3802 | |||
| 3770 | return ret; | 3803 | return ret; |
| 3771 | } | 3804 | } |
| 3772 | EXPORT_SYMBOL_GPL(snd_soc_register_card); | 3805 | EXPORT_SYMBOL_GPL(snd_soc_register_card); |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index cc36caaf6443..dcade130157f 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -1427,7 +1427,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card, | |||
| 1427 | power = 0; | 1427 | power = 0; |
| 1428 | break; | 1428 | break; |
| 1429 | default: | 1429 | default: |
| 1430 | BUG(); | 1430 | WARN(1, "Unknown event %d\n", event); |
| 1431 | return; | 1431 | return; |
| 1432 | } | 1432 | } |
| 1433 | 1433 | ||
| @@ -1460,7 +1460,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, | |||
| 1460 | power_list)->reg; | 1460 | power_list)->reg; |
| 1461 | 1461 | ||
| 1462 | list_for_each_entry(w, pending, power_list) { | 1462 | list_for_each_entry(w, pending, power_list) { |
| 1463 | BUG_ON(reg != w->reg); | 1463 | WARN_ON(reg != w->reg); |
| 1464 | w->power = w->new_power; | 1464 | w->power = w->new_power; |
| 1465 | 1465 | ||
| 1466 | mask |= w->mask << w->shift; | 1466 | mask |= w->mask << w->shift; |
| @@ -2026,7 +2026,7 @@ static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf, | |||
| 2026 | level = "Off\n"; | 2026 | level = "Off\n"; |
| 2027 | break; | 2027 | break; |
| 2028 | default: | 2028 | default: |
| 2029 | BUG(); | 2029 | WARN(1, "Unknown bias_level %d\n", dapm->bias_level); |
| 2030 | level = "Unknown\n"; | 2030 | level = "Unknown\n"; |
| 2031 | break; | 2031 | break; |
| 2032 | } | 2032 | } |
| @@ -3359,8 +3359,9 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3359 | u64 fmt; | 3359 | u64 fmt; |
| 3360 | int ret; | 3360 | int ret; |
| 3361 | 3361 | ||
| 3362 | BUG_ON(!config); | 3362 | if (WARN_ON(!config) || |
| 3363 | BUG_ON(list_empty(&w->sources) || list_empty(&w->sinks)); | 3363 | WARN_ON(list_empty(&w->sources) || list_empty(&w->sinks))) |
| 3364 | return -EINVAL; | ||
| 3364 | 3365 | ||
| 3365 | /* We only support a single source and sink, pick the first */ | 3366 | /* We only support a single source and sink, pick the first */ |
| 3366 | source_p = list_first_entry(&w->sources, struct snd_soc_dapm_path, | 3367 | source_p = list_first_entry(&w->sources, struct snd_soc_dapm_path, |
| @@ -3368,9 +3369,10 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3368 | sink_p = list_first_entry(&w->sinks, struct snd_soc_dapm_path, | 3369 | sink_p = list_first_entry(&w->sinks, struct snd_soc_dapm_path, |
| 3369 | list_source); | 3370 | list_source); |
| 3370 | 3371 | ||
| 3371 | BUG_ON(!source_p || !sink_p); | 3372 | if (WARN_ON(!source_p || !sink_p) || |
| 3372 | BUG_ON(!sink_p->source || !source_p->sink); | 3373 | WARN_ON(!sink_p->source || !source_p->sink) || |
| 3373 | BUG_ON(!source_p->source || !sink_p->sink); | 3374 | WARN_ON(!source_p->source || !sink_p->sink)) |
| 3375 | return -EINVAL; | ||
| 3374 | 3376 | ||
| 3375 | source = source_p->source->priv; | 3377 | source = source_p->source->priv; |
| 3376 | sink = sink_p->sink->priv; | 3378 | sink = sink_p->sink->priv; |
| @@ -3446,7 +3448,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3446 | break; | 3448 | break; |
| 3447 | 3449 | ||
| 3448 | default: | 3450 | default: |
| 3449 | BUG(); | 3451 | WARN(1, "Unknown event %d\n", event); |
| 3450 | return -EINVAL; | 3452 | return -EINVAL; |
| 3451 | } | 3453 | } |
| 3452 | 3454 | ||
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 6ad4c7a47f5d..cbc9c96ce1f4 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c | |||
| @@ -230,7 +230,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | ret = snd_pcm_lib_preallocate_pages(substream, | 232 | ret = snd_pcm_lib_preallocate_pages(substream, |
| 233 | SNDRV_DMA_TYPE_DEV, | 233 | SNDRV_DMA_TYPE_DEV_IRAM, |
| 234 | dmaengine_dma_dev(pcm, substream), | 234 | dmaengine_dma_dev(pcm, substream), |
| 235 | prealloc_buffer_size, | 235 | prealloc_buffer_size, |
| 236 | max_buffer_size); | 236 | max_buffer_size); |
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 591f0f3074c5..42782c01e413 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
| 22 | #include <linux/pinctrl/consumer.h> | ||
| 22 | #include <linux/pm_runtime.h> | 23 | #include <linux/pm_runtime.h> |
| 23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
| 24 | #include <linux/workqueue.h> | 25 | #include <linux/workqueue.h> |
| @@ -183,6 +184,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
| 183 | struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver; | 184 | struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver; |
| 184 | int ret = 0; | 185 | int ret = 0; |
| 185 | 186 | ||
| 187 | pinctrl_pm_select_default_state(cpu_dai->dev); | ||
| 188 | pinctrl_pm_select_default_state(codec_dai->dev); | ||
| 186 | pm_runtime_get_sync(cpu_dai->dev); | 189 | pm_runtime_get_sync(cpu_dai->dev); |
| 187 | pm_runtime_get_sync(codec_dai->dev); | 190 | pm_runtime_get_sync(codec_dai->dev); |
| 188 | pm_runtime_get_sync(platform->dev); | 191 | pm_runtime_get_sync(platform->dev); |
| @@ -317,6 +320,10 @@ out: | |||
| 317 | pm_runtime_put(platform->dev); | 320 | pm_runtime_put(platform->dev); |
| 318 | pm_runtime_put(codec_dai->dev); | 321 | pm_runtime_put(codec_dai->dev); |
| 319 | pm_runtime_put(cpu_dai->dev); | 322 | pm_runtime_put(cpu_dai->dev); |
| 323 | if (!codec_dai->active) | ||
| 324 | pinctrl_pm_select_sleep_state(codec_dai->dev); | ||
| 325 | if (!cpu_dai->active) | ||
| 326 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | ||
| 320 | 327 | ||
| 321 | return ret; | 328 | return ret; |
| 322 | } | 329 | } |
| @@ -426,6 +433,10 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
| 426 | pm_runtime_put(platform->dev); | 433 | pm_runtime_put(platform->dev); |
| 427 | pm_runtime_put(codec_dai->dev); | 434 | pm_runtime_put(codec_dai->dev); |
| 428 | pm_runtime_put(cpu_dai->dev); | 435 | pm_runtime_put(cpu_dai->dev); |
| 436 | if (!codec_dai->active) | ||
| 437 | pinctrl_pm_select_sleep_state(codec_dai->dev); | ||
| 438 | if (!cpu_dai->active) | ||
| 439 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | ||
| 429 | 440 | ||
| 430 | return 0; | 441 | return 0; |
| 431 | } | 442 | } |
diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c index 52af7f6fb37f..364bf6a907e1 100644 --- a/sound/soc/tegra/tegra20_i2s.c +++ b/sound/soc/tegra/tegra20_i2s.c | |||
| @@ -297,7 +297,7 @@ static bool tegra20_i2s_wr_rd_reg(struct device *dev, unsigned int reg) | |||
| 297 | return true; | 297 | return true; |
| 298 | default: | 298 | default: |
| 299 | return false; | 299 | return false; |
| 300 | }; | 300 | } |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg) | 303 | static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg) |
| @@ -310,7 +310,7 @@ static bool tegra20_i2s_volatile_reg(struct device *dev, unsigned int reg) | |||
| 310 | return true; | 310 | return true; |
| 311 | default: | 311 | default: |
| 312 | return false; | 312 | return false; |
| 313 | }; | 313 | } |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg) | 316 | static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg) |
| @@ -321,7 +321,7 @@ static bool tegra20_i2s_precious_reg(struct device *dev, unsigned int reg) | |||
| 321 | return true; | 321 | return true; |
| 322 | default: | 322 | default: |
| 323 | return false; | 323 | return false; |
| 324 | }; | 324 | } |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | static const struct regmap_config tegra20_i2s_regmap_config = { | 327 | static const struct regmap_config tegra20_i2s_regmap_config = { |
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c index 551b3c93ce93..08bc6931c7c7 100644 --- a/sound/soc/tegra/tegra20_spdif.c +++ b/sound/soc/tegra/tegra20_spdif.c | |||
| @@ -213,7 +213,7 @@ static bool tegra20_spdif_wr_rd_reg(struct device *dev, unsigned int reg) | |||
| 213 | return true; | 213 | return true; |
| 214 | default: | 214 | default: |
| 215 | return false; | 215 | return false; |
| 216 | }; | 216 | } |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg) | 219 | static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg) |
| @@ -234,7 +234,7 @@ static bool tegra20_spdif_volatile_reg(struct device *dev, unsigned int reg) | |||
| 234 | return true; | 234 | return true; |
| 235 | default: | 235 | default: |
| 236 | return false; | 236 | return false; |
| 237 | }; | 237 | } |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg) | 240 | static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg) |
| @@ -247,7 +247,7 @@ static bool tegra20_spdif_precious_reg(struct device *dev, unsigned int reg) | |||
| 247 | return true; | 247 | return true; |
| 248 | default: | 248 | default: |
| 249 | return false; | 249 | return false; |
| 250 | }; | 250 | } |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | static const struct regmap_config tegra20_spdif_regmap_config = { | 253 | static const struct regmap_config tegra20_spdif_regmap_config = { |
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index bdd19db4a08b..31154338c1eb 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c | |||
| @@ -360,7 +360,7 @@ static bool tegra30_ahub_apbif_wr_rd_reg(struct device *dev, unsigned int reg) | |||
| 360 | return true; | 360 | return true; |
| 361 | default: | 361 | default: |
| 362 | break; | 362 | break; |
| 363 | }; | 363 | } |
| 364 | 364 | ||
| 365 | if (REG_IN_ARRAY(reg, CHANNEL_CTRL) || | 365 | if (REG_IN_ARRAY(reg, CHANNEL_CTRL) || |
| 366 | REG_IN_ARRAY(reg, CHANNEL_CLEAR) || | 366 | REG_IN_ARRAY(reg, CHANNEL_CLEAR) || |
| @@ -395,7 +395,7 @@ static bool tegra30_ahub_apbif_volatile_reg(struct device *dev, | |||
| 395 | return true; | 395 | return true; |
| 396 | default: | 396 | default: |
| 397 | break; | 397 | break; |
| 398 | }; | 398 | } |
| 399 | 399 | ||
| 400 | if (REG_IN_ARRAY(reg, CHANNEL_CLEAR) || | 400 | if (REG_IN_ARRAY(reg, CHANNEL_CLEAR) || |
| 401 | REG_IN_ARRAY(reg, CHANNEL_STATUS) || | 401 | REG_IN_ARRAY(reg, CHANNEL_STATUS) || |
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index 5f20b695eba2..231a785b3921 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c | |||
| @@ -376,7 +376,7 @@ static bool tegra30_i2s_wr_rd_reg(struct device *dev, unsigned int reg) | |||
| 376 | return true; | 376 | return true; |
| 377 | default: | 377 | default: |
| 378 | return false; | 378 | return false; |
| 379 | }; | 379 | } |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg) | 382 | static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg) |
| @@ -389,7 +389,7 @@ static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg) | |||
| 389 | return true; | 389 | return true; |
| 390 | default: | 390 | default: |
| 391 | return false; | 391 | return false; |
| 392 | }; | 392 | } |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | static const struct regmap_config tegra30_i2s_regmap_config = { | 395 | static const struct regmap_config tegra30_i2s_regmap_config = { |
diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index 45a6428cba8d..fbd077f4de72 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c | |||
| @@ -115,8 +115,8 @@ static void txx9aclc_dma_complete(void *arg) | |||
| 115 | spin_lock_irqsave(&dmadata->dma_lock, flags); | 115 | spin_lock_irqsave(&dmadata->dma_lock, flags); |
| 116 | if (dmadata->frag_count >= 0) { | 116 | if (dmadata->frag_count >= 0) { |
| 117 | dmadata->dmacount--; | 117 | dmadata->dmacount--; |
| 118 | BUG_ON(dmadata->dmacount < 0); | 118 | if (!WARN_ON(dmadata->dmacount < 0)) |
| 119 | tasklet_schedule(&dmadata->tasklet); | 119 | tasklet_schedule(&dmadata->tasklet); |
| 120 | } | 120 | } |
| 121 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | 121 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); |
| 122 | } | 122 | } |
| @@ -181,7 +181,10 @@ static void txx9aclc_dma_tasklet(unsigned long data) | |||
| 181 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | 181 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); |
| 182 | return; | 182 | return; |
| 183 | } | 183 | } |
| 184 | BUG_ON(dmadata->dmacount >= NR_DMA_CHAIN); | 184 | if (WARN_ON(dmadata->dmacount >= NR_DMA_CHAIN)) { |
| 185 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
| 186 | return; | ||
| 187 | } | ||
| 185 | while (dmadata->dmacount < NR_DMA_CHAIN) { | 188 | while (dmadata->dmacount < NR_DMA_CHAIN) { |
| 186 | dmadata->dmacount++; | 189 | dmadata->dmacount++; |
| 187 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | 190 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); |
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 54aaad2a10f5..dbb1b625eb2f 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c | |||
| @@ -429,7 +429,8 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, | |||
| 429 | unsigned int period_size = snd_pcm_lib_period_bytes(substream); | 429 | unsigned int period_size = snd_pcm_lib_period_bytes(substream); |
| 430 | unsigned int offset = period_size * (*periods_sent); | 430 | unsigned int offset = period_size * (*periods_sent); |
| 431 | 431 | ||
| 432 | BUG_ON(period_size >= (1 << 24)); | 432 | if (WARN_ON(period_size >= (1 << 24))) |
| 433 | return; | ||
| 433 | 434 | ||
| 434 | if (dma_cont->request(dma_cont, | 435 | if (dma_cont->request(dma_cont, |
| 435 | runtime->dma_addr + offset, period_size)) | 436 | runtime->dma_addr + offset, period_size)) |
| @@ -906,18 +907,24 @@ static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream) | |||
| 906 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); | 907 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
| 907 | struct snd_pcm_runtime *runtime = substream->runtime; | 908 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 908 | unsigned long flags; | 909 | unsigned long flags; |
| 910 | int ret = 0; | ||
| 909 | 911 | ||
| 910 | spin_lock_irqsave(&chip->lock, flags); | 912 | spin_lock_irqsave(&chip->lock, flags); |
| 911 | 913 | ||
| 912 | chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | | 914 | chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | |
| 913 | CS4231_PLAYBACK_PIO); | 915 | CS4231_PLAYBACK_PIO); |
| 914 | 916 | ||
| 915 | BUG_ON(runtime->period_size > 0xffff + 1); | 917 | if (WARN_ON(runtime->period_size > 0xffff + 1)) { |
| 918 | ret = -EINVAL; | ||
| 919 | goto out; | ||
| 920 | } | ||
| 916 | 921 | ||
| 917 | chip->p_periods_sent = 0; | 922 | chip->p_periods_sent = 0; |
| 923 | |||
| 924 | out: | ||
| 918 | spin_unlock_irqrestore(&chip->lock, flags); | 925 | spin_unlock_irqrestore(&chip->lock, flags); |
| 919 | 926 | ||
| 920 | return 0; | 927 | return ret; |
| 921 | } | 928 | } |
| 922 | 929 | ||
| 923 | static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, | 930 | static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, |
diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c index c39c77978468..66edc4a7917f 100644 --- a/sound/usb/6fire/chip.c +++ b/sound/usb/6fire/chip.c | |||
| @@ -101,7 +101,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf, | |||
| 101 | usb_set_intfdata(intf, chips[i]); | 101 | usb_set_intfdata(intf, chips[i]); |
| 102 | mutex_unlock(®ister_mutex); | 102 | mutex_unlock(®ister_mutex); |
| 103 | return 0; | 103 | return 0; |
| 104 | } else if (regidx < 0) | 104 | } else if (!devices[i] && regidx < 0) |
| 105 | regidx = i; | 105 | regidx = i; |
| 106 | } | 106 | } |
| 107 | if (regidx < 0) { | 107 | if (regidx < 0) { |
diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c index ae6b50f9ed56..f65fc0987cfb 100644 --- a/sound/usb/caiaq/control.c +++ b/sound/usb/caiaq/control.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include "control.h" | 28 | #include "control.h" |
| 29 | 29 | ||
| 30 | #define CNT_INTVAL 0x10000 | 30 | #define CNT_INTVAL 0x10000 |
| 31 | #define MASCHINE_BANK_SIZE 32 | ||
| 31 | 32 | ||
| 32 | static int control_info(struct snd_kcontrol *kcontrol, | 33 | static int control_info(struct snd_kcontrol *kcontrol, |
| 33 | struct snd_ctl_elem_info *uinfo) | 34 | struct snd_ctl_elem_info *uinfo) |
| @@ -105,6 +106,10 @@ static int control_put(struct snd_kcontrol *kcontrol, | |||
| 105 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) | 106 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) |
| 106 | cmd = EP1_CMD_DIMM_LEDS; | 107 | cmd = EP1_CMD_DIMM_LEDS; |
| 107 | 108 | ||
| 109 | if (cdev->chip.usb_id == | ||
| 110 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) | ||
| 111 | cmd = EP1_CMD_DIMM_LEDS; | ||
| 112 | |||
| 108 | if (pos & CNT_INTVAL) { | 113 | if (pos & CNT_INTVAL) { |
| 109 | int i = pos & ~CNT_INTVAL; | 114 | int i = pos & ~CNT_INTVAL; |
| 110 | 115 | ||
| @@ -121,6 +126,20 @@ static int control_put(struct snd_kcontrol *kcontrol, | |||
| 121 | usb_sndbulkpipe(cdev->chip.dev, 8), | 126 | usb_sndbulkpipe(cdev->chip.dev, 8), |
| 122 | cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf), | 127 | cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf), |
| 123 | &actual_len, 200); | 128 | &actual_len, 200); |
| 129 | } else if (cdev->chip.usb_id == | ||
| 130 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) { | ||
| 131 | |||
| 132 | int bank = 0; | ||
| 133 | int offset = 0; | ||
| 134 | |||
| 135 | if (i >= MASCHINE_BANK_SIZE) { | ||
| 136 | bank = 0x1e; | ||
| 137 | offset = MASCHINE_BANK_SIZE; | ||
| 138 | } | ||
| 139 | |||
| 140 | snd_usb_caiaq_send_command_bank(cdev, cmd, bank, | ||
| 141 | cdev->control_state + offset, | ||
| 142 | MASCHINE_BANK_SIZE); | ||
| 124 | } else { | 143 | } else { |
| 125 | snd_usb_caiaq_send_command(cdev, cmd, | 144 | snd_usb_caiaq_send_command(cdev, cmd, |
| 126 | cdev->control_state, sizeof(cdev->control_state)); | 145 | cdev->control_state, sizeof(cdev->control_state)); |
| @@ -490,6 +509,74 @@ static struct caiaq_controller kontrols4_controller[] = { | |||
| 490 | { "LED: FX2: Mode", 133 | CNT_INTVAL }, | 509 | { "LED: FX2: Mode", 133 | CNT_INTVAL }, |
| 491 | }; | 510 | }; |
| 492 | 511 | ||
| 512 | static struct caiaq_controller maschine_controller[] = { | ||
| 513 | { "LED: Pad 1", 3 | CNT_INTVAL }, | ||
| 514 | { "LED: Pad 2", 2 | CNT_INTVAL }, | ||
| 515 | { "LED: Pad 3", 1 | CNT_INTVAL }, | ||
| 516 | { "LED: Pad 4", 0 | CNT_INTVAL }, | ||
| 517 | { "LED: Pad 5", 7 | CNT_INTVAL }, | ||
| 518 | { "LED: Pad 6", 6 | CNT_INTVAL }, | ||
| 519 | { "LED: Pad 7", 5 | CNT_INTVAL }, | ||
| 520 | { "LED: Pad 8", 4 | CNT_INTVAL }, | ||
| 521 | { "LED: Pad 9", 11 | CNT_INTVAL }, | ||
| 522 | { "LED: Pad 10", 10 | CNT_INTVAL }, | ||
| 523 | { "LED: Pad 11", 9 | CNT_INTVAL }, | ||
| 524 | { "LED: Pad 12", 8 | CNT_INTVAL }, | ||
| 525 | { "LED: Pad 13", 15 | CNT_INTVAL }, | ||
| 526 | { "LED: Pad 14", 14 | CNT_INTVAL }, | ||
| 527 | { "LED: Pad 15", 13 | CNT_INTVAL }, | ||
| 528 | { "LED: Pad 16", 12 | CNT_INTVAL }, | ||
| 529 | |||
| 530 | { "LED: Mute", 16 | CNT_INTVAL }, | ||
| 531 | { "LED: Solo", 17 | CNT_INTVAL }, | ||
| 532 | { "LED: Select", 18 | CNT_INTVAL }, | ||
| 533 | { "LED: Duplicate", 19 | CNT_INTVAL }, | ||
| 534 | { "LED: Navigate", 20 | CNT_INTVAL }, | ||
| 535 | { "LED: Pad Mode", 21 | CNT_INTVAL }, | ||
| 536 | { "LED: Pattern", 22 | CNT_INTVAL }, | ||
| 537 | { "LED: Scene", 23 | CNT_INTVAL }, | ||
| 538 | |||
| 539 | { "LED: Shift", 24 | CNT_INTVAL }, | ||
| 540 | { "LED: Erase", 25 | CNT_INTVAL }, | ||
| 541 | { "LED: Grid", 26 | CNT_INTVAL }, | ||
| 542 | { "LED: Right Bottom", 27 | CNT_INTVAL }, | ||
| 543 | { "LED: Rec", 28 | CNT_INTVAL }, | ||
| 544 | { "LED: Play", 29 | CNT_INTVAL }, | ||
| 545 | { "LED: Left Bottom", 32 | CNT_INTVAL }, | ||
| 546 | { "LED: Restart", 33 | CNT_INTVAL }, | ||
| 547 | |||
| 548 | { "LED: Group A", 41 | CNT_INTVAL }, | ||
| 549 | { "LED: Group B", 40 | CNT_INTVAL }, | ||
| 550 | { "LED: Group C", 37 | CNT_INTVAL }, | ||
| 551 | { "LED: Group D", 36 | CNT_INTVAL }, | ||
| 552 | { "LED: Group E", 39 | CNT_INTVAL }, | ||
| 553 | { "LED: Group F", 38 | CNT_INTVAL }, | ||
| 554 | { "LED: Group G", 35 | CNT_INTVAL }, | ||
| 555 | { "LED: Group H", 34 | CNT_INTVAL }, | ||
| 556 | |||
| 557 | { "LED: Auto Write", 42 | CNT_INTVAL }, | ||
| 558 | { "LED: Snap", 43 | CNT_INTVAL }, | ||
| 559 | { "LED: Right Top", 44 | CNT_INTVAL }, | ||
| 560 | { "LED: Left Top", 45 | CNT_INTVAL }, | ||
| 561 | { "LED: Sampling", 46 | CNT_INTVAL }, | ||
| 562 | { "LED: Browse", 47 | CNT_INTVAL }, | ||
| 563 | { "LED: Step", 48 | CNT_INTVAL }, | ||
| 564 | { "LED: Control", 49 | CNT_INTVAL }, | ||
| 565 | |||
| 566 | { "LED: Top Button 1", 57 | CNT_INTVAL }, | ||
| 567 | { "LED: Top Button 2", 56 | CNT_INTVAL }, | ||
| 568 | { "LED: Top Button 3", 55 | CNT_INTVAL }, | ||
| 569 | { "LED: Top Button 4", 54 | CNT_INTVAL }, | ||
| 570 | { "LED: Top Button 5", 53 | CNT_INTVAL }, | ||
| 571 | { "LED: Top Button 6", 52 | CNT_INTVAL }, | ||
| 572 | { "LED: Top Button 7", 51 | CNT_INTVAL }, | ||
| 573 | { "LED: Top Button 8", 50 | CNT_INTVAL }, | ||
| 574 | |||
| 575 | { "LED: Note Repeat", 58 | CNT_INTVAL }, | ||
| 576 | |||
| 577 | { "Backlight Display", 59 | CNT_INTVAL } | ||
| 578 | }; | ||
| 579 | |||
| 493 | static int add_controls(struct caiaq_controller *c, int num, | 580 | static int add_controls(struct caiaq_controller *c, int num, |
| 494 | struct snd_usb_caiaqdev *cdev) | 581 | struct snd_usb_caiaqdev *cdev) |
| 495 | { | 582 | { |
| @@ -553,6 +640,11 @@ int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev) | |||
| 553 | ret = add_controls(kontrols4_controller, | 640 | ret = add_controls(kontrols4_controller, |
| 554 | ARRAY_SIZE(kontrols4_controller), cdev); | 641 | ARRAY_SIZE(kontrols4_controller), cdev); |
| 555 | break; | 642 | break; |
| 643 | |||
| 644 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | ||
| 645 | ret = add_controls(maschine_controller, | ||
| 646 | ARRAY_SIZE(maschine_controller), cdev); | ||
| 647 | break; | ||
| 556 | } | 648 | } |
| 557 | 649 | ||
| 558 | return ret; | 650 | return ret; |
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 1a61dd12fe38..bc55f708a696 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
| @@ -235,6 +235,31 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, | |||
| 235 | cdev->ep1_out_buf, len+1, &actual_len, 200); | 235 | cdev->ep1_out_buf, len+1, &actual_len, 200); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev, | ||
| 239 | unsigned char command, | ||
| 240 | unsigned char bank, | ||
| 241 | const unsigned char *buffer, | ||
| 242 | int len) | ||
| 243 | { | ||
| 244 | int actual_len; | ||
| 245 | struct usb_device *usb_dev = cdev->chip.dev; | ||
| 246 | |||
| 247 | if (!usb_dev) | ||
| 248 | return -EIO; | ||
| 249 | |||
| 250 | if (len > EP1_BUFSIZE - 2) | ||
| 251 | len = EP1_BUFSIZE - 2; | ||
| 252 | |||
| 253 | if (buffer && len > 0) | ||
| 254 | memcpy(cdev->ep1_out_buf+2, buffer, len); | ||
| 255 | |||
| 256 | cdev->ep1_out_buf[0] = command; | ||
| 257 | cdev->ep1_out_buf[1] = bank; | ||
| 258 | |||
| 259 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), | ||
| 260 | cdev->ep1_out_buf, len+2, &actual_len, 200); | ||
| 261 | } | ||
| 262 | |||
| 238 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, | 263 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, |
| 239 | int rate, int depth, int bpp) | 264 | int rate, int depth, int bpp) |
| 240 | { | 265 | { |
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index ad102fac6942..ab0f7520a99b 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h | |||
| @@ -128,5 +128,10 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, | |||
| 128 | unsigned char command, | 128 | unsigned char command, |
| 129 | const unsigned char *buffer, | 129 | const unsigned char *buffer, |
| 130 | int len); | 130 | int len); |
| 131 | int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev, | ||
| 132 | unsigned char command, | ||
| 133 | unsigned char bank, | ||
| 134 | const unsigned char *buffer, | ||
| 135 | int len); | ||
| 131 | 136 | ||
| 132 | #endif /* CAIAQ_DEVICE_H */ | 137 | #endif /* CAIAQ_DEVICE_H */ |
diff --git a/sound/usb/card.c b/sound/usb/card.c index 64952e2d3ed1..d979050e6a6a 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c | |||
| @@ -79,7 +79,6 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card * | |||
| 79 | /* Vendor/product IDs for this card */ | 79 | /* Vendor/product IDs for this card */ |
| 80 | static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; | 80 | static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; |
| 81 | static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; | 81 | static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; |
| 82 | static int nrpacks = 8; /* max. number of packets per urb */ | ||
| 83 | static int device_setup[SNDRV_CARDS]; /* device parameter for this card */ | 82 | static int device_setup[SNDRV_CARDS]; /* device parameter for this card */ |
| 84 | static bool ignore_ctl_error; | 83 | static bool ignore_ctl_error; |
| 85 | static bool autoclock = true; | 84 | static bool autoclock = true; |
| @@ -94,8 +93,6 @@ module_param_array(vid, int, NULL, 0444); | |||
| 94 | MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device."); | 93 | MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device."); |
| 95 | module_param_array(pid, int, NULL, 0444); | 94 | module_param_array(pid, int, NULL, 0444); |
| 96 | MODULE_PARM_DESC(pid, "Product ID for the USB audio device."); | 95 | MODULE_PARM_DESC(pid, "Product ID for the USB audio device."); |
| 97 | module_param(nrpacks, int, 0644); | ||
| 98 | MODULE_PARM_DESC(nrpacks, "Max. number of packets per URB."); | ||
| 99 | module_param_array(device_setup, int, NULL, 0444); | 96 | module_param_array(device_setup, int, NULL, 0444); |
| 100 | MODULE_PARM_DESC(device_setup, "Specific device setup (if needed)."); | 97 | MODULE_PARM_DESC(device_setup, "Specific device setup (if needed)."); |
| 101 | module_param(ignore_ctl_error, bool, 0444); | 98 | module_param(ignore_ctl_error, bool, 0444); |
| @@ -349,6 +346,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
| 349 | case USB_SPEED_LOW: | 346 | case USB_SPEED_LOW: |
| 350 | case USB_SPEED_FULL: | 347 | case USB_SPEED_FULL: |
| 351 | case USB_SPEED_HIGH: | 348 | case USB_SPEED_HIGH: |
| 349 | case USB_SPEED_WIRELESS: | ||
| 352 | case USB_SPEED_SUPER: | 350 | case USB_SPEED_SUPER: |
| 353 | break; | 351 | break; |
| 354 | default: | 352 | default: |
| @@ -374,7 +372,6 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
| 374 | chip->dev = dev; | 372 | chip->dev = dev; |
| 375 | chip->card = card; | 373 | chip->card = card; |
| 376 | chip->setup = device_setup[idx]; | 374 | chip->setup = device_setup[idx]; |
| 377 | chip->nrpacks = nrpacks; | ||
| 378 | chip->autoclock = autoclock; | 375 | chip->autoclock = autoclock; |
| 379 | chip->probing = 1; | 376 | chip->probing = 1; |
| 380 | 377 | ||
| @@ -754,19 +751,4 @@ static struct usb_driver usb_audio_driver = { | |||
| 754 | .supports_autosuspend = 1, | 751 | .supports_autosuspend = 1, |
| 755 | }; | 752 | }; |
| 756 | 753 | ||
| 757 | static int __init snd_usb_audio_init(void) | 754 | module_usb_driver(usb_audio_driver); |
| 758 | { | ||
| 759 | if (nrpacks < 1 || nrpacks > MAX_PACKS) { | ||
| 760 | printk(KERN_WARNING "invalid nrpacks value.\n"); | ||
| 761 | return -EINVAL; | ||
| 762 | } | ||
| 763 | return usb_register(&usb_audio_driver); | ||
| 764 | } | ||
| 765 | |||
| 766 | static void __exit snd_usb_audio_cleanup(void) | ||
| 767 | { | ||
| 768 | usb_deregister(&usb_audio_driver); | ||
| 769 | } | ||
| 770 | |||
| 771 | module_init(snd_usb_audio_init); | ||
| 772 | module_exit(snd_usb_audio_cleanup); | ||
diff --git a/sound/usb/card.h b/sound/usb/card.h index 5ecacaa90b53..9867ab866857 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | #define __USBAUDIO_CARD_H | 2 | #define __USBAUDIO_CARD_H |
| 3 | 3 | ||
| 4 | #define MAX_NR_RATES 1024 | 4 | #define MAX_NR_RATES 1024 |
| 5 | #define MAX_PACKS 20 | 5 | #define MAX_PACKS 6 /* per URB */ |
| 6 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ | 6 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ |
| 7 | #define MAX_URBS 8 | 7 | #define MAX_URBS 12 |
| 8 | #define SYNC_URBS 4 /* always four urbs for sync */ | 8 | #define SYNC_URBS 4 /* always four urbs for sync */ |
| 9 | #define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */ | 9 | #define MAX_QUEUE 18 /* try not to exceed this queue length, in ms */ |
| 10 | 10 | ||
| 11 | struct audioformat { | 11 | struct audioformat { |
| 12 | struct list_head list; | 12 | struct list_head list; |
| @@ -87,6 +87,7 @@ struct snd_usb_endpoint { | |||
| 87 | unsigned int phase; /* phase accumulator */ | 87 | unsigned int phase; /* phase accumulator */ |
| 88 | unsigned int maxpacksize; /* max packet size in bytes */ | 88 | unsigned int maxpacksize; /* max packet size in bytes */ |
| 89 | unsigned int maxframesize; /* max packet size in frames */ | 89 | unsigned int maxframesize; /* max packet size in frames */ |
| 90 | unsigned int max_urb_frames; /* max URB size in frames */ | ||
| 90 | unsigned int curpacksize; /* current packet size in bytes (for capture) */ | 91 | unsigned int curpacksize; /* current packet size in bytes (for capture) */ |
| 91 | unsigned int curframesize; /* current packet size in frames (for capture) */ | 92 | unsigned int curframesize; /* current packet size in frames (for capture) */ |
| 92 | unsigned int syncmaxsize; /* sync endpoint packet size */ | 93 | unsigned int syncmaxsize; /* sync endpoint packet size */ |
| @@ -95,7 +96,7 @@ struct snd_usb_endpoint { | |||
| 95 | unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */ | 96 | unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */ |
| 96 | unsigned char silence_value; | 97 | unsigned char silence_value; |
| 97 | unsigned int stride; | 98 | unsigned int stride; |
| 98 | int iface, alt_idx; | 99 | int iface, altsetting; |
| 99 | int skip_packets; /* quirks for devices to ignore the first n packets | 100 | int skip_packets; /* quirks for devices to ignore the first n packets |
| 100 | in a stream */ | 101 | in a stream */ |
| 101 | 102 | ||
| @@ -116,6 +117,8 @@ struct snd_usb_substream { | |||
| 116 | unsigned int channels_max; /* max channels in the all audiofmts */ | 117 | unsigned int channels_max; /* max channels in the all audiofmts */ |
| 117 | unsigned int cur_rate; /* current rate (for hw_params callback) */ | 118 | unsigned int cur_rate; /* current rate (for hw_params callback) */ |
| 118 | unsigned int period_bytes; /* current period bytes (for hw_params callback) */ | 119 | unsigned int period_bytes; /* current period bytes (for hw_params callback) */ |
| 120 | unsigned int period_frames; /* current frames per period */ | ||
| 121 | unsigned int buffer_periods; /* current periods per buffer */ | ||
| 119 | unsigned int altset_idx; /* USB data format: index of alternate setting */ | 122 | unsigned int altset_idx; /* USB data format: index of alternate setting */ |
| 120 | unsigned int txfr_quirk:1; /* allow sub-frame alignment */ | 123 | unsigned int txfr_quirk:1; /* allow sub-frame alignment */ |
| 121 | unsigned int fmt_type; /* USB audio format type (1-3) */ | 124 | unsigned int fmt_type; /* USB audio format type (1-3) */ |
| @@ -125,6 +128,7 @@ struct snd_usb_substream { | |||
| 125 | 128 | ||
| 126 | unsigned int hwptr_done; /* processed byte position in the buffer */ | 129 | unsigned int hwptr_done; /* processed byte position in the buffer */ |
| 127 | unsigned int transfer_done; /* processed frames since last period update */ | 130 | unsigned int transfer_done; /* processed frames since last period update */ |
| 131 | unsigned int frame_limit; /* limits number of packets in URB */ | ||
| 128 | 132 | ||
| 129 | /* data and sync endpoints for this stream */ | 133 | /* data and sync endpoints for this stream */ |
| 130 | unsigned int ep_num; /* the endpoint number */ | 134 | unsigned int ep_num; /* the endpoint number */ |
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 93e970f2b3c0..b9ba0fcc45df 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | #include "pcm.h" | 33 | #include "pcm.h" |
| 34 | #include "quirks.h" | 34 | #include "quirks.h" |
| 35 | 35 | ||
| 36 | #define EP_FLAG_ACTIVATED 0 | ||
| 37 | #define EP_FLAG_RUNNING 1 | 36 | #define EP_FLAG_RUNNING 1 |
| 38 | #define EP_FLAG_STOPPING 2 | 37 | #define EP_FLAG_STOPPING 2 |
| 39 | 38 | ||
| @@ -426,9 +425,9 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, | |||
| 426 | list_for_each_entry(ep, &chip->ep_list, list) { | 425 | list_for_each_entry(ep, &chip->ep_list, list) { |
| 427 | if (ep->ep_num == ep_num && | 426 | if (ep->ep_num == ep_num && |
| 428 | ep->iface == alts->desc.bInterfaceNumber && | 427 | ep->iface == alts->desc.bInterfaceNumber && |
| 429 | ep->alt_idx == alts->desc.bAlternateSetting) { | 428 | ep->altsetting == alts->desc.bAlternateSetting) { |
| 430 | snd_printdd(KERN_DEBUG "Re-using EP %x in iface %d,%d @%p\n", | 429 | snd_printdd(KERN_DEBUG "Re-using EP %x in iface %d,%d @%p\n", |
| 431 | ep_num, ep->iface, ep->alt_idx, ep); | 430 | ep_num, ep->iface, ep->altsetting, ep); |
| 432 | goto __exit_unlock; | 431 | goto __exit_unlock; |
| 433 | } | 432 | } |
| 434 | } | 433 | } |
| @@ -447,7 +446,7 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, | |||
| 447 | ep->type = type; | 446 | ep->type = type; |
| 448 | ep->ep_num = ep_num; | 447 | ep->ep_num = ep_num; |
| 449 | ep->iface = alts->desc.bInterfaceNumber; | 448 | ep->iface = alts->desc.bInterfaceNumber; |
| 450 | ep->alt_idx = alts->desc.bAlternateSetting; | 449 | ep->altsetting = alts->desc.bAlternateSetting; |
| 451 | INIT_LIST_HEAD(&ep->ready_playback_urbs); | 450 | INIT_LIST_HEAD(&ep->ready_playback_urbs); |
| 452 | ep_num &= USB_ENDPOINT_NUMBER_MASK; | 451 | ep_num &= USB_ENDPOINT_NUMBER_MASK; |
| 453 | 452 | ||
| @@ -574,11 +573,14 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, | |||
| 574 | snd_pcm_format_t pcm_format, | 573 | snd_pcm_format_t pcm_format, |
| 575 | unsigned int channels, | 574 | unsigned int channels, |
| 576 | unsigned int period_bytes, | 575 | unsigned int period_bytes, |
| 576 | unsigned int frames_per_period, | ||
| 577 | unsigned int periods_per_buffer, | ||
| 577 | struct audioformat *fmt, | 578 | struct audioformat *fmt, |
| 578 | struct snd_usb_endpoint *sync_ep) | 579 | struct snd_usb_endpoint *sync_ep) |
| 579 | { | 580 | { |
| 580 | unsigned int maxsize, i, urb_packs, total_packs, packs_per_ms; | 581 | unsigned int maxsize, minsize, packs_per_ms, max_packs_per_urb; |
| 581 | int is_playback = usb_pipeout(ep->pipe); | 582 | unsigned int max_packs_per_period, urbs_per_period, urb_packs; |
| 583 | unsigned int max_urbs, i; | ||
| 582 | int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; | 584 | int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; |
| 583 | 585 | ||
| 584 | if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) { | 586 | if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) { |
| @@ -611,58 +613,67 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, | |||
| 611 | else | 613 | else |
| 612 | ep->curpacksize = maxsize; | 614 | ep->curpacksize = maxsize; |
| 613 | 615 | ||
| 614 | if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) | 616 | if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) { |
| 615 | packs_per_ms = 8 >> ep->datainterval; | 617 | packs_per_ms = 8 >> ep->datainterval; |
| 616 | else | 618 | max_packs_per_urb = MAX_PACKS_HS; |
| 617 | packs_per_ms = 1; | ||
| 618 | |||
| 619 | if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) { | ||
| 620 | urb_packs = max(ep->chip->nrpacks, 1); | ||
| 621 | urb_packs = min(urb_packs, (unsigned int) MAX_PACKS); | ||
| 622 | } else { | 619 | } else { |
| 623 | urb_packs = 1; | 620 | packs_per_ms = 1; |
| 621 | max_packs_per_urb = MAX_PACKS; | ||
| 624 | } | 622 | } |
| 623 | if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep)) | ||
| 624 | max_packs_per_urb = min(max_packs_per_urb, | ||
| 625 | 1U << sync_ep->syncinterval); | ||
| 626 | max_packs_per_urb = max(1u, max_packs_per_urb >> ep->datainterval); | ||
| 625 | 627 | ||
| 626 | urb_packs *= packs_per_ms; | 628 | /* |
| 629 | * Capture endpoints need to use small URBs because there's no way | ||
| 630 | * to tell in advance where the next period will end, and we don't | ||
| 631 | * want the next URB to complete much after the period ends. | ||
| 632 | * | ||
| 633 | * Playback endpoints with implicit sync much use the same parameters | ||
| 634 | * as their corresponding capture endpoint. | ||
| 635 | */ | ||
| 636 | if (usb_pipein(ep->pipe) || | ||
| 637 | snd_usb_endpoint_implicit_feedback_sink(ep)) { | ||
| 627 | 638 | ||
| 628 | if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep)) | 639 | /* make capture URBs <= 1 ms and smaller than a period */ |
| 629 | urb_packs = min(urb_packs, 1U << sync_ep->syncinterval); | 640 | urb_packs = min(max_packs_per_urb, packs_per_ms); |
| 641 | while (urb_packs > 1 && urb_packs * maxsize >= period_bytes) | ||
| 642 | urb_packs >>= 1; | ||
| 643 | ep->nurbs = MAX_URBS; | ||
| 630 | 644 | ||
| 631 | /* decide how many packets to be used */ | 645 | /* |
| 632 | if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) { | 646 | * Playback endpoints without implicit sync are adjusted so that |
| 633 | unsigned int minsize, maxpacks; | 647 | * a period fits as evenly as possible in the smallest number of |
| 648 | * URBs. The total number of URBs is adjusted to the size of the | ||
| 649 | * ALSA buffer, subject to the MAX_URBS and MAX_QUEUE limits. | ||
| 650 | */ | ||
| 651 | } else { | ||
| 634 | /* determine how small a packet can be */ | 652 | /* determine how small a packet can be */ |
| 635 | minsize = (ep->freqn >> (16 - ep->datainterval)) | 653 | minsize = (ep->freqn >> (16 - ep->datainterval)) * |
| 636 | * (frame_bits >> 3); | 654 | (frame_bits >> 3); |
| 637 | /* with sync from device, assume it can be 12% lower */ | 655 | /* with sync from device, assume it can be 12% lower */ |
| 638 | if (sync_ep) | 656 | if (sync_ep) |
| 639 | minsize -= minsize >> 3; | 657 | minsize -= minsize >> 3; |
| 640 | minsize = max(minsize, 1u); | 658 | minsize = max(minsize, 1u); |
| 641 | total_packs = (period_bytes + minsize - 1) / minsize; | ||
| 642 | /* we need at least two URBs for queueing */ | ||
| 643 | if (total_packs < 2) { | ||
| 644 | total_packs = 2; | ||
| 645 | } else { | ||
| 646 | /* and we don't want too long a queue either */ | ||
| 647 | maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2); | ||
| 648 | total_packs = min(total_packs, maxpacks); | ||
| 649 | } | ||
| 650 | } else { | ||
| 651 | while (urb_packs > 1 && urb_packs * maxsize >= period_bytes) | ||
| 652 | urb_packs >>= 1; | ||
| 653 | total_packs = MAX_URBS * urb_packs; | ||
| 654 | } | ||
| 655 | 659 | ||
| 656 | ep->nurbs = (total_packs + urb_packs - 1) / urb_packs; | 660 | /* how many packets will contain an entire ALSA period? */ |
| 657 | if (ep->nurbs > MAX_URBS) { | 661 | max_packs_per_period = DIV_ROUND_UP(period_bytes, minsize); |
| 658 | /* too much... */ | 662 | |
| 659 | ep->nurbs = MAX_URBS; | 663 | /* how many URBs will contain a period? */ |
| 660 | total_packs = MAX_URBS * urb_packs; | 664 | urbs_per_period = DIV_ROUND_UP(max_packs_per_period, |
| 661 | } else if (ep->nurbs < 2) { | 665 | max_packs_per_urb); |
| 662 | /* too little - we need at least two packets | 666 | /* how many packets are needed in each URB? */ |
| 663 | * to ensure contiguous playback/capture | 667 | urb_packs = DIV_ROUND_UP(max_packs_per_period, urbs_per_period); |
| 664 | */ | 668 | |
| 665 | ep->nurbs = 2; | 669 | /* limit the number of frames in a single URB */ |
| 670 | ep->max_urb_frames = DIV_ROUND_UP(frames_per_period, | ||
| 671 | urbs_per_period); | ||
| 672 | |||
| 673 | /* try to use enough URBs to contain an entire ALSA buffer */ | ||
| 674 | max_urbs = min((unsigned) MAX_URBS, | ||
| 675 | MAX_QUEUE * packs_per_ms / urb_packs); | ||
| 676 | ep->nurbs = min(max_urbs, urbs_per_period * periods_per_buffer); | ||
| 666 | } | 677 | } |
| 667 | 678 | ||
| 668 | /* allocate and initialize data urbs */ | 679 | /* allocate and initialize data urbs */ |
| @@ -670,8 +681,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, | |||
| 670 | struct snd_urb_ctx *u = &ep->urb[i]; | 681 | struct snd_urb_ctx *u = &ep->urb[i]; |
| 671 | u->index = i; | 682 | u->index = i; |
| 672 | u->ep = ep; | 683 | u->ep = ep; |
| 673 | u->packets = (i + 1) * total_packs / ep->nurbs | 684 | u->packets = urb_packs; |
| 674 | - i * total_packs / ep->nurbs; | ||
| 675 | u->buffer_size = maxsize * u->packets; | 685 | u->buffer_size = maxsize * u->packets; |
| 676 | 686 | ||
| 677 | if (fmt->fmt_type == UAC_FORMAT_TYPE_II) | 687 | if (fmt->fmt_type == UAC_FORMAT_TYPE_II) |
| @@ -703,8 +713,7 @@ out_of_memory: | |||
| 703 | /* | 713 | /* |
| 704 | * configure a sync endpoint | 714 | * configure a sync endpoint |
| 705 | */ | 715 | */ |
| 706 | static int sync_ep_set_params(struct snd_usb_endpoint *ep, | 716 | static int sync_ep_set_params(struct snd_usb_endpoint *ep) |
| 707 | struct audioformat *fmt) | ||
| 708 | { | 717 | { |
| 709 | int i; | 718 | int i; |
| 710 | 719 | ||
| @@ -748,6 +757,8 @@ out_of_memory: | |||
| 748 | * @pcm_format: the audio fomat. | 757 | * @pcm_format: the audio fomat. |
| 749 | * @channels: the number of audio channels. | 758 | * @channels: the number of audio channels. |
| 750 | * @period_bytes: the number of bytes in one alsa period. | 759 | * @period_bytes: the number of bytes in one alsa period. |
| 760 | * @period_frames: the number of frames in one alsa period. | ||
| 761 | * @buffer_periods: the number of periods in one alsa buffer. | ||
| 751 | * @rate: the frame rate. | 762 | * @rate: the frame rate. |
| 752 | * @fmt: the USB audio format information | 763 | * @fmt: the USB audio format information |
| 753 | * @sync_ep: the sync endpoint to use, if any | 764 | * @sync_ep: the sync endpoint to use, if any |
| @@ -760,6 +771,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
| 760 | snd_pcm_format_t pcm_format, | 771 | snd_pcm_format_t pcm_format, |
| 761 | unsigned int channels, | 772 | unsigned int channels, |
| 762 | unsigned int period_bytes, | 773 | unsigned int period_bytes, |
| 774 | unsigned int period_frames, | ||
| 775 | unsigned int buffer_periods, | ||
| 763 | unsigned int rate, | 776 | unsigned int rate, |
| 764 | struct audioformat *fmt, | 777 | struct audioformat *fmt, |
| 765 | struct snd_usb_endpoint *sync_ep) | 778 | struct snd_usb_endpoint *sync_ep) |
| @@ -793,10 +806,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
| 793 | switch (ep->type) { | 806 | switch (ep->type) { |
| 794 | case SND_USB_ENDPOINT_TYPE_DATA: | 807 | case SND_USB_ENDPOINT_TYPE_DATA: |
| 795 | err = data_ep_set_params(ep, pcm_format, channels, | 808 | err = data_ep_set_params(ep, pcm_format, channels, |
| 796 | period_bytes, fmt, sync_ep); | 809 | period_bytes, period_frames, |
| 810 | buffer_periods, fmt, sync_ep); | ||
| 797 | break; | 811 | break; |
| 798 | case SND_USB_ENDPOINT_TYPE_SYNC: | 812 | case SND_USB_ENDPOINT_TYPE_SYNC: |
| 799 | err = sync_ep_set_params(ep, fmt); | 813 | err = sync_ep_set_params(ep); |
| 800 | break; | 814 | break; |
| 801 | default: | 815 | default: |
| 802 | err = -EINVAL; | 816 | err = -EINVAL; |
| @@ -931,28 +945,21 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep) | |||
| 931 | * | 945 | * |
| 932 | * @ep: the endpoint to deactivate | 946 | * @ep: the endpoint to deactivate |
| 933 | * | 947 | * |
| 934 | * If the endpoint is not currently in use, this functions will select the | 948 | * If the endpoint is not currently in use, this functions will |
| 935 | * alternate interface setting 0 for the interface of this endpoint. | 949 | * deactivate its associated URBs. |
| 936 | * | 950 | * |
| 937 | * In case of any active users, this functions does nothing. | 951 | * In case of any active users, this functions does nothing. |
| 938 | * | ||
| 939 | * Returns an error if usb_set_interface() failed, 0 in all other | ||
| 940 | * cases. | ||
| 941 | */ | 952 | */ |
| 942 | int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) | 953 | void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep) |
| 943 | { | 954 | { |
| 944 | if (!ep) | 955 | if (!ep) |
| 945 | return -EINVAL; | 956 | return; |
| 946 | |||
| 947 | deactivate_urbs(ep, true); | ||
| 948 | wait_clear_urbs(ep); | ||
| 949 | 957 | ||
| 950 | if (ep->use_count != 0) | 958 | if (ep->use_count != 0) |
| 951 | return 0; | 959 | return; |
| 952 | |||
| 953 | clear_bit(EP_FLAG_ACTIVATED, &ep->flags); | ||
| 954 | 960 | ||
| 955 | return 0; | 961 | deactivate_urbs(ep, true); |
| 962 | wait_clear_urbs(ep); | ||
| 956 | } | 963 | } |
| 957 | 964 | ||
| 958 | /** | 965 | /** |
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index 2287adf5ca59..1c7e8ee48abc 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h | |||
| @@ -12,6 +12,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
| 12 | snd_pcm_format_t pcm_format, | 12 | snd_pcm_format_t pcm_format, |
| 13 | unsigned int channels, | 13 | unsigned int channels, |
| 14 | unsigned int period_bytes, | 14 | unsigned int period_bytes, |
| 15 | unsigned int period_frames, | ||
| 16 | unsigned int buffer_periods, | ||
| 15 | unsigned int rate, | 17 | unsigned int rate, |
| 16 | struct audioformat *fmt, | 18 | struct audioformat *fmt, |
| 17 | struct snd_usb_endpoint *sync_ep); | 19 | struct snd_usb_endpoint *sync_ep); |
| @@ -20,7 +22,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep); | |||
| 20 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep); | 22 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep); |
| 21 | void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); | 23 | void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep); |
| 22 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); | 24 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); |
| 23 | int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); | 25 | void snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); |
| 24 | void snd_usb_endpoint_free(struct list_head *head); | 26 | void snd_usb_endpoint_free(struct list_head *head); |
| 25 | 27 | ||
| 26 | int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); | 28 | int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); |
diff --git a/sound/usb/helper.c b/sound/usb/helper.c index 620902463c6e..51ed1ac825fd 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c | |||
| @@ -118,6 +118,7 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip, | |||
| 118 | { | 118 | { |
| 119 | switch (snd_usb_get_speed(chip->dev)) { | 119 | switch (snd_usb_get_speed(chip->dev)) { |
| 120 | case USB_SPEED_HIGH: | 120 | case USB_SPEED_HIGH: |
| 121 | case USB_SPEED_WIRELESS: | ||
| 121 | case USB_SPEED_SUPER: | 122 | case USB_SPEED_SUPER: |
| 122 | if (get_endpoint(alts, 0)->bInterval >= 1 && | 123 | if (get_endpoint(alts, 0)->bInterval >= 1 && |
| 123 | get_endpoint(alts, 0)->bInterval <= 4) | 124 | get_endpoint(alts, 0)->bInterval <= 4) |
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 95558ef4a7a0..44b0ba4feab3 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
| @@ -1151,14 +1151,14 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, | |||
| 1151 | const char *names_to_check[] = { | 1151 | const char *names_to_check[] = { |
| 1152 | "Headset", "headset", "Headphone", "headphone", NULL}; | 1152 | "Headset", "headset", "Headphone", "headphone", NULL}; |
| 1153 | const char **s; | 1153 | const char **s; |
| 1154 | bool found = 0; | 1154 | bool found = false; |
| 1155 | 1155 | ||
| 1156 | if (strcmp("Speaker", kctl->id.name)) | 1156 | if (strcmp("Speaker", kctl->id.name)) |
| 1157 | return; | 1157 | return; |
| 1158 | 1158 | ||
| 1159 | for (s = names_to_check; *s; s++) | 1159 | for (s = names_to_check; *s; s++) |
| 1160 | if (strstr(card->shortname, *s)) { | 1160 | if (strstr(card->shortname, *s)) { |
| 1161 | found = 1; | 1161 | found = true; |
| 1162 | break; | 1162 | break; |
| 1163 | } | 1163 | } |
| 1164 | 1164 | ||
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index d42a584cf829..3454262358b3 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c | |||
| @@ -433,6 +433,89 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, | |||
| 433 | } | 433 | } |
| 434 | } | 434 | } |
| 435 | 435 | ||
| 436 | /* EMU0204 */ | ||
| 437 | static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol, | ||
| 438 | struct snd_ctl_elem_info *uinfo) | ||
| 439 | { | ||
| 440 | static const char *texts[2] = {"1/2", | ||
| 441 | "3/4" | ||
| 442 | }; | ||
| 443 | |||
| 444 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
| 445 | uinfo->count = 1; | ||
| 446 | uinfo->value.enumerated.items = 2; | ||
| 447 | if (uinfo->value.enumerated.item > 1) | ||
| 448 | uinfo->value.enumerated.item = 1; | ||
| 449 | strcpy(uinfo->value.enumerated.name, | ||
| 450 | texts[uinfo->value.enumerated.item]); | ||
| 451 | |||
| 452 | return 0; | ||
| 453 | } | ||
| 454 | |||
| 455 | static int snd_emu0204_ch_switch_get(struct snd_kcontrol *kcontrol, | ||
| 456 | struct snd_ctl_elem_value *ucontrol) | ||
| 457 | { | ||
| 458 | ucontrol->value.enumerated.item[0] = kcontrol->private_value; | ||
| 459 | return 0; | ||
| 460 | } | ||
| 461 | |||
| 462 | static int snd_emu0204_ch_switch_put(struct snd_kcontrol *kcontrol, | ||
| 463 | struct snd_ctl_elem_value *ucontrol) | ||
| 464 | { | ||
| 465 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
| 466 | unsigned int value = ucontrol->value.enumerated.item[0]; | ||
| 467 | int err, changed; | ||
| 468 | unsigned char buf[2]; | ||
| 469 | |||
| 470 | if (value > 1) | ||
| 471 | return -EINVAL; | ||
| 472 | |||
| 473 | buf[0] = 0x01; | ||
| 474 | buf[1] = value ? 0x02 : 0x01; | ||
| 475 | |||
| 476 | changed = value != kcontrol->private_value; | ||
| 477 | down_read(&mixer->chip->shutdown_rwsem); | ||
| 478 | if (mixer->chip->shutdown) { | ||
| 479 | err = -ENODEV; | ||
| 480 | goto out; | ||
| 481 | } | ||
| 482 | err = snd_usb_ctl_msg(mixer->chip->dev, | ||
| 483 | usb_sndctrlpipe(mixer->chip->dev, 0), UAC_SET_CUR, | ||
| 484 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, | ||
| 485 | 0x0400, 0x0e00, buf, 2); | ||
| 486 | out: | ||
| 487 | up_read(&mixer->chip->shutdown_rwsem); | ||
| 488 | if (err < 0) | ||
| 489 | return err; | ||
| 490 | kcontrol->private_value = value; | ||
| 491 | return changed; | ||
| 492 | } | ||
| 493 | |||
| 494 | |||
| 495 | static struct snd_kcontrol_new snd_emu0204_controls[] = { | ||
| 496 | { | ||
| 497 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 498 | .name = "Front Jack Channels", | ||
| 499 | .info = snd_emu0204_ch_switch_info, | ||
| 500 | .get = snd_emu0204_ch_switch_get, | ||
| 501 | .put = snd_emu0204_ch_switch_put, | ||
| 502 | .private_value = 0, | ||
| 503 | }, | ||
| 504 | }; | ||
| 505 | |||
| 506 | static int snd_emu0204_controls_create(struct usb_mixer_interface *mixer) | ||
| 507 | { | ||
| 508 | int i, err; | ||
| 509 | |||
| 510 | for (i = 0; i < ARRAY_SIZE(snd_emu0204_controls); ++i) { | ||
| 511 | err = snd_ctl_add(mixer->chip->card, | ||
| 512 | snd_ctl_new1(&snd_emu0204_controls[i], mixer)); | ||
| 513 | if (err < 0) | ||
| 514 | return err; | ||
| 515 | } | ||
| 516 | |||
| 517 | return 0; | ||
| 518 | } | ||
| 436 | /* ASUS Xonar U1 / U3 controls */ | 519 | /* ASUS Xonar U1 / U3 controls */ |
| 437 | 520 | ||
| 438 | static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol, | 521 | static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol, |
| @@ -1545,6 +1628,13 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) | |||
| 1545 | snd_audigy2nx_proc_read); | 1628 | snd_audigy2nx_proc_read); |
| 1546 | break; | 1629 | break; |
| 1547 | 1630 | ||
| 1631 | /* EMU0204 */ | ||
| 1632 | case USB_ID(0x041e, 0x3f19): | ||
| 1633 | err = snd_emu0204_controls_create(mixer); | ||
| 1634 | if (err < 0) | ||
| 1635 | break; | ||
| 1636 | break; | ||
| 1637 | |||
| 1548 | case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ | 1638 | case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ |
| 1549 | case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */ | 1639 | case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */ |
| 1550 | err = snd_c400_create_mixer(mixer); | 1640 | err = snd_c400_create_mixer(mixer); |
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index b375d58871e7..ca3256d6fde3 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
| @@ -241,16 +241,17 @@ static int start_endpoints(struct snd_usb_substream *subs, bool can_sleep) | |||
| 241 | struct snd_usb_endpoint *ep = subs->sync_endpoint; | 241 | struct snd_usb_endpoint *ep = subs->sync_endpoint; |
| 242 | 242 | ||
| 243 | if (subs->data_endpoint->iface != subs->sync_endpoint->iface || | 243 | if (subs->data_endpoint->iface != subs->sync_endpoint->iface || |
| 244 | subs->data_endpoint->alt_idx != subs->sync_endpoint->alt_idx) { | 244 | subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) { |
| 245 | err = usb_set_interface(subs->dev, | 245 | err = usb_set_interface(subs->dev, |
| 246 | subs->sync_endpoint->iface, | 246 | subs->sync_endpoint->iface, |
| 247 | subs->sync_endpoint->alt_idx); | 247 | subs->sync_endpoint->altsetting); |
| 248 | if (err < 0) { | 248 | if (err < 0) { |
| 249 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); | ||
| 249 | snd_printk(KERN_ERR | 250 | snd_printk(KERN_ERR |
| 250 | "%d:%d:%d: cannot set interface (%d)\n", | 251 | "%d:%d:%d: cannot set interface (%d)\n", |
| 251 | subs->dev->devnum, | 252 | subs->dev->devnum, |
| 252 | subs->sync_endpoint->iface, | 253 | subs->sync_endpoint->iface, |
| 253 | subs->sync_endpoint->alt_idx, err); | 254 | subs->sync_endpoint->altsetting, err); |
| 254 | return -EIO; | 255 | return -EIO; |
| 255 | } | 256 | } |
| 256 | } | 257 | } |
| @@ -282,22 +283,6 @@ static void stop_endpoints(struct snd_usb_substream *subs, bool wait) | |||
| 282 | } | 283 | } |
| 283 | } | 284 | } |
| 284 | 285 | ||
| 285 | static int deactivate_endpoints(struct snd_usb_substream *subs) | ||
| 286 | { | ||
| 287 | int reta, retb; | ||
| 288 | |||
| 289 | reta = snd_usb_endpoint_deactivate(subs->sync_endpoint); | ||
| 290 | retb = snd_usb_endpoint_deactivate(subs->data_endpoint); | ||
| 291 | |||
| 292 | if (reta < 0) | ||
| 293 | return reta; | ||
| 294 | |||
| 295 | if (retb < 0) | ||
| 296 | return retb; | ||
| 297 | |||
| 298 | return 0; | ||
| 299 | } | ||
| 300 | |||
| 301 | static int search_roland_implicit_fb(struct usb_device *dev, int ifnum, | 286 | static int search_roland_implicit_fb(struct usb_device *dev, int ifnum, |
| 302 | unsigned int altsetting, | 287 | unsigned int altsetting, |
| 303 | struct usb_host_interface **alts, | 288 | struct usb_host_interface **alts, |
| @@ -595,6 +580,7 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) | |||
| 595 | subs->pcm_format, | 580 | subs->pcm_format, |
| 596 | subs->channels, | 581 | subs->channels, |
| 597 | subs->period_bytes, | 582 | subs->period_bytes, |
| 583 | 0, 0, | ||
| 598 | subs->cur_rate, | 584 | subs->cur_rate, |
| 599 | subs->cur_audiofmt, | 585 | subs->cur_audiofmt, |
| 600 | NULL); | 586 | NULL); |
| @@ -631,6 +617,7 @@ static int configure_sync_endpoint(struct snd_usb_substream *subs) | |||
| 631 | subs->pcm_format, | 617 | subs->pcm_format, |
| 632 | sync_fp->channels, | 618 | sync_fp->channels, |
| 633 | sync_period_bytes, | 619 | sync_period_bytes, |
| 620 | 0, 0, | ||
| 634 | subs->cur_rate, | 621 | subs->cur_rate, |
| 635 | sync_fp, | 622 | sync_fp, |
| 636 | NULL); | 623 | NULL); |
| @@ -653,6 +640,8 @@ static int configure_endpoint(struct snd_usb_substream *subs) | |||
| 653 | subs->pcm_format, | 640 | subs->pcm_format, |
| 654 | subs->channels, | 641 | subs->channels, |
| 655 | subs->period_bytes, | 642 | subs->period_bytes, |
| 643 | subs->period_frames, | ||
| 644 | subs->buffer_periods, | ||
| 656 | subs->cur_rate, | 645 | subs->cur_rate, |
| 657 | subs->cur_audiofmt, | 646 | subs->cur_audiofmt, |
| 658 | subs->sync_endpoint); | 647 | subs->sync_endpoint); |
| @@ -689,6 +678,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, | |||
| 689 | 678 | ||
| 690 | subs->pcm_format = params_format(hw_params); | 679 | subs->pcm_format = params_format(hw_params); |
| 691 | subs->period_bytes = params_period_bytes(hw_params); | 680 | subs->period_bytes = params_period_bytes(hw_params); |
| 681 | subs->period_frames = params_period_size(hw_params); | ||
| 682 | subs->buffer_periods = params_periods(hw_params); | ||
| 692 | subs->channels = params_channels(hw_params); | 683 | subs->channels = params_channels(hw_params); |
| 693 | subs->cur_rate = params_rate(hw_params); | 684 | subs->cur_rate = params_rate(hw_params); |
| 694 | 685 | ||
| @@ -730,7 +721,8 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) | |||
| 730 | down_read(&subs->stream->chip->shutdown_rwsem); | 721 | down_read(&subs->stream->chip->shutdown_rwsem); |
| 731 | if (!subs->stream->chip->shutdown) { | 722 | if (!subs->stream->chip->shutdown) { |
| 732 | stop_endpoints(subs, true); | 723 | stop_endpoints(subs, true); |
| 733 | deactivate_endpoints(subs); | 724 | snd_usb_endpoint_deactivate(subs->sync_endpoint); |
| 725 | snd_usb_endpoint_deactivate(subs->data_endpoint); | ||
| 734 | } | 726 | } |
| 735 | up_read(&subs->stream->chip->shutdown_rwsem); | 727 | up_read(&subs->stream->chip->shutdown_rwsem); |
| 736 | return snd_pcm_lib_free_vmalloc_buffer(substream); | 728 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
| @@ -1363,6 +1355,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
| 1363 | frames = 0; | 1355 | frames = 0; |
| 1364 | urb->number_of_packets = 0; | 1356 | urb->number_of_packets = 0; |
| 1365 | spin_lock_irqsave(&subs->lock, flags); | 1357 | spin_lock_irqsave(&subs->lock, flags); |
| 1358 | subs->frame_limit += ep->max_urb_frames; | ||
| 1366 | for (i = 0; i < ctx->packets; i++) { | 1359 | for (i = 0; i < ctx->packets; i++) { |
| 1367 | if (ctx->packet_size[i]) | 1360 | if (ctx->packet_size[i]) |
| 1368 | counts = ctx->packet_size[i]; | 1361 | counts = ctx->packet_size[i]; |
| @@ -1377,6 +1370,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
| 1377 | subs->transfer_done += counts; | 1370 | subs->transfer_done += counts; |
| 1378 | if (subs->transfer_done >= runtime->period_size) { | 1371 | if (subs->transfer_done >= runtime->period_size) { |
| 1379 | subs->transfer_done -= runtime->period_size; | 1372 | subs->transfer_done -= runtime->period_size; |
| 1373 | subs->frame_limit = 0; | ||
| 1380 | period_elapsed = 1; | 1374 | period_elapsed = 1; |
| 1381 | if (subs->fmt_type == UAC_FORMAT_TYPE_II) { | 1375 | if (subs->fmt_type == UAC_FORMAT_TYPE_II) { |
| 1382 | if (subs->transfer_done > 0) { | 1376 | if (subs->transfer_done > 0) { |
| @@ -1399,8 +1393,10 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
| 1399 | break; | 1393 | break; |
| 1400 | } | 1394 | } |
| 1401 | } | 1395 | } |
| 1402 | if (period_elapsed && | 1396 | /* finish at the period boundary or after enough frames */ |
| 1403 | !snd_usb_endpoint_implicit_feedback_sink(subs->data_endpoint)) /* finish at the period boundary */ | 1397 | if ((period_elapsed || |
| 1398 | subs->transfer_done >= subs->frame_limit) && | ||
| 1399 | !snd_usb_endpoint_implicit_feedback_sink(ep)) | ||
| 1404 | break; | 1400 | break; |
| 1405 | } | 1401 | } |
| 1406 | bytes = frames * ep->stride; | 1402 | bytes = frames * ep->stride; |
diff --git a/sound/usb/stream.c b/sound/usb/stream.c index c4339f97226b..2fb71be5e100 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c | |||
| @@ -273,16 +273,14 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, | |||
| 273 | SNDRV_CHMAP_TSL, /* top side left */ | 273 | SNDRV_CHMAP_TSL, /* top side left */ |
| 274 | SNDRV_CHMAP_TSR, /* top side right */ | 274 | SNDRV_CHMAP_TSR, /* top side right */ |
| 275 | SNDRV_CHMAP_BC, /* bottom center */ | 275 | SNDRV_CHMAP_BC, /* bottom center */ |
| 276 | SNDRV_CHMAP_BLC, /* bottom left center */ | 276 | SNDRV_CHMAP_RLC, /* back left of center */ |
| 277 | SNDRV_CHMAP_BRC, /* bottom right center */ | 277 | SNDRV_CHMAP_RRC, /* back right of center */ |
| 278 | 0 /* terminator */ | 278 | 0 /* terminator */ |
| 279 | }; | 279 | }; |
| 280 | struct snd_pcm_chmap_elem *chmap; | 280 | struct snd_pcm_chmap_elem *chmap; |
| 281 | const unsigned int *maps; | 281 | const unsigned int *maps; |
| 282 | int c; | 282 | int c; |
| 283 | 283 | ||
| 284 | if (!bits) | ||
| 285 | return NULL; | ||
| 286 | if (channels > ARRAY_SIZE(chmap->map)) | 284 | if (channels > ARRAY_SIZE(chmap->map)) |
| 287 | return NULL; | 285 | return NULL; |
| 288 | 286 | ||
| @@ -293,9 +291,19 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, | |||
| 293 | maps = protocol == UAC_VERSION_2 ? uac2_maps : uac1_maps; | 291 | maps = protocol == UAC_VERSION_2 ? uac2_maps : uac1_maps; |
| 294 | chmap->channels = channels; | 292 | chmap->channels = channels; |
| 295 | c = 0; | 293 | c = 0; |
| 296 | for (; bits && *maps; maps++, bits >>= 1) { | 294 | |
| 297 | if (bits & 1) | 295 | if (bits) { |
| 298 | chmap->map[c++] = *maps; | 296 | for (; bits && *maps; maps++, bits >>= 1) |
| 297 | if (bits & 1) | ||
| 298 | chmap->map[c++] = *maps; | ||
| 299 | } else { | ||
| 300 | /* If we're missing wChannelConfig, then guess something | ||
| 301 | to make sure the channel map is not skipped entirely */ | ||
| 302 | if (channels == 1) | ||
| 303 | chmap->map[c++] = SNDRV_CHMAP_MONO; | ||
| 304 | else | ||
| 305 | for (; c < channels && *maps; maps++) | ||
| 306 | chmap->map[c++] = *maps; | ||
| 299 | } | 307 | } |
| 300 | 308 | ||
| 301 | for (; c < channels; c++) | 309 | for (; c < channels; c++) |
| @@ -579,6 +587,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
| 579 | 587 | ||
| 580 | num_channels = as->bNrChannels; | 588 | num_channels = as->bNrChannels; |
| 581 | format = le32_to_cpu(as->bmFormats); | 589 | format = le32_to_cpu(as->bmFormats); |
| 590 | chconfig = le32_to_cpu(as->bmChannelConfig); | ||
| 582 | 591 | ||
| 583 | /* lookup the terminal associated to this interface | 592 | /* lookup the terminal associated to this interface |
| 584 | * to extract the clock */ | 593 | * to extract the clock */ |
| @@ -586,7 +595,8 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
| 586 | as->bTerminalLink); | 595 | as->bTerminalLink); |
| 587 | if (input_term) { | 596 | if (input_term) { |
| 588 | clock = input_term->bCSourceID; | 597 | clock = input_term->bCSourceID; |
| 589 | chconfig = le32_to_cpu(input_term->bmChannelConfig); | 598 | if (!chconfig && (num_channels == input_term->bNrChannels)) |
| 599 | chconfig = le32_to_cpu(input_term->bmChannelConfig); | ||
| 590 | break; | 600 | break; |
| 591 | } | 601 | } |
| 592 | 602 | ||
| @@ -652,7 +662,6 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
| 652 | * (fp->maxpacksize & 0x7ff); | 662 | * (fp->maxpacksize & 0x7ff); |
| 653 | fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); | 663 | fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); |
| 654 | fp->clock = clock; | 664 | fp->clock = clock; |
| 655 | fp->chmap = convert_chmap(num_channels, chconfig, protocol); | ||
| 656 | 665 | ||
| 657 | /* some quirks for attributes here */ | 666 | /* some quirks for attributes here */ |
| 658 | 667 | ||
| @@ -688,12 +697,16 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
| 688 | /* ok, let's parse further... */ | 697 | /* ok, let's parse further... */ |
| 689 | if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) { | 698 | if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) { |
| 690 | kfree(fp->rate_table); | 699 | kfree(fp->rate_table); |
| 691 | kfree(fp->chmap); | ||
| 692 | kfree(fp); | 700 | kfree(fp); |
| 693 | fp = NULL; | 701 | fp = NULL; |
| 694 | continue; | 702 | continue; |
| 695 | } | 703 | } |
| 696 | 704 | ||
| 705 | /* Create chmap */ | ||
| 706 | if (fp->channels != num_channels) | ||
| 707 | chconfig = 0; | ||
| 708 | fp->chmap = convert_chmap(fp->channels, chconfig, protocol); | ||
| 709 | |||
| 697 | snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint); | 710 | snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint); |
| 698 | err = snd_usb_add_audio_stream(chip, stream, fp); | 711 | err = snd_usb_add_audio_stream(chip, stream, fp); |
| 699 | if (err < 0) { | 712 | if (err < 0) { |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index caabe9b3af49..5d2fe0530745 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
| @@ -55,7 +55,6 @@ struct snd_usb_audio { | |||
| 55 | struct list_head mixer_list; /* list of mixer interfaces */ | 55 | struct list_head mixer_list; /* list of mixer interfaces */ |
| 56 | 56 | ||
| 57 | int setup; /* from the 'device_setup' module param */ | 57 | int setup; /* from the 'device_setup' module param */ |
| 58 | int nrpacks; /* from the 'nrpacks' module param */ | ||
| 59 | bool autoclock; /* from the 'autoclock' module param */ | 58 | bool autoclock; /* from the 'autoclock' module param */ |
| 60 | 59 | ||
| 61 | struct usb_host_interface *ctrl_intf; /* the audio control interface */ | 60 | struct usb_host_interface *ctrl_intf; /* the audio control interface */ |
