forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/dvb-usb/digitv.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0
23 * receiver
34 *
....@@ -5,11 +6,7 @@
56 *
67 * partly based on the SDK published by Nebula Electronics
78 *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the Free
10
- * Software Foundation, version 2.
11
- *
12
- * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
9
+ * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
1310 */
1411 #include "digitv.h"
1512
....@@ -66,6 +63,10 @@
6663 warn("more than 2 i2c messages at a time is not handled yet. TODO.");
6764
6865 for (i = 0; i < num; i++) {
66
+ if (msg[i].len < 1) {
67
+ i = -EOPNOTSUPP;
68
+ break;
69
+ }
6970 /* write/read request */
7071 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
7172 if (digitv_ctrl_msg(d, USB_READ_COFDM, msg[i].buf[0], NULL, 0,
....@@ -93,9 +94,10 @@
9394 };
9495
9596 /* Callbacks for DVB USB */
96
-static int digitv_identify_state (struct usb_device *udev, struct
97
- dvb_usb_device_properties *props, struct dvb_usb_device_description **desc,
98
- int *cold)
97
+static int digitv_identify_state(struct usb_device *udev,
98
+ const struct dvb_usb_device_properties *props,
99
+ const struct dvb_usb_device_description **desc,
100
+ int *cold)
99101 {
100102 *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0;
101103 return 0;
....@@ -233,14 +235,15 @@
233235
234236 static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
235237 {
238
+ struct rc_map_table *entry;
236239 int ret, i;
237
- u8 key[5];
240
+ u8 key[4];
238241 u8 b[4] = { 0 };
239242
240243 *event = 0;
241244 *state = REMOTE_NO_KEY_PRESSED;
242245
243
- ret = digitv_ctrl_msg(d, USB_READ_REMOTE, 0, NULL, 0, &key[1], 4);
246
+ ret = digitv_ctrl_msg(d, USB_READ_REMOTE, 0, NULL, 0, key, 4);
244247 if (ret)
245248 return ret;
246249
....@@ -251,20 +254,21 @@
251254 return ret;
252255
253256 /* if something is inside the buffer, simulate key press */
254
- if (key[1] != 0)
255
- {
256
- for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
257
- if (rc5_custom(&d->props.rc.legacy.rc_map_table[i]) == key[1] &&
258
- rc5_data(&d->props.rc.legacy.rc_map_table[i]) == key[2]) {
259
- *event = d->props.rc.legacy.rc_map_table[i].keycode;
257
+ if (key[0] != 0) {
258
+ for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
259
+ entry = &d->props.rc.legacy.rc_map_table[i];
260
+
261
+ if (rc5_custom(entry) == key[0] &&
262
+ rc5_data(entry) == key[1]) {
263
+ *event = entry->keycode;
260264 *state = REMOTE_KEY_PRESSED;
261265 return 0;
262266 }
263267 }
268
+
269
+ deb_rc("key: %*ph\n", 4, key);
264270 }
265271
266
- if (key[0] != 0)
267
- deb_rc("key: %*ph\n", 5, key);
268272 return 0;
269273 }
270274