Skip to content

Commit 120703f

Browse files
Alphixmchehab
authored andcommitted
[media] rc-core: document the protocol type
Right now the protocol information is not preserved, rc-core gets handed a scancode but has no idea which protocol it corresponds to. This patch (which required reading through the source/keymap for all drivers, not fun) makes the protocol information explicit which is important documentation and makes it easier to e.g. support multiple protocols with one decoder (think rc5 and rc-streamzap). The information isn't used yet so there should be no functional changes. [m.chehab@samsung.com: rebased, added cxusb and removed bad whitespacing] Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
1 parent af3a4a9 commit 120703f

40 files changed

Lines changed: 305 additions & 184 deletions

‎drivers/media/i2c/ir-kbd-i2c.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ static int ir_key_poll(struct IR_i2c *ir)
261261
}
262262

263263
if (rc) {
264-
dprintk(1, "%s: scancode = 0x%08x\n", __func__, scancode);
265-
rc_keydown(ir->rc, scancode, toggle);
264+
dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n",
265+
__func__, protocol, scancode);
266+
rc_keydown(ir->rc, protocol, scancode, toggle);
266267
}
267268
return 0;
268269
}

‎drivers/media/pci/bt8xx/bttv-input.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv)
7373

7474
if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
7575
(ir->mask_keyup && !(gpio & ir->mask_keyup))) {
76-
rc_keydown_notimeout(ir->dev, data, 0);
76+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
7777
} else {
7878
/* HACK: Probably, ir->mask_keydown is missing
7979
for this board */
8080
if (btv->c.type == BTTV_BOARD_WINFAST2000)
81-
rc_keydown_notimeout(ir->dev, data, 0);
81+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
8282

8383
rc_keyup(ir->dev);
8484
}
@@ -103,7 +103,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
103103
gpio, data,
104104
(gpio & ir->mask_keyup) ? " up" : "up/down");
105105

106-
rc_keydown_notimeout(ir->dev, data, 0);
106+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
107107
if (keyup)
108108
rc_keyup(ir->dev);
109109
} else {
@@ -117,7 +117,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
117117
if (keyup)
118118
rc_keyup(ir->dev);
119119
else
120-
rc_keydown_notimeout(ir->dev, data, 0);
120+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
121121
}
122122

123123
ir->last_gpio = data | keyup;
@@ -241,8 +241,8 @@ static void bttv_rc5_timer_end(unsigned long data)
241241
return;
242242
}
243243

244-
scancode = system << 8 | command;
245-
rc_keydown(ir->dev, scancode, toggle);
244+
scancode = RC_SCANCODE_RC5(system, command);
245+
rc_keydown(ir->dev, RC_TYPE_RC5, scancode, toggle);
246246
dprintk("scancode %x, toggle %x\n", scancode, toggle);
247247
}
248248

‎drivers/media/pci/cx88/cx88-input.c‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,41 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
130130

131131
data = (data << 4) | ((gpio_key & 0xf0) >> 4);
132132

133-
rc_keydown(ir->dev, data, 0);
133+
rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0);
134+
135+
} else if (ir->core->boardnr == CX88_BOARD_PROLINK_PLAYTVPVR ||
136+
ir->core->boardnr == CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO) {
137+
/* bit cleared on keydown, NEC scancode, 0xAAAACC, A = 0x866b */
138+
u16 addr;
139+
u8 cmd;
140+
u32 scancode;
141+
142+
addr = (data >> 8) & 0xffff;
143+
cmd = (data >> 0) & 0x00ff;
144+
scancode = RC_SCANCODE_NECX(addr, cmd);
145+
146+
if (0 == (gpio & ir->mask_keyup))
147+
rc_keydown_notimeout(ir->dev, RC_TYPE_NEC, scancode, 0);
148+
else
149+
rc_keyup(ir->dev);
134150

135151
} else if (ir->mask_keydown) {
136152
/* bit set on keydown */
137153
if (gpio & ir->mask_keydown)
138-
rc_keydown_notimeout(ir->dev, data, 0);
154+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
139155
else
140156
rc_keyup(ir->dev);
141157

142158
} else if (ir->mask_keyup) {
143159
/* bit cleared on keydown */
144160
if (0 == (gpio & ir->mask_keyup))
145-
rc_keydown_notimeout(ir->dev, data, 0);
161+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
146162
else
147163
rc_keyup(ir->dev);
148164

149165
} else {
150166
/* can't distinguish keydown/up :-/ */
151-
rc_keydown_notimeout(ir->dev, data, 0);
167+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
152168
rc_keyup(ir->dev);
153169
}
154170
}
@@ -329,6 +345,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
329345
* 002-T mini RC, provided with newer PV hardware
330346
*/
331347
ir_codes = RC_MAP_PIXELVIEW_MK12;
348+
rc_type = RC_BIT_NEC;
332349
ir->gpio_addr = MO_GP1_IO;
333350
ir->mask_keyup = 0x80;
334351
ir->polling = 10; /* ms */
@@ -416,7 +433,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
416433
break;
417434
case CX88_BOARD_TWINHAN_VP1027_DVBS:
418435
ir_codes = RC_MAP_TWINHAN_VP1027_DVBS;
419-
rc_type = RC_BIT_NEC;
420436
ir->sampling = 0xff00; /* address */
421437
break;
422438
}

‎drivers/media/pci/dm1105/dm1105.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ static void dm1105_emit_key(struct work_struct *work)
678678

679679
data = (ircom >> 8) & 0x7f;
680680

681-
rc_keydown(ir->dev, data, 0);
681+
/* FIXME: UNKNOWN because we don't generate a full NEC scancode (yet?) */
682+
rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0);
682683
}
683684

684685
/* work handler */

‎drivers/media/pci/saa7134/saa7134-input.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ static int build_key(struct saa7134_dev *dev)
8383
if (data == ir->mask_keycode)
8484
rc_keyup(ir->dev);
8585
else
86-
rc_keydown_notimeout(ir->dev, data, 0);
86+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
8787
return 0;
8888
}
8989

9090
if (ir->polling) {
9191
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
9292
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
93-
rc_keydown_notimeout(ir->dev, data, 0);
93+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
9494
} else {
9595
rc_keyup(ir->dev);
9696
}
9797
}
9898
else { /* IRQ driven mode - handle key press and release in one go */
9999
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
100100
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
101-
rc_keydown_notimeout(ir->dev, data, 0);
101+
rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
102102
rc_keyup(ir->dev);
103103
}
104104
}

‎drivers/media/pci/ttpci/budget-ci.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ static void msp430_ir_interrupt(unsigned long data)
161161
return;
162162

163163
if (budget_ci->ir.full_rc5) {
164-
rc_keydown(dev,
165-
budget_ci->ir.rc5_device <<8 | budget_ci->ir.ir_key,
166-
(command & 0x20) ? 1 : 0);
164+
rc_keydown(dev, RC_TYPE_RC5,
165+
RC_SCANCODE_RC5(budget_ci->ir.rc5_device, budget_ci->ir.ir_key),
166+
!!(command & 0x20));
167167
return;
168168
}
169169

170170
/* FIXME: We should generate complete scancodes for all devices */
171-
rc_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0);
171+
rc_keydown(dev, RC_TYPE_UNKNOWN, budget_ci->ir.ir_key, !!(command & 0x20));
172172
}
173173

174174
static int msp430_ir_init(struct budget_ci *budget_ci)

‎drivers/media/rc/ati_remote.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ static void ati_remote_input_report(struct urb *urb)
622622
* it would cause ghost repeats which would be a
623623
* regression for this driver.
624624
*/
625-
rc_keydown_notimeout(ati_remote->rdev, scancode,
626-
data[2]);
625+
rc_keydown_notimeout(ati_remote->rdev, RC_TYPE_OTHER,
626+
scancode, data[2]);
627627
rc_keyup(ati_remote->rdev);
628628
}
629629
return;

‎drivers/media/rc/img-ir/img-ir-hw.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static int img_ir_set_filter(struct rc_dev *dev, enum rc_filter_type type,
512512
static int img_ir_set_normal_filter(struct rc_dev *dev,
513513
struct rc_scancode_filter *sc_filter)
514514
{
515-
return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter);
515+
return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter);
516516
}
517517

518518
static int img_ir_set_wakeup_filter(struct rc_dev *dev,
@@ -795,9 +795,11 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
795795
struct img_ir_priv_hw *hw = &priv->hw;
796796
const struct img_ir_decoder *dec = hw->decoder;
797797
int ret = IMG_IR_SCANCODE;
798-
int scancode;
798+
u32 scancode;
799+
enum rc_type protocol = RC_TYPE_UNKNOWN;
800+
799801
if (dec->scancode)
800-
ret = dec->scancode(len, raw, &scancode, hw->enabled_protocols);
802+
ret = dec->scancode(len, raw, &protocol, &scancode, hw->enabled_protocols);
801803
else if (len >= 32)
802804
scancode = (u32)raw;
803805
else if (len < 32)
@@ -806,7 +808,7 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
806808
len, (unsigned long long)raw);
807809
if (ret == IMG_IR_SCANCODE) {
808810
dev_dbg(priv->dev, "decoded scan code %#x\n", scancode);
809-
rc_keydown(hw->rdev, scancode, 0);
811+
rc_keydown(hw->rdev, protocol, scancode, 0);
810812
img_ir_end_repeat(priv);
811813
} else if (ret == IMG_IR_REPEATCODE) {
812814
if (hw->mode == IMG_IR_M_REPEATING) {

‎drivers/media/rc/img-ir/img-ir-hw.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ struct img_ir_decoder {
162162
struct img_ir_control control;
163163

164164
/* scancode logic */
165-
int (*scancode)(int len, u64 raw, int *scancode, u64 protocols);
165+
int (*scancode)(int len, u64 raw, enum rc_type *protocol,
166+
u32 *scancode, u64 enabled_protocols);
166167
int (*filter)(const struct rc_scancode_filter *in,
167168
struct img_ir_filter *out, u64 protocols);
168169
};

‎drivers/media/rc/img-ir/img-ir-jvc.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include "img-ir-hw.h"
1313

1414
/* Convert JVC data to a scancode */
15-
static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
15+
static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol,
16+
u32 *scancode, u64 enabled_protocols)
1617
{
1718
unsigned int cust, data;
1819

@@ -22,6 +23,7 @@ static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
2223
cust = (raw >> 0) & 0xff;
2324
data = (raw >> 8) & 0xff;
2425

26+
*protocol = RC_TYPE_JVC;
2527
*scancode = cust << 8 | data;
2628
return IMG_IR_SCANCODE;
2729
}

0 commit comments

Comments
 (0)