Commit f698957a authored by Libin Yang's avatar Libin Yang Committed by Mauro Carvalho Chehab

[media] marvell-ccic: use internal variable replace global frame stats variable

This patch replaces the global frame stats variables by using
internal variables in mcam_camera structure.
Signed-off-by: default avatarAlbert Wang <twang13@marvell.com>
Signed-off-by: default avatarLibin Yang <lbyang@marvell.com>
Acked-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent a4bb6f35
...@@ -30,13 +30,6 @@ ...@@ -30,13 +30,6 @@
#include "mcam-core.h" #include "mcam-core.h"
/*
* Basic frame stats - to be deleted shortly
*/
static int frames;
static int singles;
static int delivered;
#ifdef MCAM_MODE_VMALLOC #ifdef MCAM_MODE_VMALLOC
/* /*
* Internal DMA buffer management. Since the controller cannot do S/G I/O, * Internal DMA buffer management. Since the controller cannot do S/G I/O,
...@@ -367,10 +360,10 @@ static void mcam_frame_tasklet(unsigned long data) ...@@ -367,10 +360,10 @@ static void mcam_frame_tasklet(unsigned long data)
if (!test_bit(bufno, &cam->flags)) if (!test_bit(bufno, &cam->flags))
continue; continue;
if (list_empty(&cam->buffers)) { if (list_empty(&cam->buffers)) {
singles++; cam->frame_state.singles++;
break; /* Leave it valid, hope for better later */ break; /* Leave it valid, hope for better later */
} }
delivered++; cam->frame_state.delivered++;
clear_bit(bufno, &cam->flags); clear_bit(bufno, &cam->flags);
buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer,
queue); queue);
...@@ -452,7 +445,7 @@ static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame) ...@@ -452,7 +445,7 @@ static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR, mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0)); vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
set_bit(CF_SINGLE_BUFFER, &cam->flags); set_bit(CF_SINGLE_BUFFER, &cam->flags);
singles++; cam->frame_state.singles++;
return; return;
} }
/* /*
...@@ -485,7 +478,7 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, int frame) ...@@ -485,7 +478,7 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, int frame)
struct mcam_vb_buffer *buf = cam->vb_bufs[frame]; struct mcam_vb_buffer *buf = cam->vb_bufs[frame];
if (!test_bit(CF_SINGLE_BUFFER, &cam->flags)) { if (!test_bit(CF_SINGLE_BUFFER, &cam->flags)) {
delivered++; cam->frame_state.delivered++;
mcam_buffer_done(cam, frame, &buf->vb_buf); mcam_buffer_done(cam, frame, &buf->vb_buf);
} }
mcam_set_contig_buffer(cam, frame); mcam_set_contig_buffer(cam, frame);
...@@ -578,13 +571,13 @@ static void mcam_dma_sg_done(struct mcam_camera *cam, int frame) ...@@ -578,13 +571,13 @@ static void mcam_dma_sg_done(struct mcam_camera *cam, int frame)
*/ */
} else { } else {
set_bit(CF_SG_RESTART, &cam->flags); set_bit(CF_SG_RESTART, &cam->flags);
singles++; cam->frame_state.singles++;
cam->vb_bufs[0] = NULL; cam->vb_bufs[0] = NULL;
} }
/* /*
* Now we can give the completed frame back to user space. * Now we can give the completed frame back to user space.
*/ */
delivered++; cam->frame_state.delivered++;
mcam_buffer_done(cam, frame, &buf->vb_buf); mcam_buffer_done(cam, frame, &buf->vb_buf);
} }
...@@ -1545,7 +1538,9 @@ static int mcam_v4l_open(struct file *filp) ...@@ -1545,7 +1538,9 @@ static int mcam_v4l_open(struct file *filp)
filp->private_data = cam; filp->private_data = cam;
frames = singles = delivered = 0; cam->frame_state.frames = 0;
cam->frame_state.singles = 0;
cam->frame_state.delivered = 0;
mutex_lock(&cam->s_mutex); mutex_lock(&cam->s_mutex);
if (cam->users == 0) { if (cam->users == 0) {
ret = mcam_setup_vb2(cam); ret = mcam_setup_vb2(cam);
...@@ -1566,8 +1561,9 @@ static int mcam_v4l_release(struct file *filp) ...@@ -1566,8 +1561,9 @@ static int mcam_v4l_release(struct file *filp)
{ {
struct mcam_camera *cam = filp->private_data; struct mcam_camera *cam = filp->private_data;
cam_dbg(cam, "Release, %d frames, %d singles, %d delivered\n", frames, cam_dbg(cam, "Release, %d frames, %d singles, %d delivered\n",
singles, delivered); cam->frame_state.frames, cam->frame_state.singles,
cam->frame_state.delivered);
mutex_lock(&cam->s_mutex); mutex_lock(&cam->s_mutex);
(cam->users)--; (cam->users)--;
if (cam->users == 0) { if (cam->users == 0) {
...@@ -1660,7 +1656,7 @@ static void mcam_frame_complete(struct mcam_camera *cam, int frame) ...@@ -1660,7 +1656,7 @@ static void mcam_frame_complete(struct mcam_camera *cam, int frame)
clear_bit(CF_DMA_ACTIVE, &cam->flags); clear_bit(CF_DMA_ACTIVE, &cam->flags);
cam->next_buf = frame; cam->next_buf = frame;
cam->buf_seq[frame] = ++(cam->sequence); cam->buf_seq[frame] = ++(cam->sequence);
frames++; cam->frame_state.frames++;
/* /*
* "This should never happen" * "This should never happen"
*/ */
......
...@@ -73,6 +73,14 @@ static inline int mcam_buffer_mode_supported(enum mcam_buffer_mode mode) ...@@ -73,6 +73,14 @@ static inline int mcam_buffer_mode_supported(enum mcam_buffer_mode mode)
} }
} }
/*
* Basic frame states
*/
struct mcam_frame_state {
unsigned int frames;
unsigned int singles;
unsigned int delivered;
};
/* /*
* A description of one of our devices. * A description of one of our devices.
...@@ -108,6 +116,7 @@ struct mcam_camera { ...@@ -108,6 +116,7 @@ struct mcam_camera {
unsigned long flags; /* Buffer status, mainly (dev_lock) */ unsigned long flags; /* Buffer status, mainly (dev_lock) */
int users; /* How many open FDs */ int users; /* How many open FDs */
struct mcam_frame_state frame_state; /* Frame state counter */
/* /*
* Subsystem structures. * Subsystem structures.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment