Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: hda/ca0132: Rewrite to new probe method

Convert the CA0132 codec driver to use the new hda_codec_ops probe.
No functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250709160434.1859-23-tiwai@suse.de

+68 -37
+67 -36
sound/hda/codecs/ca0132.c
··· 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 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 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; ··· 9958 9982 } 9959 9983 } 9960 9984 9961 - static int patch_ca0132(struct hda_codec *codec) 9985 + static void ca0132_codec_remove(struct hda_codec *codec) 9986 + { 9987 + struct ca0132_spec *spec = codec->spec; 9988 + 9989 + if (ca0132_quirk(spec) == QUIRK_ZXR_DBPRO) 9990 + return dbpro_free(codec); 9991 + else 9992 + return ca0132_free(codec); 9993 + } 9994 + 9995 + static int ca0132_codec_probe(struct hda_codec *codec, 9996 + const struct hda_device_id *id) 9962 9997 { 9963 9998 struct ca0132_spec *spec; 9964 9999 int err; 9965 10000 9966 - codec_dbg(codec, "patch_ca0132\n"); 10001 + codec_dbg(codec, "%s\n", __func__); 9967 10002 9968 10003 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 9969 10004 if (!spec) ··· 9986 9999 snd_hda_pick_fixup(codec, ca0132_quirk_models, ca0132_quirks, NULL); 9987 10000 if (ca0132_quirk(spec) == QUIRK_SBZ) 9988 10001 sbz_detect_quirk(codec); 9989 - 9990 - if (ca0132_quirk(spec) == QUIRK_ZXR_DBPRO) 9991 - codec->patch_ops = dbpro_patch_ops; 9992 - else 9993 - codec->patch_ops = ca0132_patch_ops; 9994 10002 9995 10003 codec->pcm_format_first = 1; 9996 10004 codec->no_sticky_stream = 1; ··· 10082 10100 return 0; 10083 10101 10084 10102 error: 10085 - ca0132_free(codec); 10103 + ca0132_codec_remove(codec); 10086 10104 return err; 10087 10105 } 10088 10106 10107 + static int ca0132_codec_build_controls(struct hda_codec *codec) 10108 + { 10109 + struct ca0132_spec *spec = codec->spec; 10110 + 10111 + if (ca0132_quirk(spec) == QUIRK_ZXR_DBPRO) 10112 + return dbpro_build_controls(codec); 10113 + else 10114 + return ca0132_build_controls(codec); 10115 + } 10116 + 10117 + static int ca0132_codec_build_pcms(struct hda_codec *codec) 10118 + { 10119 + struct ca0132_spec *spec = codec->spec; 10120 + 10121 + if (ca0132_quirk(spec) == QUIRK_ZXR_DBPRO) 10122 + return dbpro_build_pcms(codec); 10123 + else 10124 + return ca0132_build_pcms(codec); 10125 + } 10126 + 10127 + static int ca0132_codec_init(struct hda_codec *codec) 10128 + { 10129 + struct ca0132_spec *spec = codec->spec; 10130 + 10131 + if (ca0132_quirk(spec) == QUIRK_ZXR_DBPRO) 10132 + return dbpro_init(codec); 10133 + else 10134 + return ca0132_init(codec); 10135 + } 10136 + 10137 + static int ca0132_codec_suspend(struct hda_codec *codec) 10138 + { 10139 + struct ca0132_spec *spec = codec->spec; 10140 + 10141 + cancel_delayed_work_sync(&spec->unsol_hp_work); 10142 + return 0; 10143 + } 10144 + 10145 + static const struct hda_codec_ops ca0132_codec_ops = { 10146 + .probe = ca0132_codec_probe, 10147 + .remove = ca0132_codec_remove, 10148 + .build_controls = ca0132_codec_build_controls, 10149 + .build_pcms = ca0132_codec_build_pcms, 10150 + .init = ca0132_codec_init, 10151 + .unsol_event = snd_hda_jack_unsol_event, 10152 + .suspend = ca0132_codec_suspend, 10153 + }; 10154 + 10089 10155 /* 10090 - * patch entries 10156 + * driver entries 10091 10157 */ 10092 10158 static const struct hda_device_id snd_hda_id_ca0132[] = { 10093 - HDA_CODEC_ENTRY(0x11020011, "CA0132", patch_ca0132), 10159 + HDA_CODEC_ID(0x11020011, "CA0132"), 10094 10160 {} /* terminator */ 10095 10161 }; 10096 10162 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_ca0132); ··· 10148 10118 10149 10119 static struct hda_codec_driver ca0132_driver = { 10150 10120 .id = snd_hda_id_ca0132, 10121 + .ops = &ca0132_codec_ops, 10151 10122 }; 10152 10123 10153 10124 module_hda_codec_driver(ca0132_driver);
+1 -1
sound/hda/codecs/ca0132_regs.h
··· 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 * CA0132 registers defines. 5 5 * 6 6 * Copyright (c) 2011, Creative Technology Ltd.