@@ -27,6 +27,7 @@ struct hda_beep;
2727struct hda_codec ;
2828struct hda_pcm ;
2929struct hda_pcm_stream ;
30+ struct hda_codec_ops ;
3031
3132/*
3233 * codec bus
@@ -69,28 +70,31 @@ struct hda_bus {
6970
7071/*
7172 * codec preset
72- *
73- * Known codecs have the patch to build and set up the controls/PCMs
74- * better than the generic parser.
7573 */
76- typedef int (* hda_codec_patch_t )(struct hda_codec * );
77-
74+
7875#define HDA_CODEC_ID_SKIP_PROBE 0x00000001
7976#define HDA_CODEC_ID_GENERIC_HDMI 0x00000101
8077#define HDA_CODEC_ID_GENERIC 0x00000201
8178
82- #define HDA_CODEC_REV_ENTRY (_vid , _rev , _name , _patch ) \
79+ #define HDA_CODEC_ID_REV_MODEL (_vid , _rev , _name , _model ) \
8380 { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
84- .api_version = HDA_DEV_LEGACY, \
85- .driver_data = (unsigned long)(_patch) }
86- #define HDA_CODEC_ENTRY (_vid , _name , _patch ) \
87- HDA_CODEC_REV_ENTRY(_vid, 0, _name, _patch)
81+ .api_version = HDA_DEV_LEGACY, .driver_data = (_model) }
82+ #define HDA_CODEC_ID_MODEL (_vid , _name , _model ) \
83+ HDA_CODEC_ID_REV_MODEL(_vid, 0, _name, _model)
84+ #define HDA_CODEC_ID_REV (_vid , _rev , _name ) \
85+ HDA_CODEC_ID_REV_MODEL(_vid, _rev, _name, 0)
86+ #define HDA_CODEC_ID (_vid , _name ) \
87+ HDA_CODEC_ID_REV(_vid, 0, _name)
8888
8989struct hda_codec_driver {
9090 struct hdac_driver core ;
9191 const struct hda_device_id * id ;
92+ const struct hda_codec_ops * ops ;
9293};
9394
95+ #define hda_codec_to_driver (codec ) \
96+ container_of((codec)->core.dev.driver, struct hda_codec_driver, core.driver)
97+
9498int __hda_codec_driver_register (struct hda_codec_driver * drv , const char * name ,
9599 struct module * owner );
96100#define hda_codec_driver_register (drv ) \
@@ -100,12 +104,13 @@ void hda_codec_driver_unregister(struct hda_codec_driver *drv);
100104 module_driver(drv, hda_codec_driver_register, \
101105 hda_codec_driver_unregister)
102106
103- /* ops set by the preset patch */
107+ /* ops for hda codec driver */
104108struct hda_codec_ops {
109+ int (* probe )(struct hda_codec * codec , const struct hda_device_id * id );
110+ void (* remove )(struct hda_codec * codec );
105111 int (* build_controls )(struct hda_codec * codec );
106112 int (* build_pcms )(struct hda_codec * codec );
107113 int (* init )(struct hda_codec * codec );
108- void (* free )(struct hda_codec * codec );
109114 void (* unsol_event )(struct hda_codec * codec , unsigned int res );
110115 void (* set_power_state )(struct hda_codec * codec , hda_nid_t fg ,
111116 unsigned int power_state );
@@ -181,10 +186,7 @@ struct hda_codec {
181186 const struct hda_device_id * preset ;
182187 const char * modelname ; /* model name for preset */
183188
184- /* set by patch */
185- struct hda_codec_ops patch_ops ;
186-
187- /* PCM to create, set by patch_ops.build_pcms callback */
189+ /* PCM to create, set by hda_codec_ops.build_pcms callback */
188190 struct list_head pcm_list_head ;
189191 refcount_t pcm_ref ;
190192 wait_queue_head_t remove_sleep ;
@@ -478,8 +480,10 @@ extern const struct dev_pm_ops hda_codec_driver_pm;
478480static inline
479481int hda_call_check_power_status (struct hda_codec * codec , hda_nid_t nid )
480482{
481- if (codec -> patch_ops .check_power_status )
482- return codec -> patch_ops .check_power_status (codec , nid );
483+ struct hda_codec_driver * driver = hda_codec_to_driver (codec );
484+
485+ if (driver -> ops && driver -> ops -> check_power_status )
486+ return driver -> ops -> check_power_status (codec , nid );
483487 return 0 ;
484488}
485489
0 commit comments