1
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
2
/*
3
- * HD audio interface patch for Creative CA0132 chip
3
+ * HD audio codec driver for Creative CA0132 chip
4
4
*
5
5
* Copyright (c) 2011, Creative Technology Ltd.
6
6
*
@@ -9118,7 +9118,7 @@ static void sbz_dsp_startup_check(struct hda_codec *codec)
9118
9118
codec_info (codec , "Reloading... Tries left: %d" , reload );
9119
9119
sbz_exit_chip (codec );
9120
9120
spec -> dsp_state = DSP_DOWNLOAD_INIT ;
9121
- codec -> patch_ops . init (codec );
9121
+ snd_hda_codec_init (codec );
9122
9122
failure = 0 ;
9123
9123
for (i = 0 ; i < 4 ; i ++ ) {
9124
9124
chipio_read (codec , cur_address , & dsp_data_check [i ]);
@@ -9694,30 +9694,6 @@ static void dbpro_free(struct hda_codec *codec)
9694
9694
kfree (codec -> spec );
9695
9695
}
9696
9696
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
-
9721
9697
static void ca0132_config (struct hda_codec * codec )
9722
9698
{
9723
9699
struct ca0132_spec * spec = codec -> spec ;
@@ -9982,12 +9958,23 @@ static void sbz_detect_quirk(struct hda_codec *codec)
9982
9958
}
9983
9959
}
9984
9960
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 )
9986
9973
{
9987
9974
struct ca0132_spec * spec ;
9988
9975
int err ;
9989
9976
9990
- codec_dbg (codec , "patch_ca0132 \n" );
9977
+ codec_dbg (codec , "%s \n" , __func__ );
9991
9978
9992
9979
spec = kzalloc (sizeof (* spec ), GFP_KERNEL );
9993
9980
if (!spec )
@@ -10000,11 +9987,6 @@ static int patch_ca0132(struct hda_codec *codec)
10000
9987
if (ca0132_quirk (spec ) == QUIRK_SBZ )
10001
9988
sbz_detect_quirk (codec );
10002
9989
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
-
10008
9990
codec -> pcm_format_first = 1 ;
10009
9991
codec -> no_sticky_stream = 1 ;
10010
9992
@@ -10100,15 +10082,63 @@ static int patch_ca0132(struct hda_codec *codec)
10100
10082
return 0 ;
10101
10083
10102
10084
error :
10103
- ca0132_free (codec );
10085
+ ca0132_codec_remove (codec );
10104
10086
return err ;
10105
10087
}
10106
10088
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
+
10107
10137
/*
10108
- * patch entries
10138
+ * driver entries
10109
10139
*/
10110
10140
static const struct hda_device_id snd_hda_id_ca0132 [] = {
10111
- HDA_CODEC_ENTRY (0x11020011 , "CA0132" , patch_ca0132 ),
10141
+ HDA_CODEC_ID (0x11020011 , "CA0132" ),
10112
10142
{} /* terminator */
10113
10143
};
10114
10144
MODULE_DEVICE_TABLE (hdaudio , snd_hda_id_ca0132 );
@@ -10118,6 +10148,7 @@ MODULE_DESCRIPTION("Creative Sound Core3D codec");
10118
10148
10119
10149
static struct hda_codec_driver ca0132_driver = {
10120
10150
.id = snd_hda_id_ca0132 ,
10151
+ .ops = & ca0132_codec_ops ,
10121
10152
};
10122
10153
10123
10154
module_hda_codec_driver (ca0132_driver );
0 commit comments