diff options
author | Lad, Prabhakar <prabhakar.csengg@gmail.com> | 2014-05-16 09:33:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-05-23 18:00:04 -0400 |
commit | a2b235cb481c6b1e497839c384e5746632603b86 (patch) | |
tree | 77f524b3673610fe77671e2bb75a6edd001e017a /drivers/media/platform/davinci | |
parent | 49b2f4c56fbf70ca693d6df1c491f0566d516aea (diff) |
[media] media: davinci: vpif_display: initialize vb2 queue and DMA context during probe
this patch moves the initalization of vb2 queue and
the DMA context to probe() and clean up in remove()
callback respectively.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/platform/davinci')
-rw-r--r-- | drivers/media/platform/davinci/vpif_display.c | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index d03487fb1888..dbd4f0f60919 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c | |||
@@ -74,12 +74,12 @@ static void vpif_config_addr(struct channel_obj *ch, int muxmode); | |||
74 | */ | 74 | */ |
75 | static int vpif_buffer_prepare(struct vb2_buffer *vb) | 75 | static int vpif_buffer_prepare(struct vb2_buffer *vb) |
76 | { | 76 | { |
77 | struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue); | ||
78 | struct vb2_queue *q = vb->vb2_queue; | 77 | struct vb2_queue *q = vb->vb2_queue; |
78 | struct channel_obj *ch = vb2_get_drv_priv(q); | ||
79 | struct common_obj *common; | 79 | struct common_obj *common; |
80 | unsigned long addr; | 80 | unsigned long addr; |
81 | 81 | ||
82 | common = &fh->channel->common[VPIF_VIDEO_INDEX]; | 82 | common = &ch->common[VPIF_VIDEO_INDEX]; |
83 | if (vb->state != VB2_BUF_STATE_ACTIVE && | 83 | if (vb->state != VB2_BUF_STATE_ACTIVE && |
84 | vb->state != VB2_BUF_STATE_PREPARED) { | 84 | vb->state != VB2_BUF_STATE_PREPARED) { |
85 | vb2_set_plane_payload(vb, 0, common->fmt.fmt.pix.sizeimage); | 85 | vb2_set_plane_payload(vb, 0, common->fmt.fmt.pix.sizeimage); |
@@ -112,8 +112,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, | |||
112 | unsigned int *nbuffers, unsigned int *nplanes, | 112 | unsigned int *nbuffers, unsigned int *nplanes, |
113 | unsigned int sizes[], void *alloc_ctxs[]) | 113 | unsigned int sizes[], void *alloc_ctxs[]) |
114 | { | 114 | { |
115 | struct vpif_fh *fh = vb2_get_drv_priv(vq); | 115 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
116 | struct channel_obj *ch = fh->channel; | ||
117 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; | 116 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
118 | unsigned long size; | 117 | unsigned long size; |
119 | 118 | ||
@@ -154,10 +153,9 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, | |||
154 | */ | 153 | */ |
155 | static void vpif_buffer_queue(struct vb2_buffer *vb) | 154 | static void vpif_buffer_queue(struct vb2_buffer *vb) |
156 | { | 155 | { |
157 | struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue); | ||
158 | struct vpif_disp_buffer *buf = container_of(vb, | 156 | struct vpif_disp_buffer *buf = container_of(vb, |
159 | struct vpif_disp_buffer, vb); | 157 | struct vpif_disp_buffer, vb); |
160 | struct channel_obj *ch = fh->channel; | 158 | struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue); |
161 | struct common_obj *common; | 159 | struct common_obj *common; |
162 | unsigned long flags; | 160 | unsigned long flags; |
163 | 161 | ||
@@ -175,10 +173,9 @@ static void vpif_buffer_queue(struct vb2_buffer *vb) | |||
175 | */ | 173 | */ |
176 | static void vpif_buf_cleanup(struct vb2_buffer *vb) | 174 | static void vpif_buf_cleanup(struct vb2_buffer *vb) |
177 | { | 175 | { |
178 | struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue); | ||
179 | struct vpif_disp_buffer *buf = container_of(vb, | 176 | struct vpif_disp_buffer *buf = container_of(vb, |
180 | struct vpif_disp_buffer, vb); | 177 | struct vpif_disp_buffer, vb); |
181 | struct channel_obj *ch = fh->channel; | 178 | struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue); |
182 | struct common_obj *common; | 179 | struct common_obj *common; |
183 | unsigned long flags; | 180 | unsigned long flags; |
184 | 181 | ||
@@ -192,8 +189,7 @@ static void vpif_buf_cleanup(struct vb2_buffer *vb) | |||
192 | 189 | ||
193 | static void vpif_wait_prepare(struct vb2_queue *vq) | 190 | static void vpif_wait_prepare(struct vb2_queue *vq) |
194 | { | 191 | { |
195 | struct vpif_fh *fh = vb2_get_drv_priv(vq); | 192 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
196 | struct channel_obj *ch = fh->channel; | ||
197 | struct common_obj *common; | 193 | struct common_obj *common; |
198 | 194 | ||
199 | common = &ch->common[VPIF_VIDEO_INDEX]; | 195 | common = &ch->common[VPIF_VIDEO_INDEX]; |
@@ -202,8 +198,7 @@ static void vpif_wait_prepare(struct vb2_queue *vq) | |||
202 | 198 | ||
203 | static void vpif_wait_finish(struct vb2_queue *vq) | 199 | static void vpif_wait_finish(struct vb2_queue *vq) |
204 | { | 200 | { |
205 | struct vpif_fh *fh = vb2_get_drv_priv(vq); | 201 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
206 | struct channel_obj *ch = fh->channel; | ||
207 | struct common_obj *common; | 202 | struct common_obj *common; |
208 | 203 | ||
209 | common = &ch->common[VPIF_VIDEO_INDEX]; | 204 | common = &ch->common[VPIF_VIDEO_INDEX]; |
@@ -226,8 +221,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
226 | { | 221 | { |
227 | struct vpif_display_config *vpif_config_data = | 222 | struct vpif_display_config *vpif_config_data = |
228 | vpif_dev->platform_data; | 223 | vpif_dev->platform_data; |
229 | struct vpif_fh *fh = vb2_get_drv_priv(vq); | 224 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
230 | struct channel_obj *ch = fh->channel; | ||
231 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; | 225 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
232 | struct vpif_params *vpif = &ch->vpifparams; | 226 | struct vpif_params *vpif = &ch->vpifparams; |
233 | unsigned long addr = 0; | 227 | unsigned long addr = 0; |
@@ -310,8 +304,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
310 | /* abort streaming and wait for last buffer */ | 304 | /* abort streaming and wait for last buffer */ |
311 | static void vpif_stop_streaming(struct vb2_queue *vq) | 305 | static void vpif_stop_streaming(struct vb2_queue *vq) |
312 | { | 306 | { |
313 | struct vpif_fh *fh = vb2_get_drv_priv(vq); | 307 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
314 | struct channel_obj *ch = fh->channel; | ||
315 | struct common_obj *common; | 308 | struct common_obj *common; |
316 | unsigned long flags; | 309 | unsigned long flags; |
317 | 310 | ||
@@ -794,10 +787,6 @@ static int vpif_release(struct file *filep) | |||
794 | if (fh->io_allowed[VPIF_VIDEO_INDEX]) { | 787 | if (fh->io_allowed[VPIF_VIDEO_INDEX]) { |
795 | /* Reset io_usrs member of channel object */ | 788 | /* Reset io_usrs member of channel object */ |
796 | common->io_usrs = 0; | 789 | common->io_usrs = 0; |
797 | /* Free buffers allocated */ | ||
798 | vb2_queue_release(&common->buffer_queue); | ||
799 | vb2_dma_contig_cleanup_ctx(common->alloc_ctx); | ||
800 | |||
801 | common->numbuffers = | 790 | common->numbuffers = |
802 | config_params.numbuffers[ch->channel_id]; | 791 | config_params.numbuffers[ch->channel_id]; |
803 | } | 792 | } |
@@ -939,9 +928,7 @@ static int vpif_reqbufs(struct file *file, void *priv, | |||
939 | struct channel_obj *ch = fh->channel; | 928 | struct channel_obj *ch = fh->channel; |
940 | struct common_obj *common; | 929 | struct common_obj *common; |
941 | enum v4l2_field field; | 930 | enum v4l2_field field; |
942 | struct vb2_queue *q; | ||
943 | u8 index = 0; | 931 | u8 index = 0; |
944 | int ret; | ||
945 | 932 | ||
946 | /* This file handle has not initialized the channel, | 933 | /* This file handle has not initialized the channel, |
947 | It is not allowed to do settings */ | 934 | It is not allowed to do settings */ |
@@ -973,35 +960,12 @@ static int vpif_reqbufs(struct file *file, void *priv, | |||
973 | } else { | 960 | } else { |
974 | field = V4L2_VBI_INTERLACED; | 961 | field = V4L2_VBI_INTERLACED; |
975 | } | 962 | } |
976 | /* Initialize videobuf2 queue as per the buffer type */ | ||
977 | common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev); | ||
978 | if (IS_ERR(common->alloc_ctx)) { | ||
979 | vpif_err("Failed to get the context\n"); | ||
980 | return PTR_ERR(common->alloc_ctx); | ||
981 | } | ||
982 | q = &common->buffer_queue; | ||
983 | q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | ||
984 | q->io_modes = VB2_MMAP | VB2_USERPTR; | ||
985 | q->drv_priv = fh; | ||
986 | q->ops = &video_qops; | ||
987 | q->mem_ops = &vb2_dma_contig_memops; | ||
988 | q->buf_struct_size = sizeof(struct vpif_disp_buffer); | ||
989 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
990 | q->min_buffers_needed = 1; | ||
991 | |||
992 | ret = vb2_queue_init(q); | ||
993 | if (ret) { | ||
994 | vpif_err("vpif_display: vb2_queue_init() failed\n"); | ||
995 | vb2_dma_contig_cleanup_ctx(common->alloc_ctx); | ||
996 | return ret; | ||
997 | } | ||
998 | /* Set io allowed member of file handle to TRUE */ | 963 | /* Set io allowed member of file handle to TRUE */ |
999 | fh->io_allowed[index] = 1; | 964 | fh->io_allowed[index] = 1; |
1000 | /* Increment io usrs member of channel object to 1 */ | 965 | /* Increment io usrs member of channel object to 1 */ |
1001 | common->io_usrs = 1; | 966 | common->io_usrs = 1; |
1002 | /* Store type of memory requested in channel object */ | 967 | /* Store type of memory requested in channel object */ |
1003 | common->memory = reqbuf->memory; | 968 | common->memory = reqbuf->memory; |
1004 | INIT_LIST_HEAD(&common->dma_queue); | ||
1005 | /* Allocate buffers */ | 969 | /* Allocate buffers */ |
1006 | return vb2_reqbufs(&common->buffer_queue, reqbuf); | 970 | return vb2_reqbufs(&common->buffer_queue, reqbuf); |
1007 | } | 971 | } |
@@ -1637,6 +1601,7 @@ static int vpif_probe_complete(void) | |||
1637 | { | 1601 | { |
1638 | struct common_obj *common; | 1602 | struct common_obj *common; |
1639 | struct channel_obj *ch; | 1603 | struct channel_obj *ch; |
1604 | struct vb2_queue *q; | ||
1640 | int j, err, k; | 1605 | int j, err, k; |
1641 | 1606 | ||
1642 | for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) { | 1607 | for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) { |
@@ -1685,6 +1650,32 @@ static int vpif_probe_complete(void) | |||
1685 | if (err) | 1650 | if (err) |
1686 | goto probe_out; | 1651 | goto probe_out; |
1687 | 1652 | ||
1653 | /* Initialize vb2 queue */ | ||
1654 | q = &common->buffer_queue; | ||
1655 | q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | ||
1656 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; | ||
1657 | q->drv_priv = ch; | ||
1658 | q->ops = &video_qops; | ||
1659 | q->mem_ops = &vb2_dma_contig_memops; | ||
1660 | q->buf_struct_size = sizeof(struct vpif_disp_buffer); | ||
1661 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
1662 | q->min_buffers_needed = 1; | ||
1663 | |||
1664 | err = vb2_queue_init(q); | ||
1665 | if (err) { | ||
1666 | vpif_err("vpif_display: vb2_queue_init() failed\n"); | ||
1667 | goto probe_out; | ||
1668 | } | ||
1669 | |||
1670 | common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev); | ||
1671 | if (IS_ERR(common->alloc_ctx)) { | ||
1672 | vpif_err("Failed to get the context\n"); | ||
1673 | err = PTR_ERR(common->alloc_ctx); | ||
1674 | goto probe_out; | ||
1675 | } | ||
1676 | |||
1677 | INIT_LIST_HEAD(&common->dma_queue); | ||
1678 | |||
1688 | /* register video device */ | 1679 | /* register video device */ |
1689 | vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", | 1680 | vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", |
1690 | (int)ch, (int)&ch->video_dev); | 1681 | (int)ch, (int)&ch->video_dev); |
@@ -1700,6 +1691,8 @@ static int vpif_probe_complete(void) | |||
1700 | probe_out: | 1691 | probe_out: |
1701 | for (k = 0; k < j; k++) { | 1692 | for (k = 0; k < j; k++) { |
1702 | ch = vpif_obj.dev[k]; | 1693 | ch = vpif_obj.dev[k]; |
1694 | common = &ch->common[k]; | ||
1695 | vb2_dma_contig_cleanup_ctx(common->alloc_ctx); | ||
1703 | video_unregister_device(ch->video_dev); | 1696 | video_unregister_device(ch->video_dev); |
1704 | video_device_release(ch->video_dev); | 1697 | video_device_release(ch->video_dev); |
1705 | ch->video_dev = NULL; | 1698 | ch->video_dev = NULL; |
@@ -1865,6 +1858,7 @@ vpif_unregister: | |||
1865 | */ | 1858 | */ |
1866 | static int vpif_remove(struct platform_device *device) | 1859 | static int vpif_remove(struct platform_device *device) |
1867 | { | 1860 | { |
1861 | struct common_obj *common; | ||
1868 | struct channel_obj *ch; | 1862 | struct channel_obj *ch; |
1869 | int i; | 1863 | int i; |
1870 | 1864 | ||
@@ -1875,6 +1869,8 @@ static int vpif_remove(struct platform_device *device) | |||
1875 | for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) { | 1869 | for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) { |
1876 | /* Get the pointer to the channel object */ | 1870 | /* Get the pointer to the channel object */ |
1877 | ch = vpif_obj.dev[i]; | 1871 | ch = vpif_obj.dev[i]; |
1872 | common = &ch->common[i]; | ||
1873 | vb2_dma_contig_cleanup_ctx(common->alloc_ctx); | ||
1878 | /* Unregister video device */ | 1874 | /* Unregister video device */ |
1879 | video_unregister_device(ch->video_dev); | 1875 | video_unregister_device(ch->video_dev); |
1880 | 1876 | ||