ALSA: hda - add DP mst verb support
PATCH 1/1 ALSA: hda - add DP mst verb support
From: Libin Yang <[email protected]>
Add snd_hda_get_dev_select() and snd_hda_set_dev_select() functions for DP MST audio support.
--- sound/pci/hda/hda_codec.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_codec.h | 2 ++ 2 files changed, 56 insertions(+)
sound/pci/hda/hda_codec.c +54 -0
@@ -368,6 +368,60 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,return devices; } +/** +* snd_hda_get_dev_select - get device entry select on the pin +* @codec: the HDA codec +* @nid: NID of the pin to get device entry select +* +* Get the devcie entry select on the pin. Return the device entry +* id selected on the pin. Return 0 means the first device entry +* is selected or MST is not supported. +*/ +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid) +{ +/* not support dp_mst will always return 0, using first dev_entry */ +if (!codec->dp_mst) +return 0 ; + +return snd_hda_codec_read (codec, nid,0 ,AC_VERB_GET_DEVICE_SEL ,0 ); +} +EXPORT_SYMBOL_GPL (snd_hda_get_dev_select); + +/** +* snd_hda_set_dev_select - set device entry select on the pin +* @codec: the HDA codec +* @nid: NID of the pin to set device entry select +* @dev_id: device entry id to be set +* +* Set the device entry select on the pin nid. +*/ +int snd_hda_set_dev_select (struct hda_codec *codec,hda_nid_t nid,int dev_id) +{ +int ret, dev; +unsigned long timeout; + +/* not support dp_mst will always return 0, using first dev_entry */ +if (!codec->dp_mst) +return 0 ; + + timeout = jiffies +msecs_to_jiffies (500 ); + +/* make sure the device entry selection takes effect */ +do { + ret =snd_hda_codec_write (codec, nid,0 , +AC_VERB_SET_DEVICE_SEL , dev_id); +udelay (20 ); + + dev =snd_hda_get_dev_select (codec, nid); +if (dev == dev_id) +break ; +msleep (20 ); + }while (time_before (jiffies, timeout)); + +return ret; +} +EXPORT_SYMBOL_GPL (snd_hda_set_dev_select); +/* * read widget caps for each widget and store in cache */
sound/pci/hda/hda_codec.h +2 -0
@@ -349,6 +349,8 @@ int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux, hda_nid_t nid, int recursive);int snd_hda_get_devices (struct hda_codec *codec,hda_nid_t nid,u8 *dev_list,int max_devices); +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid); +int snd_hda_set_dev_select (struct hda_codec *codec,hda_nid_t nid,int dev_id);struct hda_verb {hda_nid_t nid;
Signature · 1 line
1.9.1
Quoted 36 lines · On Wed, 13 Jan 2016 12:09:49 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add
snd_hda_get_dev_select()andsnd_hda_set_dev_select()functions for DP MST audio support.Signed-off-by Libin Yang <[email protected]>--- sound/pci/hda/hda_codec.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_codec.h | 2 ++ 2 files changed, 56 insertions(+)sound/pci/hda/hda_codec.c +16
-0@@ -368,6 +368,60 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,return devices; } +/** +* snd_hda_get_dev_select - get device entry select on the pin +* @codec: the HDA codec +* @nid: NID of the pin to get device entry select +* +* Get the devcie entry select on the pin. Return the device entry +* id selected on the pin. Return 0 means the first device entry +* is selected or MST is not supported. +*/ +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid) +{ +/* not support dp_mst will always return 0, using first dev_entry */ +if (!codec->dp_mst) +return 0 ; + +return snd_hda_codec_read (codec, nid,0 ,AC_VERB_GET_DEVICE_SEL ,0 );
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, · line 396
Quoted 10 lines
sound/pci/hda/hda_codec.c +10
-0+} +EXPORT_SYMBOL_GPL (snd_hda_get_dev_select); + +/** +* snd_hda_set_dev_select - set device entry select on the pin +* @codec: the HDA codec +* @nid: NID of the pin to set device entry select +* @dev_id: device entry id to be set +* +* Set the device entry select on the pin nid.
The return code isn't clearly defined.
Other than that, it looks OK. But I prefer merging this rather together with its caller (unless a complex dependency exists).
thanks,
Takashi
Quoted 47 lines
sound/pci/hda/hda_codec.c +28
-0+*/ +int snd_hda_set_dev_select (struct hda_codec *codec,hda_nid_t nid,int dev_id) +{ +int ret, dev; +unsigned long timeout; + +/* not support dp_mst will always return 0, using first dev_entry */ +if (!codec->dp_mst) +return 0 ; + + timeout = jiffies +msecs_to_jiffies (500 ); + +/* make sure the device entry selection takes effect */ +do { + ret =snd_hda_codec_write (codec, nid,0 , +AC_VERB_SET_DEVICE_SEL , dev_id); +udelay (20 ); + + dev =snd_hda_get_dev_select (codec, nid); +if (dev == dev_id) +break ; +msleep (20 ); + }while (time_before (jiffies, timeout)); + +return ret; +} +EXPORT_SYMBOL_GPL (snd_hda_set_dev_select); +/* * read widget caps for each widget and store in cache */ sound/pci/hda/hda_codec.h +2
-0@@ -349,6 +349,8 @@ int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux, hda_nid_t nid, int recursive);int snd_hda_get_devices (struct hda_codec *codec,hda_nid_t nid,u8 *dev_list,int max_devices); +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid); +int snd_hda_set_dev_select (struct hda_codec *codec,hda_nid_t nid,int dev_id);struct hda_verb {hda_nid_t nid;Signature · 1 line
1.9.1
Quoted 64 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, January 13, 2016 7:25 PM
To: [email protected]
Cc: [email protected]; Lin, Mengdong; Yang, Libin
Subject: Re: [PATCH] ALSA: hda - add DP mst verb supportQuoted 4 lines · On Wed, 13 Jan 2016 12:09:49 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add
snd_hda_get_dev_select()andsnd_hda_set_dev_select()functions
Quoted 5 lines
for DP MST audio support.
Signed-off-by Libin Yang <[email protected]>--- sound/pci/hda/hda_codec.c | 54+++++++++++++++++++++++++++++++++++++++++++++++
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec
Quoted 8 lines
sound/pci/hda/hda_codec.h | 2 ++ 2 files changed, 56 insertions(+)sound/pci/hda/hda_codec.c +0
-0@@ -368,6 +368,60 @@ int snd_hda_get_devices(struct hda_codec*codec,
hda_nid_tnid,Quoted 5 lines
sound/pci/hda/hda_codec.c +2
-0return devices; } +/** +* snd_hda_get_dev_select - get device entry select on the pin sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
Quoted 10 lines
sound/pci/hda/hda_codec.c +10
-0+* @codec: the HDA codec +* @nid: NID of the pin to get device entry select +* +* Get the devcie entry select on the pin. Return the device entry +* id selected on the pin. Return 0 means the first device entry +* is selected or MST is not supported. +*/ +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid) +{ +/* not support dp_mst will always return 0, using first dev_entry */
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
Quoted 4 lines
sound/pci/hda/hda_codec.c +4
-0+if (!codec->dp_mst) +return 0 ; + + return snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_DEVICE_SEL, 0);sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, · line 396
Quoted 10 lines
sound/pci/hda/hda_codec.c +10
-0+} +EXPORT_SYMBOL_GPL (snd_hda_get_dev_select); + +/** +* snd_hda_set_dev_select - set device entry select on the pin +* @codec: the HDA codec +* @nid: NID of the pin to set device entry select +* @dev_id: device entry id to be set +* +* Set the device entry select on the pin nid. The return code isn't clearly defined.
Quoted 1 line
Other than that, it looks OK.
What about return dev_id returned from snd_hda_get_dev_select() Or return true if it sets dev_id successfully and false for failure.
Quoted 2 lines
But I prefer merging this rather
together with its caller (unless a complex dependency exists).
OK. I will submit the patch later.
Regards,
Libin
Quoted 57 lines
thanks,
Takashi
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec · line 398
Quoted 2 lines
sound/pci/hda/hda_codec.c +2
-0+*/ +int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid,int
dev_id)sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
Quoted 5 lines
sound/pci/hda/hda_codec.c +5
-0+{ +int ret, dev; +unsigned long timeout; + +/* not support dp_mst will always return 0, using first dev_entry */
sound/pci/hda/hda_codec.h int snd_hda_get_conn_index(struct
Quoted 29 lines
sound/pci/hda/hda_codec.c +21
-0+if (!codec->dp_mst) +return 0 ; + + timeout = jiffies +msecs_to_jiffies (500 ); + +/* make sure the device entry selection takes effect */ +do { + ret =snd_hda_codec_write (codec, nid,0 , +AC_VERB_SET_DEVICE_SEL , dev_id); +udelay (20 ); + + dev =snd_hda_get_dev_select (codec, nid); +if (dev == dev_id) +break ; +msleep (20 ); + }while (time_before (jiffies, timeout)); + +return ret; +} +EXPORT_SYMBOL_GPL (snd_hda_set_dev_select); +/* * read widget caps for each widget and store in cache */ sound/pci/hda/hda_codec.h +0
-0@@ -349,6 +349,8 @@ int snd_hda_get_conn_index(struct
hda_codec*codec,hda_nid_tmux,sound/pci/hda/hda_codec.h int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
Quoted 5 lines
sound/pci/hda/hda_codec.h +2
-0hda_nid_t nid, int recursive);int snd_hda_get_devices (struct hda_codec *codec,hda_nid_t nid,u8 *dev_list,int max_devices); +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid); +int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid,int
dev_id);Quoted 6 lines
sound/pci/hda/hda_codec.h +0
-1struct hda_verb {hda_nid_t nid; --1.9.1
Quoted 65 lines · Libin
Quoted 65 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, January 13, 2016 7:25 PM
To: [email protected]
Cc: [email protected]; Lin, Mengdong; Yang, Libin
Subject: Re: [PATCH] ALSA: hda - add DP mst verb supportQuoted 4 lines · On Wed, 13 Jan 2016 12:09:49 +0100, [email protected] wrote:
From: Libin Yang <[email protected]>
Add
snd_hda_get_dev_select()andsnd_hda_set_dev_select()functions
Quoted 5 lines
for DP MST audio support.
Signed-off-by Libin Yang <[email protected]>--- sound/pci/hda/hda_codec.c | 54+++++++++++++++++++++++++++++++++++++++++++++++
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec
Quoted 8 lines
sound/pci/hda/hda_codec.h | 2 ++ 2 files changed, 56 insertions(+)sound/pci/hda/hda_codec.c +0
-0@@ -368,6 +368,60 @@ int snd_hda_get_devices(struct hda_codec*codec,
hda_nid_tnid,Quoted 5 lines
sound/pci/hda/hda_codec.c +2
-0return devices; } +/** +* snd_hda_get_dev_select - get device entry select on the pin sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
Quoted 10 lines
sound/pci/hda/hda_codec.c +10
-0+* @codec: the HDA codec +* @nid: NID of the pin to get device entry select +* +* Get the devcie entry select on the pin. Return the device entry +* id selected on the pin. Return 0 means the first device entry +* is selected or MST is not supported. +*/ +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid) +{ +/* not support dp_mst will always return 0, using first dev_entry */
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
Quoted 4 lines
sound/pci/hda/hda_codec.c +4
-0+if (!codec->dp_mst) +return 0 ; + + return snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_DEVICE_SEL, 0);sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, · line 396
Quoted 10 lines
sound/pci/hda/hda_codec.c +10
-0+} +EXPORT_SYMBOL_GPL (snd_hda_get_dev_select); + +/** +* snd_hda_set_dev_select - set device entry select on the pin +* @codec: the HDA codec +* @nid: NID of the pin to set device entry select +* @dev_id: device entry id to be set +* +* Set the device entry select on the pin nid. The return code isn't clearly defined.
Quoted 3 lines
Quoted 1 line
Other than that, it looks OK.
What about return
dev_idreturned fromsnd_hda_get_dev_select()
... plus a negative error code.
Quoted 1 line
Or return true if it sets
dev_idsuccessfully and false for failure.
I don't mind in either way.
Quoted 4 lines
Quoted 2 lines
But I prefer merging this rather
together with its caller (unless a complex dependency exists).OK. I will submit the patch later.
OK, thanks.
Takashi
Quoted 61 lines
Regards,
LibinQuoted 57 lines
thanks,
Takashi
sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec · line 398
Quoted 2 lines
sound/pci/hda/hda_codec.c +2
-0+*/ +int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid,int
dev_id)sound/pci/hda/hda_codec.c int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
Quoted 5 lines
sound/pci/hda/hda_codec.c +5
-0+{ +int ret, dev; +unsigned long timeout; + +/* not support dp_mst will always return 0, using first dev_entry */
sound/pci/hda/hda_codec.h int snd_hda_get_conn_index(struct
Quoted 29 lines
sound/pci/hda/hda_codec.c +21
-0+if (!codec->dp_mst) +return 0 ; + + timeout = jiffies +msecs_to_jiffies (500 ); + +/* make sure the device entry selection takes effect */ +do { + ret =snd_hda_codec_write (codec, nid,0 , +AC_VERB_SET_DEVICE_SEL , dev_id); +udelay (20 ); + + dev =snd_hda_get_dev_select (codec, nid); +if (dev == dev_id) +break ; +msleep (20 ); + }while (time_before (jiffies, timeout)); + +return ret; +} +EXPORT_SYMBOL_GPL (snd_hda_set_dev_select); +/* * read widget caps for each widget and store in cache */ sound/pci/hda/hda_codec.h +0
-0@@ -349,6 +349,8 @@ int snd_hda_get_conn_index(struct
hda_codec*codec,hda_nid_tmux,sound/pci/hda/hda_codec.h int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
Quoted 5 lines
sound/pci/hda/hda_codec.h +2
-0hda_nid_t nid, int recursive);int snd_hda_get_devices (struct hda_codec *codec,hda_nid_t nid,u8 *dev_list,int max_devices); +int snd_hda_get_dev_select (struct hda_codec *codec,hda_nid_t nid); +int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid,int
dev_id);Quoted 6 lines
sound/pci/hda/hda_codec.h +0
-1struct hda_verb {hda_nid_t nid; --1.9.1