[media] atmel-isi: code cleanup
Ensure that ISI is clocked before starting sensor sub device. Remove un-needed type check in try_fmt(). Use clamp() macro for hardware capabilities. Fix wrong tabulation to space. Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
42654ebad0
commit
ec62c9a54c
@@ -37,8 +37,8 @@
|
|||||||
|
|
||||||
#include "atmel-isi.h"
|
#include "atmel-isi.h"
|
||||||
|
|
||||||
#define MAX_SUPPORT_WIDTH 2048
|
#define MAX_SUPPORT_WIDTH 2048U
|
||||||
#define MAX_SUPPORT_HEIGHT 2048
|
#define MAX_SUPPORT_HEIGHT 2048U
|
||||||
#define MIN_FRAME_RATE 15
|
#define MIN_FRAME_RATE 15
|
||||||
#define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE)
|
#define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE)
|
||||||
|
|
||||||
@@ -425,6 +425,8 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
|
|||||||
struct frame_buffer *buf, *node;
|
struct frame_buffer *buf, *node;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
pm_runtime_get_sync(isi->dev);
|
||||||
|
|
||||||
/* Enable stream on the sub device */
|
/* Enable stream on the sub device */
|
||||||
ret = v4l2_subdev_call(isi->entity.subdev, video, s_stream, 1);
|
ret = v4l2_subdev_call(isi->entity.subdev, video, s_stream, 1);
|
||||||
if (ret && ret != -ENOIOCTLCMD) {
|
if (ret && ret != -ENOIOCTLCMD) {
|
||||||
@@ -432,8 +434,6 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
|
|||||||
goto err_start_stream;
|
goto err_start_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_runtime_get_sync(isi->dev);
|
|
||||||
|
|
||||||
/* Reset ISI */
|
/* Reset ISI */
|
||||||
ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
|
ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -456,10 +456,11 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_reset:
|
err_reset:
|
||||||
pm_runtime_put(isi->dev);
|
|
||||||
v4l2_subdev_call(isi->entity.subdev, video, s_stream, 0);
|
v4l2_subdev_call(isi->entity.subdev, video, s_stream, 0);
|
||||||
|
|
||||||
err_start_stream:
|
err_start_stream:
|
||||||
|
pm_runtime_put(isi->dev);
|
||||||
|
|
||||||
spin_lock_irq(&isi->irqlock);
|
spin_lock_irq(&isi->irqlock);
|
||||||
isi->active = NULL;
|
isi->active = NULL;
|
||||||
/* Release all active buffers */
|
/* Release all active buffers */
|
||||||
@@ -567,20 +568,15 @@ static int isi_try_fmt(struct atmel_isi *isi, struct v4l2_format *f,
|
|||||||
};
|
};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
isi_fmt = find_format_by_fourcc(isi, pixfmt->pixelformat);
|
isi_fmt = find_format_by_fourcc(isi, pixfmt->pixelformat);
|
||||||
if (!isi_fmt) {
|
if (!isi_fmt) {
|
||||||
isi_fmt = isi->user_formats[isi->num_user_formats - 1];
|
isi_fmt = isi->user_formats[isi->num_user_formats - 1];
|
||||||
pixfmt->pixelformat = isi_fmt->fourcc;
|
pixfmt->pixelformat = isi_fmt->fourcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Limit to Atmel ISC hardware capabilities */
|
/* Limit to Atmel ISI hardware capabilities */
|
||||||
if (pixfmt->width > MAX_SUPPORT_WIDTH)
|
pixfmt->width = clamp(pixfmt->width, 0U, MAX_SUPPORT_WIDTH);
|
||||||
pixfmt->width = MAX_SUPPORT_WIDTH;
|
pixfmt->height = clamp(pixfmt->height, 0U, MAX_SUPPORT_HEIGHT);
|
||||||
if (pixfmt->height > MAX_SUPPORT_HEIGHT)
|
|
||||||
pixfmt->height = MAX_SUPPORT_HEIGHT;
|
|
||||||
|
|
||||||
v4l2_fill_mbus_format(&format.format, pixfmt, isi_fmt->mbus_code);
|
v4l2_fill_mbus_format(&format.format, pixfmt, isi_fmt->mbus_code);
|
||||||
ret = v4l2_subdev_call(isi->entity.subdev, pad, set_fmt,
|
ret = v4l2_subdev_call(isi->entity.subdev, pad, set_fmt,
|
||||||
|
Reference in New Issue
Block a user