3300ed46860d914aac387fbe28de4449a60e31bd
[openwrt/staging/blocktrron.git] /
1 From af066bde5a442efd50868ffed1aad30190400c91 Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Tue, 19 May 2020 15:57:08 +0100
4 Subject: [PATCH] staging: vc04_services: isp: Reorder operations
5 during device probe
6
7 Register the video node at the end of the probe, swapping order with
8 registering the controls.
9
10 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
11 ---
12 .../bcm2835-isp/bcm2835-v4l2-isp.c | 48 ++++++++++++-------
13 1 file changed, 32 insertions(+), 16 deletions(-)
14
15 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
16 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
17 @@ -1295,21 +1295,6 @@ static int register_node(struct bcm2835_
18 }
19 node->queue_init = true;
20
21 - /* Define the device names */
22 - snprintf(vfd->name, sizeof(node->vfd.name), "%s-%s%d", BCM2835_ISP_NAME,
23 - node->name, node->id);
24 -
25 - ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr + index);
26 - if (ret) {
27 - v4l2_err(&dev->v4l2_dev,
28 - "Failed to register video %s[%d] device node\n",
29 - node->name, node->id);
30 - return ret;
31 - }
32 -
33 - node->registered = true;
34 - video_set_drvdata(vfd, node);
35 -
36 /* Set some controls and defaults, but only on the VIDEO_OUTPUT node. */
37 if (node_is_output(node)) {
38 unsigned int i;
39 @@ -1324,7 +1309,12 @@ static int register_node(struct bcm2835_
40 .step = 1,
41 };
42
43 - v4l2_ctrl_handler_init(&dev->ctrl_handler, 4);
44 + ret = v4l2_ctrl_handler_init(&dev->ctrl_handler, 12);
45 + if (ret) {
46 + v4l2_err(&dev->v4l2_dev, "ctrl_handler init failed (%d)\n",
47 + ret);
48 + return ret;
49 + }
50
51 dev->r_gain = 1000;
52 dev->b_gain = 1000;
53 @@ -1350,13 +1340,39 @@ static int register_node(struct bcm2835_
54 }
55
56 node->vfd.ctrl_handler = &dev->ctrl_handler;
57 + if (dev->ctrl_handler.error) {
58 + ret = dev->ctrl_handler.error;
59 + v4l2_err(&dev->v4l2_dev, "controls init failed (%d)\n",
60 + ret);
61 + v4l2_ctrl_handler_free(&dev->ctrl_handler);
62 + goto ctrl_cleanup;
63 + }
64 }
65
66 + /* Define the device names */
67 + snprintf(vfd->name, sizeof(node->vfd.name), "%s-%s%d", BCM2835_ISP_NAME,
68 + node->name, node->id);
69 +
70 + ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr + index);
71 + if (ret) {
72 + v4l2_err(&dev->v4l2_dev,
73 + "Failed to register video %s[%d] device node\n",
74 + node->name, node->id);
75 + goto ctrl_cleanup;
76 + }
77 +
78 + node->registered = true;
79 + video_set_drvdata(vfd, node);
80 +
81 v4l2_info(&dev->v4l2_dev,
82 "Device node %s[%d] registered as /dev/video%d\n",
83 node->name, node->id, vfd->num);
84
85 return 0;
86 +
87 +ctrl_cleanup:
88 + v4l2_ctrl_handler_free(&dev->ctrl_handler);
89 + return ret;
90 }
91
92 /* Unregister one of the /dev/video<N> nodes associated with the ISP. */