1 From 94a174095f29c77574548eea17aacaed5c540757 Mon Sep 17 00:00:00 2001
2 From: Stefan Wahren <stefan.wahren@i2se.com>
3 Date: Sun, 21 Oct 2018 18:40:07 +0200
4 Subject: [PATCH 235/806] staging: bcm2835-camera: Provide more specific probe
7 Currently there is only a catch-all info message which print the
8 relevant error code without any context. So add more specific error
9 messages in order to narrow down possible issues.
11 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
13 .../bcm2835-camera/bcm2835-camera.c | 58 +++++++++++++------
14 1 file changed, 39 insertions(+), 19 deletions(-)
16 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
17 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
18 @@ -1552,8 +1552,11 @@ static int mmal_init(struct bm2835_mmal_
19 struct vchiq_mmal_component *camera;
21 ret = vchiq_mmal_init(&dev->instance);
24 + v4l2_err(&dev->v4l2_dev, "%s: vchiq mmal init failed %d\n",
29 /* get the camera component ready */
30 ret = vchiq_mmal_component_init(dev->instance, "ril.camera",
31 @@ -1562,7 +1565,9 @@ static int mmal_init(struct bm2835_mmal_
34 camera = dev->component[MMAL_COMPONENT_CAMERA];
35 - if (camera->outputs < MMAL_CAMERA_PORT_COUNT) {
36 + if (camera->outputs < MMAL_CAMERA_PORT_COUNT) {
37 + v4l2_err(&dev->v4l2_dev, "%s: too few camera outputs %d needed %d\n",
38 + __func__, camera->outputs, MMAL_CAMERA_PORT_COUNT);
42 @@ -1570,8 +1575,11 @@ static int mmal_init(struct bm2835_mmal_
43 ret = set_camera_parameters(dev->instance,
48 + v4l2_err(&dev->v4l2_dev, "%s: unable to set camera parameters: %d\n",
53 /* There was an error in the firmware that meant the camera component
54 * produced BGR instead of RGB.
55 @@ -1660,8 +1668,8 @@ static int mmal_init(struct bm2835_mmal_
57 if (dev->component[MMAL_COMPONENT_PREVIEW]->inputs < 1) {
59 - pr_debug("too few input ports %d needed %d\n",
60 - dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1);
61 + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n",
62 + __func__, dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1);
66 @@ -1674,8 +1682,8 @@ static int mmal_init(struct bm2835_mmal_
68 if (dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs < 1) {
70 - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n",
71 - dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs,
72 + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n",
73 + __func__, dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs,
75 goto unreg_image_encoder;
77 @@ -1689,8 +1697,8 @@ static int mmal_init(struct bm2835_mmal_
79 if (dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs < 1) {
81 - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n",
82 - dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs,
83 + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n",
84 + __func__, dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs,
86 goto unreg_vid_encoder;
88 @@ -1719,8 +1727,11 @@ static int mmal_init(struct bm2835_mmal_
91 ret = bm2835_mmal_set_all_camera_controls(dev);
94 + v4l2_err(&dev->v4l2_dev, "%s: failed to set all camera controls: %d\n",
96 goto unreg_vid_encoder;
101 @@ -1880,21 +1891,29 @@ static int bcm2835_mmal_probe(struct pla
102 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name),
103 "%s", BM2835_MMAL_MODULE_NAME);
104 ret = v4l2_device_register(NULL, &dev->v4l2_dev);
107 + dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n",
112 /* setup v4l controls */
113 ret = bm2835_mmal_init_controls(dev, &dev->ctrl_handler);
116 + v4l2_err(&dev->v4l2_dev, "%s: could not init controls: %d\n",
120 dev->v4l2_dev.ctrl_handler = &dev->ctrl_handler;
123 dev->instance = instance;
124 ret = mmal_init(dev);
127 + v4l2_err(&dev->v4l2_dev, "%s: mmal init failed: %d\n",
132 /* initialize queue */
133 q = &dev->capture.vb_vidq;
134 memset(q, 0, sizeof(*q));
135 @@ -1912,16 +1931,19 @@ static int bcm2835_mmal_probe(struct pla
137 /* initialise video devices */
138 ret = bm2835_mmal_init_device(dev, &dev->vdev);
141 + v4l2_err(&dev->v4l2_dev, "%s: could not init device: %d\n",
146 /* Really want to call vidioc_s_fmt_vid_cap with the default
147 * format, but currently the APIs don't join up.
149 ret = mmal_setup_components(dev, &default_v4l2_format);
151 - v4l2_err(&dev->v4l2_dev,
152 - "%s: could not setup components\n", __func__);
153 + v4l2_err(&dev->v4l2_dev, "%s: could not setup components: %d\n",
158 @@ -1945,8 +1967,6 @@ cleanup_gdev:
159 bcm2835_cleanup_instance(gdev[i]);
162 - pr_info("%s: error %d while loading driver\n",
163 - BM2835_MMAL_MODULE_NAME, ret);