diff options
author | Michel Ludwig <michel.ludwig@gmail.com> | 2007-11-16 05:46:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:02:14 -0500 |
commit | a37b4c9bc87a74ed5003c385eae264fc0acf6b35 (patch) | |
tree | 50ac0d83aebd44f94b357592a22242f11716f7b9 | |
parent | 2fc580ffeb551066f769934e3a4717d721d0a559 (diff) |
V4L/DVB (6611): Change xc2028_attach method to make easier for DVB
Removes uneeded parameters and adds an structure for passing the parameters
This patch is co-authored by Mauro Carvalho Chehab.
Signed-off-by: Michel Ludwig <michel.ludwig@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/tuner-core.c | 11 | ||||
-rw-r--r-- | drivers/media/video/tuner-xc2028.c | 53 | ||||
-rw-r--r-- | drivers/media/video/tuner-xc2028.h | 20 |
3 files changed, 44 insertions, 40 deletions
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 1b0d28a0ca78..e56a41941489 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -336,10 +336,13 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
336 | break; | 336 | break; |
337 | case TUNER_XC2028: | 337 | case TUNER_XC2028: |
338 | { | 338 | { |
339 | int rc=xc2028_attach(&t->fe, t->i2c->adapter, t->i2c->addr, | 339 | struct xc2028_config cfg = { |
340 | &c->dev, c->adapter->algo_data, | 340 | .i2c_adap = t->i2c->adapter, |
341 | t->tuner_callback); | 341 | .i2c_addr = t->i2c->addr, |
342 | if (rc<0) { | 342 | .video_dev = c->adapter->algo_data, |
343 | .callback = t->tuner_callback, | ||
344 | }; | ||
345 | if (!xc2028_attach(&t->fe, &cfg)) { | ||
343 | t->type = TUNER_ABSENT; | 346 | t->type = TUNER_ABSENT; |
344 | t->mode_mask = T_UNINITIALIZED; | 347 | t->mode_mask = T_UNINITIALIZED; |
345 | return; | 348 | return; |
diff --git a/drivers/media/video/tuner-xc2028.c b/drivers/media/video/tuner-xc2028.c index c64eae2c7ec2..0a2ffe4f38d0 100644 --- a/drivers/media/video/tuner-xc2028.c +++ b/drivers/media/video/tuner-xc2028.c | |||
@@ -56,7 +56,6 @@ struct xc2028_data { | |||
56 | struct tuner_i2c_props i2c_props; | 56 | struct tuner_i2c_props i2c_props; |
57 | int (*tuner_callback) (void *dev, | 57 | int (*tuner_callback) (void *dev, |
58 | int command, int arg); | 58 | int command, int arg); |
59 | struct device *dev; | ||
60 | void *video_dev; | 59 | void *video_dev; |
61 | int count; | 60 | int count; |
62 | __u32 frequency; | 61 | __u32 frequency; |
@@ -240,7 +239,8 @@ static int load_all_firmwares(struct dvb_frontend *fe) | |||
240 | tuner_dbg("%s called\n", __FUNCTION__); | 239 | tuner_dbg("%s called\n", __FUNCTION__); |
241 | 240 | ||
242 | tuner_info("Reading firmware %s\n", priv->ctrl.fname); | 241 | tuner_info("Reading firmware %s\n", priv->ctrl.fname); |
243 | rc = request_firmware(&fw, priv->ctrl.fname, priv->dev); | 242 | rc = request_firmware(&fw, priv->ctrl.fname, |
243 | &priv->i2c_props.adap->dev); | ||
244 | if (rc < 0) { | 244 | if (rc < 0) { |
245 | if (rc == -ENOENT) | 245 | if (rc == -ENOENT) |
246 | tuner_err("Error: firmware %s not found.\n", | 246 | tuner_err("Error: firmware %s not found.\n", |
@@ -546,8 +546,10 @@ static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, | |||
546 | tuner_dbg("%s called\n", __FUNCTION__); | 546 | tuner_dbg("%s called\n", __FUNCTION__); |
547 | 547 | ||
548 | if (!priv->firm) { | 548 | if (!priv->firm) { |
549 | if (!priv->ctrl.fname) | 549 | if (!priv->ctrl.fname) { |
550 | tuner_info("xc2028/3028 firmware name not set!\n"); | ||
550 | return -EINVAL; | 551 | return -EINVAL; |
552 | } | ||
551 | 553 | ||
552 | rc = load_all_firmwares(fe); | 554 | rc = load_all_firmwares(fe); |
553 | if (rc < 0) | 555 | if (rc < 0) |
@@ -882,53 +884,51 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = { | |||
882 | 884 | ||
883 | }; | 885 | }; |
884 | 886 | ||
885 | int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, | 887 | void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) |
886 | u8 i2c_addr, struct device *dev, void *video_dev, | ||
887 | int (*tuner_callback) (void *dev, int command, int arg)) | ||
888 | { | 888 | { |
889 | struct xc2028_data *priv; | 889 | struct xc2028_data *priv; |
890 | void *video_dev; | ||
890 | 891 | ||
891 | if (debug) | 892 | if (debug) |
892 | printk(KERN_DEBUG PREFIX "Xcv2028/3028 init called!\n"); | 893 | printk(KERN_DEBUG PREFIX "Xcv2028/3028 init called!\n"); |
893 | 894 | ||
894 | if (NULL == dev) | 895 | if (NULL == cfg->video_dev) |
895 | return -ENODEV; | 896 | return NULL; |
896 | 897 | ||
897 | if (NULL == video_dev) | 898 | if (!fe) { |
898 | return -ENODEV; | 899 | printk(KERN_ERR PREFIX "No frontend!\n"); |
899 | 900 | return NULL; | |
900 | if (!tuner_callback) { | ||
901 | printk(KERN_ERR PREFIX "No tuner callback!\n"); | ||
902 | return -EINVAL; | ||
903 | } | 901 | } |
904 | 902 | ||
903 | video_dev = cfg->video_dev; | ||
904 | |||
905 | list_for_each_entry(priv, &xc2028_list, xc2028_list) { | 905 | list_for_each_entry(priv, &xc2028_list, xc2028_list) { |
906 | if (priv->dev == dev) | 906 | if (priv->video_dev == cfg->video_dev) { |
907 | dev = NULL; | 907 | video_dev = NULL; |
908 | break; | ||
909 | } | ||
908 | } | 910 | } |
909 | 911 | ||
910 | if (dev) { | 912 | if (video_dev) { |
911 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 913 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
912 | if (priv == NULL) | 914 | if (priv == NULL) |
913 | return -ENOMEM; | 915 | return NULL; |
914 | |||
915 | fe->tuner_priv = priv; | ||
916 | 916 | ||
917 | priv->bandwidth = BANDWIDTH_6_MHZ; | 917 | priv->bandwidth = BANDWIDTH_6_MHZ; |
918 | priv->need_load_generic = 1; | 918 | priv->need_load_generic = 1; |
919 | priv->mode = T_UNINITIALIZED; | 919 | priv->mode = T_UNINITIALIZED; |
920 | priv->i2c_props.addr = i2c_addr; | 920 | priv->i2c_props.addr = cfg->i2c_addr; |
921 | priv->i2c_props.adap = i2c_adap; | 921 | priv->i2c_props.adap = cfg->i2c_adap; |
922 | priv->dev = dev; | ||
923 | priv->video_dev = video_dev; | 922 | priv->video_dev = video_dev; |
924 | priv->tuner_callback = tuner_callback; | 923 | priv->tuner_callback = cfg->callback; |
925 | priv->max_len = 13; | 924 | priv->max_len = 13; |
926 | 925 | ||
927 | |||
928 | mutex_init(&priv->lock); | 926 | mutex_init(&priv->lock); |
929 | 927 | ||
930 | list_add_tail(&priv->xc2028_list, &xc2028_list); | 928 | list_add_tail(&priv->xc2028_list, &xc2028_list); |
931 | } | 929 | } |
930 | |||
931 | fe->tuner_priv = priv; | ||
932 | priv->count++; | 932 | priv->count++; |
933 | 933 | ||
934 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, | 934 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, |
@@ -936,8 +936,9 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, | |||
936 | 936 | ||
937 | tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner"); | 937 | tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner"); |
938 | 938 | ||
939 | return 0; | 939 | return fe; |
940 | } | 940 | } |
941 | |||
941 | EXPORT_SYMBOL(xc2028_attach); | 942 | EXPORT_SYMBOL(xc2028_attach); |
942 | 943 | ||
943 | MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); | 944 | MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); |
diff --git a/drivers/media/video/tuner-xc2028.h b/drivers/media/video/tuner-xc2028.h index e04611e653e4..a20eeb4935d0 100644 --- a/drivers/media/video/tuner-xc2028.h +++ b/drivers/media/video/tuner-xc2028.h | |||
@@ -22,22 +22,22 @@ struct xc2028_ctrl { | |||
22 | int max_len; | 22 | int max_len; |
23 | }; | 23 | }; |
24 | 24 | ||
25 | struct xc2028_config { | ||
26 | struct i2c_adapter *i2c_adap; | ||
27 | u8 i2c_addr; | ||
28 | void *video_dev; | ||
29 | int (*callback) (void *dev, int command, int arg); | ||
30 | }; | ||
31 | |||
25 | /* xc2028 commands for callback */ | 32 | /* xc2028 commands for callback */ |
26 | #define XC2028_TUNER_RESET 0 | 33 | #define XC2028_TUNER_RESET 0 |
27 | #define XC2028_RESET_CLK 1 | 34 | #define XC2028_RESET_CLK 1 |
28 | 35 | ||
29 | #if defined(CONFIG_TUNER_XC2028) || (defined(CONFIG_TUNER_XC2028_MODULE) && defined(MODULE)) | 36 | #if defined(CONFIG_TUNER_XC2028) || (defined(CONFIG_TUNER_XC2028_MODULE) && defined(MODULE)) |
30 | int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, | 37 | void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg); |
31 | u8 i2c_addr, struct device *dev, void *video_dev, | ||
32 | int (*tuner_callback) (void *dev, int command, int arg)); | ||
33 | |||
34 | #else | 38 | #else |
35 | static inline int xc2028_attach(struct dvb_frontend *fe, | 39 | void *xc2028_attach(struct dvb_frontend *fe, |
36 | struct i2c_adapter *i2c_adap, | 40 | struct xc2028_config *cfg) |
37 | u8 i2c_addr, struct device *dev, | ||
38 | void *video_dev, | ||
39 | int (*tuner_callback) (void *dev, int command, | ||
40 | int arg)) | ||
41 | { | 41 | { |
42 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", | 42 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", |
43 | __FUNCTION__); | 43 | __FUNCTION__); |