ASoC: rt-sdw-common: Common functions for Realtek soundwire driver
Subsystems (3)
PATCH v2 1/1 ASoC: rt-sdw-common: Common functions for Realtek soundwire driver
This is the first version of common functions for Realtek soundwire codec driver.
--- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt-sdw-common.c | 238 +++++++++++++++++++++++++++++++ sound/soc/codecs/rt-sdw-common.h | 66 +++++++++ 4 files changed, 311 insertions(+) create mode 100644 sound/soc/codecs/rt-sdw-common.c create mode 100644 sound/soc/codecs/rt-sdw-common.h
sound/soc/codecs/Kconfig +5 -0
@@ -1545,6 +1545,11 @@ config SND_SOC_RL6231 default m if SND_SOC_RT1305=m default m if SND_SOC_RT1308=m +config SND_SOC_RT_SDW_COMMON + tristate + default y if SND_SOC_RT721_SDCA_SDW=y + default m if SND_SOC_RT721_SDCA_SDW=m + config SND_SOC_RL6347A tristate default y if SND_SOC_RT274=y
sound/soc/codecs/Makefile +2 -0
@@ -216,6 +216,7 @@ snd-soc-rk3308-y := rk3308_codec.o snd-soc-rk3328-y := rk3328_codec.o snd-soc-rk817-y := rk817_codec.o snd-soc-rl6231-y := rl6231.o +snd-soc-rt-sdw-common-y := rt-sdw-common.o snd-soc-rl6347a-y := rl6347a.o snd-soc-rt1011-y := rt1011.o snd-soc-rt1015-y := rt1015.o
@@ -618,6 +619,7 @@ obj-$(CONFIG_SND_SOC_RK3308) += snd-soc-rk3308.o obj-$(CONFIG_SND_SOC_RK3328) += snd-soc-rk3328.o obj-$(CONFIG_SND_SOC_RK817) += snd-soc-rk817.o obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o +obj-$(CONFIG_SND_SOC_RT_SDW_COMMON) += snd-soc-rt-sdw-common.o obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o obj-$(CONFIG_SND_SOC_RT1011) += snd-soc-rt1011.o obj-$(CONFIG_SND_SOC_RT1015) += snd-soc-rt1015.o
sound/soc/codecs/rt-sdw-common.c new file +238 -0
238 lines not on this page · raw message
sound/soc/codecs/rt-sdw-common.h new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.34.1
Mark Brown
maintainersound/soc/codecs/Kconfig config SND_SOC_RL6231 · line 1552
Quoted 5 lines · Jack Yu
sound/soc/codecs/Kconfig +5
-0+config SND_SOC_RT_SDW_COMMON + tristate + default y if SND_SOC_RT721_SDCA_SDW=y + default m if SND_SOC_RT721_SDCA_SDW=m +
This should really be posted in a series with the patch adding the driver, I guess the driver won't build without this.
Mark Brown
maintainerQuoted 4 lines · Jack Yu
This is the first version of common functions for Realtek soundwire codec driver.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: rt-sdw-common: Common functions for Realtek soundwire driver
commit: bbca8e7050e0769d46eb775082d1926db05e7dac
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Op 01-10-2024 om 11:16 schreef Jack Yu:
Quoted 16 lines
This is the first version of common functions for Realtek soundwire codec driver.
Signed-off-by Jack Yu <[email protected]>--- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt-sdw-common.c | 238 +++++++++++++++++++++++++++++++ sound/soc/codecs/rt-sdw-common.h | 66 +++++++++ 4 files changed, 311 insertions(+)create mode 100644
sound/soc/codecs/rt-sdw-common.ccreate mode 100644sound/soc/codecs/rt-sdw-common.h[...]
sound/soc/codecs/rt-sdw-common.c new file +2
-0+/** +* rt_sdca_btn_type - Decision of button type.
sound/soc/codecs/rt-sdw-common.c line 111
Quoted 10 lines
sound/soc/codecs/rt-sdw-common.c new file +10
-0+* +* @buffer: UMP message buffer. +* +* A button type will be returned regarding to buffer, +* it returns zero if buffer cannot be recognized. +*/ +int rt_sdca_btn_type (unsigned char *buffer) +{ +u8 btn_type =0 ; +int ret;
No initializer ?? You probably want to set it to zero here.
sound/soc/codecs/rt-sdw-common.c line 118
Quoted 7 lines
sound/soc/codecs/rt-sdw-common.c new file +7
-0+ + btn_type |= buffer[0 ] &0xf ; + btn_type |= (buffer[0 ] >>4 ) &0xf ; + btn_type |= buffer[1 ] &0xf ; + btn_type |= (buffer[1 ] >>4 ) &0xf ; + +if (btn_type &BIT (0 ))
Variable "ret" is not initialized yet.
Quoted 12 lines
sound/soc/codecs/rt-sdw-common.c new file +11
-0+ ret |=SND_JACK_BTN_2 ; +if (btn_type &BIT (1 )) + ret |=SND_JACK_BTN_3 ; +if (btn_type &BIT (2 )) + ret |=SND_JACK_BTN_0 ; +if (btn_type &BIT (3 )) + ret |=SND_JACK_BTN_1 ; + +return ret; +} +EXPORT_SYMBOL_GPL (rt_sdca_btn_type);
Op 01-10-2024 om 11:16 schreef Jack Yu:
Quoted 35 lines
This is the first version of common functions for Realtek soundwire codec driver.
Signed-off-by Jack Yu <[email protected]>--- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt-sdw-common.c | 238 +++++++++++++++++++++++++++++++ sound/soc/codecs/rt-sdw-common.h | 66 +++++++++ 4 files changed, 311 insertions(+)create mode 100644
sound/soc/codecs/rt-sdw-common.ccreate mode 100644sound/soc/codecs/rt-sdw-common.h[...]
sound/soc/codecs/rt-sdw-common.c new file +21
-0+/** +* rt_sdca_headset_detect - Headset jack type detection. +* +* @map: map for setting. +* @entity_id: SDCA entity ID. +* +* A headset jack type will be returned, a negative errno will +* be returned in error cases. +*/ +int rt_sdca_headset_detect (struct regmap *map,unsigned int entity_id) +{ +unsigned int det_mode, jack_type; +int ret; + +/* get detected_mode */ + ret =regmap_read (map,SDW_SDCA_CTL (SDCA_NUM_JACK_CODEC , entity_id, +RT_SDCA_CTL_DETECTED_MODE ,0 ), &det_mode); + +if (ret <0 ) + goto io_error; +
sound/soc/codecs/rt-sdw-common.c line 161
Quoted 10 lines
sound/soc/codecs/rt-sdw-common.c new file +10
-0+switch (det_mode) { +case 0x00 : + jack_type =0 ; +break ; +case 0x03 : + jack_type =SND_JACK_HEADPHONE ; +break ; +case 0x05 : + jack_type =SND_JACK_HEADSET ; +break ;
There is no default case. So, variable jack_type can remain uninitialized and then used for the return value. Perhaps you can combine "case 0x00" with "default".
Quoted 12 lines
sound/soc/codecs/rt-sdw-common.c new file +11
-0+ } + +/* write selected_mode */ +if (det_mode) { + ret =regmap_write (map,SDW_SDCA_CTL (SDCA_NUM_JACK_CODEC , entity_id, +RT_SDCA_CTL_SELECTED_MODE ,0 ), det_mode); +if (ret <0 ) + goto io_error; + } + +return jack_type;
Op 08-10-2024 om 22:59 schreef Kees Bakker:
Quoted 48 lines
Op 01-10-2024 om 11:16 schreef Jack Yu:
Quoted 35 lines
This is the first version of common functions for Realtek soundwire codec driver.
Signed-off-by Jack Yu <[email protected]>---
sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 +sound/soc/codecs/rt-sdw-common.c| 238 +++++++++++++++++++++++++++++++sound/soc/codecs/rt-sdw-common.h| 66 +++++++++4 files changed, 311 insertions(+)create mode 100644
sound/soc/codecs/rt-sdw-common.ccreate mode 100644sound/soc/codecs/rt-sdw-common.h[...]
sound/soc/codecs/rt-sdw-common.c new file +21
-0+/** +* rt_sdca_headset_detect - Headset jack type detection. +* +* @map: map for setting. +* @entity_id: SDCA entity ID. +* +* A headset jack type will be returned, a negative errno will +* be returned in error cases. +*/ +int rt_sdca_headset_detect (struct regmap *map,unsigned int entity_id) +{ + unsigned int det_mode, jack_type; + int ret; + + /* get detected_mode */ + ret = regmap_read(map, SDW_SDCA_CTL(SDCA_NUM_JACK_CODEC, entity_id, + RT_SDCA_CTL_DETECTED_MODE, 0), &det_mode); + + if (ret < 0) + goto io_error; +sound/soc/codecs/rt-sdw-common.c line 161
Quoted 10 lines
sound/soc/codecs/rt-sdw-common.c new file +10
-0+ switch (det_mode) { + case 0x00: + jack_type = 0; + break; + case 0x03: + jack_type = SND_JACK_HEADPHONE; + break; + case 0x05: + jack_type = SND_JACK_HEADSET; + break;There is no default case. So, variable
jack_typecan remain uninitialized and then used for the return value. Perhaps you can combine "case0x00" with "default".
Quoted 13 lines
Quoted 4 lines
+ }
+
+ /* writeselected_mode*/
+ if (det_mode) {Quoted 9 lines
+ ret = regmap_write(map, SDW_SDCA_CTL(SDCA_NUM_JACK_CODEC,
entity_id,
+RT_SDCA_CTL_SELECTED_MODE, 0),det_mode); + if (ret < 0)
+ gotoio_error;
+ }
+
+ returnjack_type;
Please have a look at my comment again.
If regmap_read returns a det_mode not 0, 3 or 5 then the function will return jack_type with an uninitialzed value.
Signature · 1 line
Kees