diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-12-21 09:18:32 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:04:11 -0500 |
commit | bc3e5c7fc20d3c09667067878fb7a55dd9fc041d (patch) | |
tree | 81d83ec2aa0b21f8b594d45a398bdefe206ad3e3 /drivers/media/video/tuner-core.c | |
parent | 9ad89f0104314786138d580ab2c1119e7e470f56 (diff) |
V4L/DVB (6881): include struct analog_demod_ops directly inside struct dvb_frontend
Rather than using a pointer, include struct analog_demod_ops directly
inside struct dvb_frontend. This will allow us to use dvb_attach in
the future, along with removing the need to check the ops structure
before having to check the pointer to the method being called.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tuner-core.c')
-rw-r--r-- | drivers/media/video/tuner-core.c | 99 |
1 files changed, 47 insertions, 52 deletions
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index ad20af84809d..f792871582ff 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -143,8 +143,6 @@ static void fe_release(struct dvb_frontend *fe) | |||
143 | if (fe->ops.tuner_ops.release) | 143 | if (fe->ops.tuner_ops.release) |
144 | fe->ops.tuner_ops.release(fe); | 144 | fe->ops.tuner_ops.release(fe); |
145 | 145 | ||
146 | fe->ops.analog_demod_ops = NULL; | ||
147 | |||
148 | /* DO NOT kfree(fe->analog_demod_priv) | 146 | /* DO NOT kfree(fe->analog_demod_priv) |
149 | * | 147 | * |
150 | * If we are in this function, analog_demod_priv contains a pointer | 148 | * If we are in this function, analog_demod_priv contains a pointer |
@@ -189,7 +187,7 @@ static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg) | |||
189 | 187 | ||
190 | static void tuner_status(struct dvb_frontend *fe); | 188 | static void tuner_status(struct dvb_frontend *fe); |
191 | 189 | ||
192 | static struct analog_tuner_ops tuner_core_ops = { | 190 | static struct analog_demod_ops tuner_core_ops = { |
193 | .set_params = fe_set_params, | 191 | .set_params = fe_set_params, |
194 | .standby = fe_standby, | 192 | .standby = fe_standby, |
195 | .release = fe_release, | 193 | .release = fe_release, |
@@ -202,7 +200,7 @@ static struct analog_tuner_ops tuner_core_ops = { | |||
202 | static void set_tv_freq(struct i2c_client *c, unsigned int freq) | 200 | static void set_tv_freq(struct i2c_client *c, unsigned int freq) |
203 | { | 201 | { |
204 | struct tuner *t = i2c_get_clientdata(c); | 202 | struct tuner *t = i2c_get_clientdata(c); |
205 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 203 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
206 | 204 | ||
207 | struct analog_parameters params = { | 205 | struct analog_parameters params = { |
208 | .mode = t->mode, | 206 | .mode = t->mode, |
@@ -214,7 +212,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
214 | tuner_warn ("tuner type not set\n"); | 212 | tuner_warn ("tuner type not set\n"); |
215 | return; | 213 | return; |
216 | } | 214 | } |
217 | if ((NULL == ops) || (NULL == ops->set_params)) { | 215 | if (NULL == analog_ops->set_params) { |
218 | tuner_warn ("Tuner has no way to set tv freq\n"); | 216 | tuner_warn ("Tuner has no way to set tv freq\n"); |
219 | return; | 217 | return; |
220 | } | 218 | } |
@@ -231,13 +229,13 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
231 | } | 229 | } |
232 | params.frequency = freq; | 230 | params.frequency = freq; |
233 | 231 | ||
234 | ops->set_params(&t->fe, ¶ms); | 232 | analog_ops->set_params(&t->fe, ¶ms); |
235 | } | 233 | } |
236 | 234 | ||
237 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) | 235 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) |
238 | { | 236 | { |
239 | struct tuner *t = i2c_get_clientdata(c); | 237 | struct tuner *t = i2c_get_clientdata(c); |
240 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 238 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
241 | 239 | ||
242 | struct analog_parameters params = { | 240 | struct analog_parameters params = { |
243 | .mode = t->mode, | 241 | .mode = t->mode, |
@@ -249,7 +247,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
249 | tuner_warn ("tuner type not set\n"); | 247 | tuner_warn ("tuner type not set\n"); |
250 | return; | 248 | return; |
251 | } | 249 | } |
252 | if ((NULL == ops) || (NULL == ops->set_params)) { | 250 | if (analog_ops->set_params) { |
253 | tuner_warn ("tuner has no way to set radio frequency\n"); | 251 | tuner_warn ("tuner has no way to set radio frequency\n"); |
254 | return; | 252 | return; |
255 | } | 253 | } |
@@ -266,7 +264,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
266 | } | 264 | } |
267 | params.frequency = freq; | 265 | params.frequency = freq; |
268 | 266 | ||
269 | ops->set_params(&t->fe, ¶ms); | 267 | analog_ops->set_params(&t->fe, ¶ms); |
270 | } | 268 | } |
271 | 269 | ||
272 | static void set_freq(struct i2c_client *c, unsigned long freq) | 270 | static void set_freq(struct i2c_client *c, unsigned long freq) |
@@ -337,7 +335,7 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
337 | { | 335 | { |
338 | struct tuner *t = i2c_get_clientdata(c); | 336 | struct tuner *t = i2c_get_clientdata(c); |
339 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 337 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
340 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 338 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
341 | unsigned char buffer[4]; | 339 | unsigned char buffer[4]; |
342 | 340 | ||
343 | if (type == UNSET || type == TUNER_ABSENT) { | 341 | if (type == UNSET || type == TUNER_ABSENT) { |
@@ -364,8 +362,8 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
364 | } | 362 | } |
365 | 363 | ||
366 | /* discard private data, in case set_type() was previously called */ | 364 | /* discard private data, in case set_type() was previously called */ |
367 | if (ops && ops->release) | 365 | if (analog_ops->release) |
368 | ops->release(&t->fe); | 366 | analog_ops->release(&t->fe); |
369 | 367 | ||
370 | switch (t->type) { | 368 | switch (t->type) { |
371 | case TUNER_MT2032: | 369 | case TUNER_MT2032: |
@@ -435,17 +433,16 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
435 | break; | 433 | break; |
436 | } | 434 | } |
437 | 435 | ||
438 | ops = t->fe.ops.analog_demod_ops; | 436 | if ((NULL == analog_ops->set_params) && |
439 | |||
440 | if (((NULL == ops) || (NULL == ops->set_params)) && | ||
441 | (fe_tuner_ops->set_analog_params)) { | 437 | (fe_tuner_ops->set_analog_params)) { |
442 | strlcpy(t->i2c->name, fe_tuner_ops->info.name, | 438 | strlcpy(t->i2c->name, fe_tuner_ops->info.name, |
443 | sizeof(t->i2c->name)); | 439 | sizeof(t->i2c->name)); |
444 | 440 | ||
445 | t->fe.ops.analog_demod_ops = &tuner_core_ops; | ||
446 | t->fe.analog_demod_priv = t; | 441 | t->fe.analog_demod_priv = t; |
442 | memcpy(analog_ops, &tuner_core_ops, | ||
443 | sizeof(struct analog_demod_ops)); | ||
447 | } else { | 444 | } else { |
448 | strlcpy(t->i2c->name, ops->info.name, | 445 | strlcpy(t->i2c->name, analog_ops->info.name, |
449 | sizeof(t->i2c->name)); | 446 | sizeof(t->i2c->name)); |
450 | } | 447 | } |
451 | 448 | ||
@@ -624,7 +621,7 @@ static void tuner_status(struct dvb_frontend *fe) | |||
624 | struct tuner *t = fe->analog_demod_priv; | 621 | struct tuner *t = fe->analog_demod_priv; |
625 | unsigned long freq, freq_fraction; | 622 | unsigned long freq, freq_fraction; |
626 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 623 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
627 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 624 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
628 | const char *p; | 625 | const char *p; |
629 | 626 | ||
630 | switch (t->mode) { | 627 | switch (t->mode) { |
@@ -654,14 +651,12 @@ static void tuner_status(struct dvb_frontend *fe) | |||
654 | if (tuner_status & TUNER_STATUS_STEREO) | 651 | if (tuner_status & TUNER_STATUS_STEREO) |
655 | tuner_info("Stereo: yes\n"); | 652 | tuner_info("Stereo: yes\n"); |
656 | } | 653 | } |
657 | if (ops) { | 654 | if (analog_ops->has_signal) |
658 | if (ops->has_signal) | 655 | tuner_info("Signal strength: %d\n", |
659 | tuner_info("Signal strength: %d\n", | 656 | analog_ops->has_signal(fe)); |
660 | ops->has_signal(fe)); | 657 | if (analog_ops->is_stereo) |
661 | if (ops->is_stereo) | 658 | tuner_info("Stereo: %s\n", |
662 | tuner_info("Stereo: %s\n", | 659 | analog_ops->is_stereo(fe) ? "yes" : "no"); |
663 | ops->is_stereo(fe) ? "yes" : "no"); | ||
664 | } | ||
665 | } | 660 | } |
666 | 661 | ||
667 | /* ---------------------------------------------------------------------- */ | 662 | /* ---------------------------------------------------------------------- */ |
@@ -675,7 +670,7 @@ static void tuner_status(struct dvb_frontend *fe) | |||
675 | 670 | ||
676 | static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) | 671 | static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd) |
677 | { | 672 | { |
678 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 673 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
679 | 674 | ||
680 | if (mode == t->mode) | 675 | if (mode == t->mode) |
681 | return 0; | 676 | return 0; |
@@ -684,8 +679,8 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, | |||
684 | 679 | ||
685 | if (check_mode(t, cmd) == EINVAL) { | 680 | if (check_mode(t, cmd) == EINVAL) { |
686 | t->mode = T_STANDBY; | 681 | t->mode = T_STANDBY; |
687 | if (ops && ops->standby) | 682 | if (analog_ops->standby) |
688 | ops->standby(&t->fe); | 683 | analog_ops->standby(&t->fe); |
689 | return EINVAL; | 684 | return EINVAL; |
690 | } | 685 | } |
691 | return 0; | 686 | return 0; |
@@ -708,7 +703,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
708 | { | 703 | { |
709 | struct tuner *t = i2c_get_clientdata(client); | 704 | struct tuner *t = i2c_get_clientdata(client); |
710 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 705 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
711 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 706 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
712 | 707 | ||
713 | if (tuner_debug>1) | 708 | if (tuner_debug>1) |
714 | v4l_i2c_print_ioctl(client,cmd); | 709 | v4l_i2c_print_ioctl(client,cmd); |
@@ -735,8 +730,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
735 | if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) | 730 | if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) |
736 | return 0; | 731 | return 0; |
737 | t->mode = T_STANDBY; | 732 | t->mode = T_STANDBY; |
738 | if (ops && ops->standby) | 733 | if (analog_ops->standby) |
739 | ops->standby(&t->fe); | 734 | analog_ops->standby(&t->fe); |
740 | break; | 735 | break; |
741 | #ifdef CONFIG_VIDEO_V4L1 | 736 | #ifdef CONFIG_VIDEO_V4L1 |
742 | case VIDIOCSAUDIO: | 737 | case VIDIOCSAUDIO: |
@@ -804,8 +799,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
804 | else | 799 | else |
805 | vt->flags &= ~VIDEO_TUNER_STEREO_ON; | 800 | vt->flags &= ~VIDEO_TUNER_STEREO_ON; |
806 | } else { | 801 | } else { |
807 | if (ops && ops->is_stereo) { | 802 | if (analog_ops->is_stereo) { |
808 | if (ops->is_stereo(&t->fe)) | 803 | if (analog_ops->is_stereo(&t->fe)) |
809 | vt->flags |= | 804 | vt->flags |= |
810 | VIDEO_TUNER_STEREO_ON; | 805 | VIDEO_TUNER_STEREO_ON; |
811 | else | 806 | else |
@@ -813,8 +808,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
813 | ~VIDEO_TUNER_STEREO_ON; | 808 | ~VIDEO_TUNER_STEREO_ON; |
814 | } | 809 | } |
815 | } | 810 | } |
816 | if (ops && ops->has_signal) | 811 | if (analog_ops->has_signal) |
817 | vt->signal = ops->has_signal(&t->fe); | 812 | vt->signal = |
813 | analog_ops->has_signal(&t->fe); | ||
818 | 814 | ||
819 | vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ | 815 | vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */ |
820 | 816 | ||
@@ -844,8 +840,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
844 | fe_tuner_ops->get_status(&t->fe, &tuner_status); | 840 | fe_tuner_ops->get_status(&t->fe, &tuner_status); |
845 | va->mode = (tuner_status & TUNER_STATUS_STEREO) | 841 | va->mode = (tuner_status & TUNER_STATUS_STEREO) |
846 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; | 842 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; |
847 | } else if (ops && ops->is_stereo) | 843 | } else if (analog_ops->is_stereo) |
848 | va->mode = ops->is_stereo(&t->fe) | 844 | va->mode = analog_ops->is_stereo(&t->fe) |
849 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; | 845 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; |
850 | } | 846 | } |
851 | return 0; | 847 | return 0; |
@@ -853,19 +849,18 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
853 | #endif | 849 | #endif |
854 | case TUNER_SET_CONFIG: | 850 | case TUNER_SET_CONFIG: |
855 | { | 851 | { |
856 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | ||
857 | struct v4l2_priv_tun_config *cfg = arg; | 852 | struct v4l2_priv_tun_config *cfg = arg; |
858 | 853 | ||
859 | if (t->type != cfg->tuner) | 854 | if (t->type != cfg->tuner) |
860 | break; | 855 | break; |
861 | 856 | ||
862 | if ((NULL == ops) || (NULL == ops->set_config)) { | 857 | if (analog_ops->set_config) { |
863 | tuner_warn("Tuner frontend module has no way to " | 858 | tuner_warn("Tuner frontend module has no way to " |
864 | "set config\n"); | 859 | "set config\n"); |
865 | break; | 860 | break; |
866 | } | 861 | } |
867 | 862 | ||
868 | ops->set_config(&t->fe, cfg->priv); | 863 | analog_ops->set_config(&t->fe, cfg->priv); |
869 | break; | 864 | break; |
870 | } | 865 | } |
871 | /* --- v4l ioctls --- */ | 866 | /* --- v4l ioctls --- */ |
@@ -929,8 +924,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
929 | switch_v4l2(); | 924 | switch_v4l2(); |
930 | 925 | ||
931 | tuner->type = t->mode; | 926 | tuner->type = t->mode; |
932 | if (ops && ops->get_afc) | 927 | if (analog_ops->get_afc) |
933 | tuner->afc = ops->get_afc(&t->fe); | 928 | tuner->afc = analog_ops->get_afc(&t->fe); |
934 | if (t->mode == V4L2_TUNER_ANALOG_TV) | 929 | if (t->mode == V4L2_TUNER_ANALOG_TV) |
935 | tuner->capability |= V4L2_TUNER_CAP_NORM; | 930 | tuner->capability |= V4L2_TUNER_CAP_NORM; |
936 | if (t->mode != V4L2_TUNER_RADIO) { | 931 | if (t->mode != V4L2_TUNER_RADIO) { |
@@ -951,15 +946,15 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
951 | V4L2_TUNER_SUB_STEREO : | 946 | V4L2_TUNER_SUB_STEREO : |
952 | V4L2_TUNER_SUB_MONO; | 947 | V4L2_TUNER_SUB_MONO; |
953 | } else { | 948 | } else { |
954 | if (ops && ops->is_stereo) { | 949 | if (analog_ops->is_stereo) { |
955 | tuner->rxsubchans = | 950 | tuner->rxsubchans = |
956 | ops->is_stereo(&t->fe) ? | 951 | analog_ops->is_stereo(&t->fe) ? |
957 | V4L2_TUNER_SUB_STEREO : | 952 | V4L2_TUNER_SUB_STEREO : |
958 | V4L2_TUNER_SUB_MONO; | 953 | V4L2_TUNER_SUB_MONO; |
959 | } | 954 | } |
960 | } | 955 | } |
961 | if (ops && ops->has_signal) | 956 | if (analog_ops->has_signal) |
962 | tuner->signal = ops->has_signal(&t->fe); | 957 | tuner->signal = analog_ops->has_signal(&t->fe); |
963 | tuner->capability |= | 958 | tuner->capability |= |
964 | V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 959 | V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
965 | tuner->audmode = t->audmode; | 960 | tuner->audmode = t->audmode; |
@@ -984,8 +979,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
984 | break; | 979 | break; |
985 | } | 980 | } |
986 | case VIDIOC_LOG_STATUS: | 981 | case VIDIOC_LOG_STATUS: |
987 | if (ops && ops->tuner_status) | 982 | if (analog_ops->tuner_status) |
988 | ops->tuner_status(&t->fe); | 983 | analog_ops->tuner_status(&t->fe); |
989 | break; | 984 | break; |
990 | } | 985 | } |
991 | 986 | ||
@@ -1214,10 +1209,10 @@ static int tuner_legacy_probe(struct i2c_adapter *adap) | |||
1214 | static int tuner_remove(struct i2c_client *client) | 1209 | static int tuner_remove(struct i2c_client *client) |
1215 | { | 1210 | { |
1216 | struct tuner *t = i2c_get_clientdata(client); | 1211 | struct tuner *t = i2c_get_clientdata(client); |
1217 | struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; | 1212 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
1218 | 1213 | ||
1219 | if (ops && ops->release) | 1214 | if (analog_ops->release) |
1220 | ops->release(&t->fe); | 1215 | analog_ops->release(&t->fe); |
1221 | 1216 | ||
1222 | list_del(&t->list); | 1217 | list_del(&t->list); |
1223 | kfree(t); | 1218 | kfree(t); |