aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tuner-xc2028.c
diff options
context:
space:
mode:
authorMichel Ludwig <michel.ludwig@gmail.com>2007-11-16 05:46:14 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:02:14 -0500
commita37b4c9bc87a74ed5003c385eae264fc0acf6b35 (patch)
tree50ac0d83aebd44f94b357592a22242f11716f7b9 /drivers/media/video/tuner-xc2028.c
parent2fc580ffeb551066f769934e3a4717d721d0a559 (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>
Diffstat (limited to 'drivers/media/video/tuner-xc2028.c')
-rw-r--r--drivers/media/video/tuner-xc2028.c53
1 files changed, 27 insertions, 26 deletions
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
885int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, 887void *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
941EXPORT_SYMBOL(xc2028_attach); 942EXPORT_SYMBOL(xc2028_attach);
942 943
943MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); 944MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver");