aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-07-17 21:31:29 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:29:03 -0400
commit1c22dad8ab86caef7a1f01cf3e9bb446a448aac5 (patch)
tree5f3ce52b628904d7d50574a35ea581469989db9d /drivers/media
parent4db16db4f60ce063435bd08b71c82aad1254cd95 (diff)
V4L/DVB (8395): saa7134: Fix Kbuild dependency of ir-kbd-i2c
Currently, saa7134 is dependent of ir-kbd-i2c, since it uses a symbol that is defined there. However, as this symbol is used only on saa7134, there's no sense on keeping it defined there (or on ir-commons). So, let's move it to saa7134 and remove one symbol for being exported. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/ir-kbd-i2c.c82
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c78
2 files changed, 78 insertions, 82 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 7b65f5e537f8..a30254bed311 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -194,88 +194,6 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
194 return 1; 194 return 1;
195} 195}
196 196
197/* Common (grey or coloured) pinnacle PCTV remote handling
198 *
199 */
200static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
201 int parity_offset, int marker, int code_modulo)
202{
203 unsigned char b[4];
204 unsigned int start = 0,parity = 0,code = 0;
205
206 /* poll IR chip */
207 if (4 != i2c_master_recv(&ir->c,b,4)) {
208 dprintk(2,"read error\n");
209 return -EIO;
210 }
211
212 for (start = 0; start < ARRAY_SIZE(b); start++) {
213 if (b[start] == marker) {
214 code=b[(start+parity_offset+1)%4];
215 parity=b[(start+parity_offset)%4];
216 }
217 }
218
219 /* Empty Request */
220 if (parity==0)
221 return 0;
222
223 /* Repeating... */
224 if (ir->old == parity)
225 return 0;
226
227 ir->old = parity;
228
229 /* drop special codes when a key is held down a long time for the grey controller
230 In this case, the second bit of the code is asserted */
231 if (marker == 0xfe && (code & 0x40))
232 return 0;
233
234 code %= code_modulo;
235
236 *ir_raw = code;
237 *ir_key = code;
238
239 dprintk(1,"Pinnacle PCTV key %02x\n", code);
240
241 return 1;
242}
243
244/* The grey pinnacle PCTV remote
245 *
246 * There are one issue with this remote:
247 * - I2c packet does not change when the same key is pressed quickly. The workaround
248 * is to hold down each key for about half a second, so that another code is generated
249 * in the i2c packet, and the function can distinguish key presses.
250 *
251 * Sylvain Pasche <sylvain.pasche@gmail.com>
252 */
253int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
254{
255
256 return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
257}
258
259EXPORT_SYMBOL_GPL(get_key_pinnacle_grey);
260
261
262/* The new pinnacle PCTV remote (with the colored buttons)
263 *
264 * Ricardo Cerqueira <v4l@cerqueira.org>
265 */
266int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
267{
268 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
269 *
270 * this is the only value that results in 42 unique
271 * codes < 128
272 */
273
274 return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
275}
276
277EXPORT_SYMBOL_GPL(get_key_pinnacle_color);
278
279/* ----------------------------------------------------------------------- */ 197/* ----------------------------------------------------------------------- */
280 198
281static void ir_key_poll(struct IR_i2c *ir) 199static void ir_key_poll(struct IR_i2c *ir)
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index e6217fe13339..ad08d13dffdd 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -198,6 +198,84 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
198 return 1; 198 return 1;
199} 199}
200 200
201/* Common (grey or coloured) pinnacle PCTV remote handling
202 *
203 */
204static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
205 int parity_offset, int marker, int code_modulo)
206{
207 unsigned char b[4];
208 unsigned int start = 0,parity = 0,code = 0;
209
210 /* poll IR chip */
211 if (4 != i2c_master_recv(&ir->c, b, 4)) {
212 i2cdprintk("read error\n");
213 return -EIO;
214 }
215
216 for (start = 0; start < ARRAY_SIZE(b); start++) {
217 if (b[start] == marker) {
218 code=b[(start+parity_offset + 1) % 4];
219 parity=b[(start+parity_offset) % 4];
220 }
221 }
222
223 /* Empty Request */
224 if (parity == 0)
225 return 0;
226
227 /* Repeating... */
228 if (ir->old == parity)
229 return 0;
230
231 ir->old = parity;
232
233 /* drop special codes when a key is held down a long time for the grey controller
234 In this case, the second bit of the code is asserted */
235 if (marker == 0xfe && (code & 0x40))
236 return 0;
237
238 code %= code_modulo;
239
240 *ir_raw = code;
241 *ir_key = code;
242
243 i2cdprintk("Pinnacle PCTV key %02x\n", code);
244
245 return 1;
246}
247
248/* The grey pinnacle PCTV remote
249 *
250 * There are one issue with this remote:
251 * - I2c packet does not change when the same key is pressed quickly. The workaround
252 * is to hold down each key for about half a second, so that another code is generated
253 * in the i2c packet, and the function can distinguish key presses.
254 *
255 * Sylvain Pasche <sylvain.pasche@gmail.com>
256 */
257static int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
258{
259
260 return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
261}
262
263
264/* The new pinnacle PCTV remote (with the colored buttons)
265 *
266 * Ricardo Cerqueira <v4l@cerqueira.org>
267 */
268static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
269{
270 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
271 *
272 * this is the only value that results in 42 unique
273 * codes < 128
274 */
275
276 return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
277}
278
201void saa7134_input_irq(struct saa7134_dev *dev) 279void saa7134_input_irq(struct saa7134_dev *dev)
202{ 280{
203 struct card_ir *ir = dev->remote; 281 struct card_ir *ir = dev->remote;