aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorManjunath Hadli <manjunath.hadli@ti.com>2012-04-13 03:49:34 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-30 18:04:32 -0400
commit764af39aa415c9418f035d2a4bd606d7a7814a68 (patch)
tree54d38fa2aa8569a924b1289a7f631e540a65be60 /drivers/media/video
parentfc613d44e08a9f0986e493e2605132161b5b39a5 (diff)
[media] davinci: vpif capture: size up the memory for the buffers from the buffer pool
Size up the memory for the buffers from the buffer pool allocated in board file. Then adjust the reqbuf count depending the available memory. Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/davinci/vpif_capture.c39
-rw-r--r--drivers/media/video/davinci/vpif_capture.h1
2 files changed, 38 insertions, 2 deletions
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index bce31ea55dc4..d126fb6d74b6 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -217,6 +217,23 @@ static int vpif_buffer_setup(struct videobuf_queue *q, unsigned int *count,
217 /* Calculate the size of the buffer */ 217 /* Calculate the size of the buffer */
218 *size = config_params.channel_bufsize[ch->channel_id]; 218 *size = config_params.channel_bufsize[ch->channel_id];
219 219
220 /*
221 * Checking if the buffer size exceeds the available buffer
222 * ycmux_mode = 0 means 1 channel mode HD and
223 * ycmux_mode = 1 means 2 channels mode SD
224 */
225 if (ch->vpifparams.std_info.ycmux_mode == 0) {
226 if (config_params.video_limit[ch->channel_id])
227 while (*size * *count > (config_params.video_limit[0]
228 + config_params.video_limit[1]))
229 (*count)--;
230 } else {
231 if (config_params.video_limit[ch->channel_id])
232 while (*size * *count >
233 config_params.video_limit[ch->channel_id])
234 (*count)--;
235 }
236
220 if (*count < config_params.min_numbuffers) 237 if (*count < config_params.min_numbuffers)
221 *count = config_params.min_numbuffers; 238 *count = config_params.min_numbuffers;
222 return 0; 239 return 0;
@@ -890,7 +907,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
890 } 907 }
891 } 908 }
892 909
893 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != reqbuf->type) 910 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != reqbuf->type || !vpif_dev)
894 return -EINVAL; 911 return -EINVAL;
895 912
896 index = VPIF_VIDEO_INDEX; 913 index = VPIF_VIDEO_INDEX;
@@ -902,7 +919,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
902 919
903 /* Initialize videobuf queue as per the buffer type */ 920 /* Initialize videobuf queue as per the buffer type */
904 videobuf_queue_dma_contig_init(&common->buffer_queue, 921 videobuf_queue_dma_contig_init(&common->buffer_queue,
905 &video_qops, NULL, 922 &video_qops, vpif_dev,
906 &common->irqlock, 923 &common->irqlock,
907 reqbuf->type, 924 reqbuf->type,
908 common->fmt.fmt.pix.field, 925 common->fmt.fmt.pix.field,
@@ -2171,6 +2188,7 @@ static __init int vpif_probe(struct platform_device *pdev)
2171 struct video_device *vfd; 2188 struct video_device *vfd;
2172 struct resource *res; 2189 struct resource *res;
2173 int subdev_count; 2190 int subdev_count;
2191 size_t size;
2174 2192
2175 vpif_dev = &pdev->dev; 2193 vpif_dev = &pdev->dev;
2176 2194
@@ -2225,6 +2243,23 @@ static __init int vpif_probe(struct platform_device *pdev)
2225 ch->video_dev = vfd; 2243 ch->video_dev = vfd;
2226 } 2244 }
2227 2245
2246 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2247 if (res) {
2248 size = resource_size(res);
2249 /* The resources are divided into two equal memory and when we
2250 * have HD output we can add them together
2251 */
2252 for (j = 0; j < VPIF_CAPTURE_MAX_DEVICES; j++) {
2253 ch = vpif_obj.dev[j];
2254 ch->channel_id = j;
2255 /* only enabled if second resource exists */
2256 config_params.video_limit[ch->channel_id] = 0;
2257 if (size)
2258 config_params.video_limit[ch->channel_id] =
2259 size/2;
2260 }
2261 }
2262
2228 for (j = 0; j < VPIF_CAPTURE_MAX_DEVICES; j++) { 2263 for (j = 0; j < VPIF_CAPTURE_MAX_DEVICES; j++) {
2229 ch = vpif_obj.dev[j]; 2264 ch = vpif_obj.dev[j];
2230 ch->channel_id = j; 2265 ch->channel_id = j;
diff --git a/drivers/media/video/davinci/vpif_capture.h b/drivers/media/video/davinci/vpif_capture.h
index a693d4ebda55..8095910f02c1 100644
--- a/drivers/media/video/davinci/vpif_capture.h
+++ b/drivers/media/video/davinci/vpif_capture.h
@@ -151,6 +151,7 @@ struct vpif_config_params {
151 u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS]; 151 u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
152 u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS]; 152 u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
153 u8 default_device[VPIF_CAPTURE_NUM_CHANNELS]; 153 u8 default_device[VPIF_CAPTURE_NUM_CHANNELS];
154 u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS];
154 u8 max_device_type; 155 u8 max_device_type;
155}; 156};
156/* Struct which keeps track of the line numbers for the sliced vbi service */ 157/* Struct which keeps track of the line numbers for the sliced vbi service */