aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tuner-3036.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/tuner-3036.c')
-rw-r--r--drivers/media/video/tuner-3036.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index c4a78e7a5a5..74ab48c09c6 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * The SAB3036 is just about different enough from the chips that 6 * The SAB3036 is just about different enough from the chips that
7 * tuner.c copes with to make it not worth the effort to crowbar 7 * tuner.c copes with to make it not worth the effort to crowbar
8 * the support into that file. So instead we have a separate driver. 8 * the support into that file. So instead we have a separate driver.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
@@ -56,15 +56,15 @@ tuner_getstatus (struct i2c_client *c)
56 56
57#define TUNER_FL 0x80 57#define TUNER_FL 0x80
58 58
59static int 59static int
60tuner_islocked (struct i2c_client *c) 60tuner_islocked (struct i2c_client *c)
61{ 61{
62 return (tuner_getstatus(c) & TUNER_FL); 62 return (tuner_getstatus(c) & TUNER_FL);
63} 63}
64 64
65/* ---------------------------------------------------------------------- */ 65/* ---------------------------------------------------------------------- */
66 66
67static void 67static void
68set_tv_freq(struct i2c_client *c, int freq) 68set_tv_freq(struct i2c_client *c, int freq)
69{ 69{
70 u16 div = ((freq * 20) / 16); 70 u16 div = ((freq * 20) / 16);
@@ -73,26 +73,26 @@ set_tv_freq(struct i2c_client *c, int freq)
73 73
74 if (debug) 74 if (debug)
75 printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div); 75 printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div);
76 76
77 /* Select high tuning current */ 77 /* Select high tuning current */
78 buffer[0] = 0x29; 78 buffer[0] = 0x29;
79 buffer[1] = 0x3e; 79 buffer[1] = 0x3e;
80 80
81 if (i2c_master_send(c, buffer, 2) != 2) 81 if (i2c_master_send(c, buffer, 2) != 2)
82 printk("tuner: i2c i/o error 1\n"); 82 printk("tuner: i2c i/o error 1\n");
83 83
84 buffer[0] = 0x80 | ((div>>8) & 0x7f); 84 buffer[0] = 0x80 | ((div>>8) & 0x7f);
85 buffer[1] = div & 0xff; 85 buffer[1] = div & 0xff;
86 86
87 if (i2c_master_send(c, buffer, 2) != 2) 87 if (i2c_master_send(c, buffer, 2) != 2)
88 printk("tuner: i2c i/o error 2\n"); 88 printk("tuner: i2c i/o error 2\n");
89 89
90 while (!tuner_islocked(c) && time_before(jiffies, give_up)) 90 while (!tuner_islocked(c) && time_before(jiffies, give_up))
91 schedule(); 91 schedule();
92 92
93 if (!tuner_islocked(c)) 93 if (!tuner_islocked(c))
94 printk(KERN_WARNING "tuner: failed to achieve PLL lock\n"); 94 printk(KERN_WARNING "tuner: failed to achieve PLL lock\n");
95 95
96 /* Select low tuning current and engage AFC */ 96 /* Select low tuning current and engage AFC */
97 buffer[0] = 0x29; 97 buffer[0] = 0x29;
98 buffer[1] = 0xb2; 98 buffer[1] = 0xb2;
@@ -106,7 +106,7 @@ set_tv_freq(struct i2c_client *c, int freq)
106 106
107/* ---------------------------------------------------------------------- */ 107/* ---------------------------------------------------------------------- */
108 108
109static int 109static int
110tuner_attach(struct i2c_adapter *adap, int addr, int kind) 110tuner_attach(struct i2c_adapter *adap, int addr, int kind)
111{ 111{
112 static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 }; 112 static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 };
@@ -116,18 +116,18 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
116 if (this_adap > 0) 116 if (this_adap > 0)
117 return -1; 117 return -1;
118 this_adap++; 118 this_adap++;
119 119
120 client_template.adapter = adap; 120 client_template.adapter = adap;
121 client_template.addr = addr; 121 client_template.addr = addr;
122 122
123 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 123 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
124 if (client == NULL) 124 if (client == NULL)
125 return -ENOMEM; 125 return -ENOMEM;
126 memcpy(client, &client_template, sizeof(struct i2c_client)); 126 memcpy(client, &client_template, sizeof(struct i2c_client));
127 127
128 printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client)); 128 printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client));
129 129
130 i2c_attach_client(client); 130 i2c_attach_client(client);
131 131
132 if (i2c_master_send(client, buffer, 2) != 2) 132 if (i2c_master_send(client, buffer, 2) != 2)
133 printk("tuner: i2c i/o error 1\n"); 133 printk("tuner: i2c i/o error 1\n");
@@ -138,30 +138,30 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
138 return 0; 138 return 0;
139} 139}
140 140
141static int 141static int
142tuner_detach(struct i2c_client *c) 142tuner_detach(struct i2c_client *c)
143{ 143{
144 return 0; 144 return 0;
145} 145}
146 146
147static int 147static int
148tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) 148tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
149{ 149{
150 int *iarg = (int*)arg; 150 int *iarg = (int*)arg;
151 151
152 switch (cmd) 152 switch (cmd)
153 { 153 {
154 case VIDIOCSFREQ: 154 case VIDIOCSFREQ:
155 set_tv_freq(client, *iarg); 155 set_tv_freq(client, *iarg);
156 break; 156 break;
157 157
158 default: 158 default:
159 return -EINVAL; 159 return -EINVAL;
160 } 160 }
161 return 0; 161 return 0;
162} 162}
163 163
164static int 164static int
165tuner_probe(struct i2c_adapter *adap) 165tuner_probe(struct i2c_adapter *adap)
166{ 166{
167 this_adap = 0; 167 this_adap = 0;
@@ -172,8 +172,8 @@ tuner_probe(struct i2c_adapter *adap)
172 172
173/* ----------------------------------------------------------------------- */ 173/* ----------------------------------------------------------------------- */
174 174
175static struct i2c_driver 175static struct i2c_driver
176i2c_driver_tuner = 176i2c_driver_tuner =
177{ 177{
178 .driver = { 178 .driver = {
179 .name = "sab3036", 179 .name = "sab3036",
@@ -186,7 +186,7 @@ i2c_driver_tuner =
186 186
187static struct i2c_client client_template = 187static struct i2c_client client_template =
188{ 188{
189 .driver = &i2c_driver_tuner, 189 .driver = &i2c_driver_tuner,
190 .name = "SAB3036", 190 .name = "SAB3036",
191}; 191};
192 192