Skip to content

Commit 0927f82

Browse files
seanyoungksacilotto
authored andcommitted
media: smipcie: fix interrupt handling and IR timeout
BugLink: https://bugs.launchpad.net/bugs/1918974 commit 6532923 upstream. After the first IR message, interrupts are no longer received. In addition, the code generates a timeout IR message of 10ms but sets the timeout value to 100ms, so no timeout was ever generated. Link: https://bugzilla.kernel.org/show_bug.cgi?id=204317 Fixes: a49a7a4 ("media: smipcie: add universal ir capability") Tested-by: Laz Lev <lazlev@web.de> Cc: stable@vger.kernel.org # v5.1+ Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
1 parent 2cb5a4c commit 0927f82

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

drivers/media/pci/smipcie/smipcie-ir.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,45 @@ static void smi_ir_decode(struct smi_rc *ir)
6060
{
6161
struct smi_dev *dev = ir->dev;
6262
struct rc_dev *rc_dev = ir->rc_dev;
63-
u32 dwIRControl, dwIRData;
64-
u8 index, ucIRCount, readLoop;
63+
u32 control, data;
64+
u8 index, ir_count, read_loop;
6565

66-
dwIRControl = smi_read(IR_Init_Reg);
66+
control = smi_read(IR_Init_Reg);
6767

68-
if (dwIRControl & rbIRVld) {
69-
ucIRCount = (u8) smi_read(IR_Data_Cnt);
68+
dev_dbg(&rc_dev->dev, "ircontrol: 0x%08x\n", control);
7069

71-
readLoop = ucIRCount/4;
72-
if (ucIRCount % 4)
73-
readLoop += 1;
74-
for (index = 0; index < readLoop; index++) {
75-
dwIRData = smi_read(IR_DATA_BUFFER_BASE + (index * 4));
70+
if (control & rbIRVld) {
71+
ir_count = (u8)smi_read(IR_Data_Cnt);
7672

77-
ir->irData[index*4 + 0] = (u8)(dwIRData);
78-
ir->irData[index*4 + 1] = (u8)(dwIRData >> 8);
79-
ir->irData[index*4 + 2] = (u8)(dwIRData >> 16);
80-
ir->irData[index*4 + 3] = (u8)(dwIRData >> 24);
73+
dev_dbg(&rc_dev->dev, "ircount %d\n", ir_count);
74+
75+
read_loop = ir_count / 4;
76+
if (ir_count % 4)
77+
read_loop += 1;
78+
for (index = 0; index < read_loop; index++) {
79+
data = smi_read(IR_DATA_BUFFER_BASE + (index * 4));
80+
dev_dbg(&rc_dev->dev, "IRData 0x%08x\n", data);
81+
82+
ir->irData[index * 4 + 0] = (u8)(data);
83+
ir->irData[index * 4 + 1] = (u8)(data >> 8);
84+
ir->irData[index * 4 + 2] = (u8)(data >> 16);
85+
ir->irData[index * 4 + 3] = (u8)(data >> 24);
8186
}
82-
smi_raw_process(rc_dev, ir->irData, ucIRCount);
83-
smi_set(IR_Init_Reg, rbIRVld);
87+
smi_raw_process(rc_dev, ir->irData, ir_count);
8488
}
8589

86-
if (dwIRControl & rbIRhighidle) {
90+
if (control & rbIRhighidle) {
8791
struct ir_raw_event rawir = {};
8892

93+
dev_dbg(&rc_dev->dev, "high idle\n");
94+
8995
rawir.pulse = 0;
9096
rawir.duration = US_TO_NS(SMI_SAMPLE_PERIOD *
9197
SMI_SAMPLE_IDLEMIN);
9298
ir_raw_event_store_with_filter(rc_dev, &rawir);
93-
smi_set(IR_Init_Reg, rbIRhighidle);
9499
}
95100

101+
smi_set(IR_Init_Reg, rbIRVld);
96102
ir_raw_event_handle(rc_dev);
97103
}
98104

@@ -151,7 +157,7 @@ int smi_ir_init(struct smi_dev *dev)
151157
rc_dev->dev.parent = &dev->pci_dev->dev;
152158

153159
rc_dev->map_name = dev->info->rc_map;
154-
rc_dev->timeout = MS_TO_NS(100);
160+
rc_dev->timeout = US_TO_NS(SMI_SAMPLE_PERIOD * SMI_SAMPLE_IDLEMIN);
155161
rc_dev->rx_resolution = US_TO_NS(SMI_SAMPLE_PERIOD);
156162

157163
ir->rc_dev = rc_dev;
@@ -174,7 +180,7 @@ void smi_ir_exit(struct smi_dev *dev)
174180
struct smi_rc *ir = &dev->ir;
175181
struct rc_dev *rc_dev = ir->rc_dev;
176182

177-
smi_ir_stop(ir);
178183
rc_unregister_device(rc_dev);
184+
smi_ir_stop(ir);
179185
ir->rc_dev = NULL;
180186
}

0 commit comments

Comments
 (0)