11// SPDX-License-Identifier: GPL-2.0-or-later
22/*
3- * HD audio interface patch for Creative CA0132 chip
3+ * HD audio codec driver for Creative CA0132 chip
44 *
55 * Copyright (c) 2011, Creative Technology Ltd.
66 *
@@ -9118,7 +9118,7 @@ static void sbz_dsp_startup_check(struct hda_codec *codec)
91189118 codec_info (codec , "Reloading... Tries left: %d" , reload );
91199119 sbz_exit_chip (codec );
91209120 spec -> dsp_state = DSP_DOWNLOAD_INIT ;
9121- codec -> patch_ops . init (codec );
9121+ snd_hda_codec_init (codec );
91229122 failure = 0 ;
91239123 for (i = 0 ; i < 4 ; i ++ ) {
91249124 chipio_read (codec , cur_address , & dsp_data_check [i ]);
@@ -9694,30 +9694,6 @@ static void dbpro_free(struct hda_codec *codec)
96949694 kfree (codec -> spec );
96959695}
96969696
9697- static int ca0132_suspend (struct hda_codec * codec )
9698- {
9699- struct ca0132_spec * spec = codec -> spec ;
9700-
9701- cancel_delayed_work_sync (& spec -> unsol_hp_work );
9702- return 0 ;
9703- }
9704-
9705- static const struct hda_codec_ops ca0132_patch_ops = {
9706- .build_controls = ca0132_build_controls ,
9707- .build_pcms = ca0132_build_pcms ,
9708- .init = ca0132_init ,
9709- .free = ca0132_free ,
9710- .unsol_event = snd_hda_jack_unsol_event ,
9711- .suspend = ca0132_suspend ,
9712- };
9713-
9714- static const struct hda_codec_ops dbpro_patch_ops = {
9715- .build_controls = dbpro_build_controls ,
9716- .build_pcms = dbpro_build_pcms ,
9717- .init = dbpro_init ,
9718- .free = dbpro_free ,
9719- };
9720-
97219697static void ca0132_config (struct hda_codec * codec )
97229698{
97239699 struct ca0132_spec * spec = codec -> spec ;
@@ -9982,12 +9958,23 @@ static void sbz_detect_quirk(struct hda_codec *codec)
99829958 }
99839959}
99849960
9985- static int patch_ca0132 (struct hda_codec * codec )
9961+ static void ca0132_codec_remove (struct hda_codec * codec )
9962+ {
9963+ struct ca0132_spec * spec = codec -> spec ;
9964+
9965+ if (ca0132_quirk (spec ) == QUIRK_ZXR_DBPRO )
9966+ return dbpro_free (codec );
9967+ else
9968+ return ca0132_free (codec );
9969+ }
9970+
9971+ static int ca0132_codec_probe (struct hda_codec * codec ,
9972+ const struct hda_device_id * id )
99869973{
99879974 struct ca0132_spec * spec ;
99889975 int err ;
99899976
9990- codec_dbg (codec , "patch_ca0132 \n" );
9977+ codec_dbg (codec , "%s \n" , __func__ );
99919978
99929979 spec = kzalloc (sizeof (* spec ), GFP_KERNEL );
99939980 if (!spec )
@@ -10000,11 +9987,6 @@ static int patch_ca0132(struct hda_codec *codec)
100009987 if (ca0132_quirk (spec ) == QUIRK_SBZ )
100019988 sbz_detect_quirk (codec );
100029989
10003- if (ca0132_quirk (spec ) == QUIRK_ZXR_DBPRO )
10004- codec -> patch_ops = dbpro_patch_ops ;
10005- else
10006- codec -> patch_ops = ca0132_patch_ops ;
10007-
100089990 codec -> pcm_format_first = 1 ;
100099991 codec -> no_sticky_stream = 1 ;
100109992
@@ -10100,15 +10082,63 @@ static int patch_ca0132(struct hda_codec *codec)
1010010082 return 0 ;
1010110083
1010210084 error :
10103- ca0132_free (codec );
10085+ ca0132_codec_remove (codec );
1010410086 return err ;
1010510087}
1010610088
10089+ static int ca0132_codec_build_controls (struct hda_codec * codec )
10090+ {
10091+ struct ca0132_spec * spec = codec -> spec ;
10092+
10093+ if (ca0132_quirk (spec ) == QUIRK_ZXR_DBPRO )
10094+ return dbpro_build_controls (codec );
10095+ else
10096+ return ca0132_build_controls (codec );
10097+ }
10098+
10099+ static int ca0132_codec_build_pcms (struct hda_codec * codec )
10100+ {
10101+ struct ca0132_spec * spec = codec -> spec ;
10102+
10103+ if (ca0132_quirk (spec ) == QUIRK_ZXR_DBPRO )
10104+ return dbpro_build_pcms (codec );
10105+ else
10106+ return ca0132_build_pcms (codec );
10107+ }
10108+
10109+ static int ca0132_codec_init (struct hda_codec * codec )
10110+ {
10111+ struct ca0132_spec * spec = codec -> spec ;
10112+
10113+ if (ca0132_quirk (spec ) == QUIRK_ZXR_DBPRO )
10114+ return dbpro_init (codec );
10115+ else
10116+ return ca0132_init (codec );
10117+ }
10118+
10119+ static int ca0132_codec_suspend (struct hda_codec * codec )
10120+ {
10121+ struct ca0132_spec * spec = codec -> spec ;
10122+
10123+ cancel_delayed_work_sync (& spec -> unsol_hp_work );
10124+ return 0 ;
10125+ }
10126+
10127+ static const struct hda_codec_ops ca0132_codec_ops = {
10128+ .probe = ca0132_codec_probe ,
10129+ .remove = ca0132_codec_remove ,
10130+ .build_controls = ca0132_codec_build_controls ,
10131+ .build_pcms = ca0132_codec_build_pcms ,
10132+ .init = ca0132_codec_init ,
10133+ .unsol_event = snd_hda_jack_unsol_event ,
10134+ .suspend = ca0132_codec_suspend ,
10135+ };
10136+
1010710137/*
10108- * patch entries
10138+ * driver entries
1010910139 */
1011010140static const struct hda_device_id snd_hda_id_ca0132 [] = {
10111- HDA_CODEC_ENTRY (0x11020011 , "CA0132" , patch_ca0132 ),
10141+ HDA_CODEC_ID (0x11020011 , "CA0132" ),
1011210142 {} /* terminator */
1011310143};
1011410144MODULE_DEVICE_TABLE (hdaudio , snd_hda_id_ca0132 );
@@ -10118,6 +10148,7 @@ MODULE_DESCRIPTION("Creative Sound Core3D codec");
1011810148
1011910149static struct hda_codec_driver ca0132_driver = {
1012010150 .id = snd_hda_id_ca0132 ,
10151+ .ops = & ca0132_codec_ops ,
1012110152};
1012210153
1012310154module_hda_codec_driver (ca0132_driver );
0 commit comments