Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: rcar-vin: Move hardware buffer tracking to own struct

To support SEQ_TB/BT not all buffers given to the hardware will be
equal, the driver needs to keep track of different buffer types. Move
the tracking of buffers given to hardware into a struct so additional
tracking fields can be associated with each buffer.

[hverkuil: fix small checkpatch warning]

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Niklas Söderlund and committed by
Mauro Carvalho Chehab
e72b7359 dea0ab37

+19 -17
+14 -13
drivers/media/platform/rcar-vin/rcar-dma.c
··· 844 844 dma_addr_t phys_addr; 845 845 846 846 /* A already populated slot shall never be overwritten. */ 847 - if (WARN_ON(vin->queue_buf[slot] != NULL)) 847 + if (WARN_ON(vin->buf_hw[slot].buffer)) 848 848 return; 849 849 850 850 vin_dbg(vin, "Filling HW slot: %d\n", slot); 851 851 852 852 if (list_empty(&vin->buf_list)) { 853 - vin->queue_buf[slot] = NULL; 853 + vin->buf_hw[slot].buffer = NULL; 854 854 phys_addr = vin->scratch_phys; 855 855 } else { 856 856 /* Keep track of buffer we give to HW */ 857 857 buf = list_entry(vin->buf_list.next, struct rvin_buffer, list); 858 858 vbuf = &buf->vb; 859 859 list_del_init(to_buf_list(vbuf)); 860 - vin->queue_buf[slot] = vbuf; 860 + vin->buf_hw[slot].buffer = vbuf; 861 861 862 862 /* Setup DMA */ 863 863 phys_addr = vb2_dma_contig_plane_dma_addr(&vbuf->vb2_buf, 0); ··· 953 953 } 954 954 955 955 /* Capture frame */ 956 - if (vin->queue_buf[slot]) { 957 - vin->queue_buf[slot]->field = rvin_get_active_field(vin, vnms); 958 - vin->queue_buf[slot]->sequence = vin->sequence; 959 - vin->queue_buf[slot]->vb2_buf.timestamp = ktime_get_ns(); 960 - vb2_buffer_done(&vin->queue_buf[slot]->vb2_buf, 956 + if (vin->buf_hw[slot].buffer) { 957 + vin->buf_hw[slot].buffer->field = 958 + rvin_get_active_field(vin, vnms); 959 + vin->buf_hw[slot].buffer->sequence = vin->sequence; 960 + vin->buf_hw[slot].buffer->vb2_buf.timestamp = ktime_get_ns(); 961 + vb2_buffer_done(&vin->buf_hw[slot].buffer->vb2_buf, 961 962 VB2_BUF_STATE_DONE); 962 - vin->queue_buf[slot] = NULL; 963 + vin->buf_hw[slot].buffer = NULL; 963 964 } else { 964 965 /* Scratch buffer was used, dropping frame. */ 965 966 vin_dbg(vin, "Dropping frame %u\n", vin->sequence); ··· 984 983 int i; 985 984 986 985 for (i = 0; i < HW_BUFFER_NUM; i++) { 987 - if (vin->queue_buf[i]) { 988 - vb2_buffer_done(&vin->queue_buf[i]->vb2_buf, 986 + if (vin->buf_hw[i].buffer) { 987 + vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf, 989 988 state); 990 - vin->queue_buf[i] = NULL; 989 + vin->buf_hw[i].buffer = NULL; 991 990 } 992 991 } 993 992 ··· 1292 1291 vin->state = STOPPED; 1293 1292 1294 1293 for (i = 0; i < HW_BUFFER_NUM; i++) 1295 - vin->queue_buf[i] = NULL; 1294 + vin->buf_hw[i].buffer = NULL; 1296 1295 1297 1296 /* buffer queue */ 1298 1297 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+5 -4
drivers/media/platform/rcar-vin/rcar-vin.h
··· 164 164 * @scratch: cpu address for scratch buffer 165 165 * @scratch_phys: physical address of the scratch buffer 166 166 * 167 - * @qlock: protects @queue_buf, @buf_list, @sequence 168 - * @state 169 - * @queue_buf: Keeps track of buffers given to HW slot 167 + * @qlock: protects @buf_hw, @buf_list, @sequence and @state 168 + * @buf_hw: Keeps track of buffers given to HW slot 170 169 * @buf_list: list of queued buffers 171 170 * @sequence: V4L2 buffers sequence number 172 171 * @state: keeps track of operation state ··· 204 205 dma_addr_t scratch_phys; 205 206 206 207 spinlock_t qlock; 207 - struct vb2_v4l2_buffer *queue_buf[HW_BUFFER_NUM]; 208 + struct { 209 + struct vb2_v4l2_buffer *buffer; 210 + } buf_hw[HW_BUFFER_NUM]; 208 211 struct list_head buf_list; 209 212 unsigned int sequence; 210 213 enum rvin_dma_state state;