Skip to content

Commit

Permalink
[media] davinci: vpif display: size up the memory for the buffers fro…
Browse files Browse the repository at this point in the history
…m 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>
  • Loading branch information
Manjunath Hadli authored and Mauro Carvalho Chehab committed Jul 30, 2012
1 parent 3bc1953 commit fc613d4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
42 changes: 39 additions & 3 deletions drivers/media/video/davinci/vpif_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,24 @@ static int vpif_buffer_setup(struct videobuf_queue *q, unsigned int *count,
return 0;

*size = config_params.channel_bufsize[ch->channel_id];

/*
* Checking if the buffer size exceeds the available buffer
* ycmux_mode = 0 means 1 channel mode HD and
* ycmux_mode = 1 means 2 channels mode SD
*/
if (ch->vpifparams.std_info.ycmux_mode == 0) {
if (config_params.video_limit[ch->channel_id])
while (*size * *count > (config_params.video_limit[0]
+ config_params.video_limit[1]))
(*count)--;
} else {
if (config_params.video_limit[ch->channel_id])
while (*size * *count >
config_params.video_limit[ch->channel_id])
(*count)--;
}

if (*count < config_params.min_numbuffers)
*count = config_params.min_numbuffers;

Expand Down Expand Up @@ -828,7 +846,7 @@ static int vpif_reqbufs(struct file *file, void *priv,

common = &ch->common[index];

if (common->fmt.type != reqbuf->type)
if (common->fmt.type != reqbuf->type || !vpif_dev)
return -EINVAL;

if (0 != common->io_usrs)
Expand All @@ -845,7 +863,7 @@ static int vpif_reqbufs(struct file *file, void *priv,

/* Initialize videobuf queue as per the buffer type */
videobuf_queue_dma_contig_init(&common->buffer_queue,
&video_qops, NULL,
&video_qops, vpif_dev,
&common->irqlock,
reqbuf->type, field,
sizeof(struct videobuf_buffer), fh,
Expand Down Expand Up @@ -1690,9 +1708,9 @@ static __init int vpif_probe(struct platform_device *pdev)
struct video_device *vfd;
struct resource *res;
int subdev_count;
size_t size;

vpif_dev = &pdev->dev;

err = initialize_vpif();

if (err) {
Expand Down Expand Up @@ -1747,6 +1765,24 @@ static __init int vpif_probe(struct platform_device *pdev)
ch->video_dev = vfd;
}

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res) {
size = resource_size(res);
/* The resources are divided into two equal memory and when
* we have HD output we can add them together
*/
for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) {
ch = vpif_obj.dev[j];
ch->channel_id = j;

/* only enabled if second resource exists */
config_params.video_limit[ch->channel_id] = 0;
if (size)
config_params.video_limit[ch->channel_id] =
size/2;
}
}

for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) {
ch = vpif_obj.dev[j];
/* Initialize field of the channel objects */
Expand Down
1 change: 1 addition & 0 deletions drivers/media/video/davinci/vpif_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ struct vpif_config_params {
u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
u32 video_limit[VPIF_DISPLAY_NUM_CHANNELS];
u8 min_numbuffers;
};

Expand Down

0 comments on commit fc613d4

Please sign in to comment.