brcm2708: update against latest rpi-3.10.y branch
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-3.10 / 0141-V4L2-Fix-issue-when-switching-down-JPEG-resolution.patch
1 From 50a40e8c2a9014c62943b034edefa035c0647519 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dsteve@broadcom.com>
3 Date: Mon, 9 Dec 2013 11:24:55 +0000
4 Subject: [PATCH 141/174] V4L2: Fix issue when switching down JPEG resolution.
5
6 JPEG buffer size calculation is based on input resolution.
7 Input resolution was being configured after output port
8 format. Caused failures if switching from one JPEG resolution
9 to a smaller one.
10
11 Signed-off-by: Dave Stevenson <dsteve@broadcom.com>
12 ---
13 drivers/media/platform/bcm2835/bcm2835-camera.c | 126 ++++++++++++++----------
14 1 file changed, 72 insertions(+), 54 deletions(-)
15
16 --- a/drivers/media/platform/bcm2835/bcm2835-camera.c
17 +++ b/drivers/media/platform/bcm2835/bcm2835-camera.c
18 @@ -955,69 +955,87 @@ static int mmal_setup_components(struct
19 camera_port->current_buffer.num =
20 camera_port->recommended_buffer.num;
21
22 - port->format.encoding = mfmt->mmal;
23 - port->format.encoding_variant = 0;
24 - /* Set any encoding specific parameters */
25 - switch (mfmt->mmal_component) {
26 - case MMAL_COMPONENT_VIDEO_ENCODE:
27 - port->format.bitrate =
28 - dev->capture.encode_bitrate;
29 - break;
30 - case MMAL_COMPONENT_IMAGE_ENCODE:
31 - /* Could set EXIF parameters here */
32 - break;
33 - default:
34 - break;
35 - }
36 - ret = vchiq_mmal_port_set_format(dev->instance, port);
37 -
38 + ret =
39 + vchiq_mmal_port_connect_tunnel(
40 + dev->instance,
41 + camera_port,
42 + &encode_component->input[0]);
43 if (ret) {
44 - v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
45 - "%s failed to set format\n", __func__);
46 + v4l2_dbg(1, bcm2835_v4l2_debug,
47 + &dev->v4l2_dev,
48 + "%s failed to create connection\n",
49 + __func__);
50 + /* ensure capture is not going to be tried */
51 + dev->capture.port = NULL;
52 } else {
53 + port->es.video.width = f->fmt.pix.width;
54 + port->es.video.height = f->fmt.pix.height;
55 + port->es.video.crop.x = 0;
56 + port->es.video.crop.y = 0;
57 + port->es.video.crop.width = f->fmt.pix.width;
58 + port->es.video.crop.height = f->fmt.pix.height;
59 + port->es.video.frame_rate.num =
60 + dev->capture.timeperframe.denominator;
61 + port->es.video.frame_rate.den =
62 + dev->capture.timeperframe.numerator;
63 +
64 + port->format.encoding = mfmt->mmal;
65 + port->format.encoding_variant = 0;
66 + /* Set any encoding specific parameters */
67 + switch (mfmt->mmal_component) {
68 + case MMAL_COMPONENT_VIDEO_ENCODE:
69 + port->format.bitrate =
70 + dev->capture.encode_bitrate;
71 + break;
72 + case MMAL_COMPONENT_IMAGE_ENCODE:
73 + /* Could set EXIF parameters here */
74 + break;
75 + default:
76 + break;
77 + }
78 + ret = vchiq_mmal_port_set_format(dev->instance,
79 + port);
80 + if (ret)
81 + v4l2_dbg(1, bcm2835_v4l2_debug,
82 + &dev->v4l2_dev,
83 + "%s failed to set format\n",
84 + __func__);
85 + }
86 +
87 + if (!ret) {
88 ret = vchiq_mmal_component_enable(
89 dev->instance,
90 encode_component);
91 if (ret) {
92 v4l2_dbg(1, bcm2835_v4l2_debug,
93 - &dev->v4l2_dev,
94 - "%s Failed to enable encode components\n",
95 - __func__);
96 - } else {
97 - /* configure buffering */
98 - port->current_buffer.num = 1;
99 - port->current_buffer.size =
100 - f->fmt.pix.sizeimage;
101 - if (port->format.encoding ==
102 - MMAL_ENCODING_JPEG) {
103 - v4l2_dbg(1, bcm2835_v4l2_debug,
104 - &dev->v4l2_dev,
105 - "JPEG - fiddle buffer size\n");
106 - port->current_buffer.size =
107 - (f->fmt.pix.sizeimage <
108 - (100 << 10))
109 - ? (100 << 10) : f->fmt.pix.
110 - sizeimage;
111 - }
112 + &dev->v4l2_dev,
113 + "%s Failed to enable encode components\n",
114 + __func__);
115 + }
116 + }
117 + if (!ret) {
118 + /* configure buffering */
119 + port->current_buffer.num = 1;
120 + port->current_buffer.size =
121 + f->fmt.pix.sizeimage;
122 + if (port->format.encoding ==
123 + MMAL_ENCODING_JPEG) {
124 v4l2_dbg(1, bcm2835_v4l2_debug,
125 - &dev->v4l2_dev,
126 - "vid_cap - current_buffer.size being set to %d\n",
127 - f->fmt.pix.sizeimage);
128 - port->current_buffer.alignment = 0;
129 - ret =
130 - vchiq_mmal_port_connect_tunnel(
131 - dev->instance,
132 - camera_port,
133 - &encode_component->input[0]);
134 - if (ret) {
135 - v4l2_dbg(1, bcm2835_v4l2_debug,
136 - &dev->v4l2_dev,
137 - "%s failed to create connection\n",
138 - __func__);
139 - /* ensure capture is not going to be tried */
140 - dev->capture.port = NULL;
141 - }
142 + &dev->v4l2_dev,
143 + "JPG - buf size now %d was %d\n",
144 + f->fmt.pix.sizeimage,
145 + port->current_buffer.size);
146 + port->current_buffer.size =
147 + (f->fmt.pix.sizeimage <
148 + (100 << 10))
149 + ? (100 << 10) : f->fmt.pix.
150 + sizeimage;
151 }
152 + v4l2_dbg(1, bcm2835_v4l2_debug,
153 + &dev->v4l2_dev,
154 + "vid_cap - cur_buf.size set to %d\n",
155 + f->fmt.pix.sizeimage);
156 + port->current_buffer.alignment = 0;
157 }
158 } else {
159 /* configure buffering */