Commit ab7ef224 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] m5mols: Implement .get_frame_desc subdev callback

.get_frame_desc can be used by host interface driver to query
properties of captured frames, e.g. required memory buffer size.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 14783d25
...@@ -19,6 +19,13 @@ ...@@ -19,6 +19,13 @@
#include <media/v4l2-subdev.h> #include <media/v4l2-subdev.h>
#include "m5mols_reg.h" #include "m5mols_reg.h"
/* An amount of data transmitted in addition to the value
* determined by CAPP_JPEG_SIZE_MAX register.
*/
#define M5MOLS_JPEG_TAGS_SIZE 0x20000
#define M5MOLS_MAIN_JPEG_SIZE_MAX (5 * SZ_1M)
extern int m5mols_debug; extern int m5mols_debug;
enum m5mols_restype { enum m5mols_restype {
...@@ -67,12 +74,14 @@ struct m5mols_exif { ...@@ -67,12 +74,14 @@ struct m5mols_exif {
/** /**
* struct m5mols_capture - Structure for the capture capability * struct m5mols_capture - Structure for the capture capability
* @exif: EXIF information * @exif: EXIF information
* @buf_size: internal JPEG frame buffer size, in bytes
* @main: size in bytes of the main image * @main: size in bytes of the main image
* @thumb: size in bytes of the thumb image, if it was accompanied * @thumb: size in bytes of the thumb image, if it was accompanied
* @total: total size in bytes of the produced image * @total: total size in bytes of the produced image
*/ */
struct m5mols_capture { struct m5mols_capture {
struct m5mols_exif exif; struct m5mols_exif exif;
unsigned int buf_size;
u32 main; u32 main;
u32 thumb; u32 thumb;
u32 total; u32 total;
......
...@@ -105,6 +105,7 @@ static int m5mols_capture_info(struct m5mols_info *info) ...@@ -105,6 +105,7 @@ static int m5mols_capture_info(struct m5mols_info *info)
int m5mols_start_capture(struct m5mols_info *info) int m5mols_start_capture(struct m5mols_info *info)
{ {
unsigned int framesize = info->cap.buf_size - M5MOLS_JPEG_TAGS_SIZE;
struct v4l2_subdev *sd = &info->sd; struct v4l2_subdev *sd = &info->sd;
int ret; int ret;
...@@ -120,6 +121,8 @@ int m5mols_start_capture(struct m5mols_info *info) ...@@ -120,6 +121,8 @@ int m5mols_start_capture(struct m5mols_info *info)
ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG); ret = m5mols_write(sd, CAPP_YUVOUT_MAIN, REG_JPEG);
if (!ret) if (!ret)
ret = m5mols_write(sd, CAPP_MAIN_IMAGE_SIZE, info->resolution); ret = m5mols_write(sd, CAPP_MAIN_IMAGE_SIZE, info->resolution);
if (!ret)
ret = m5mols_write(sd, CAPP_JPEG_SIZE_MAX, framesize);
if (!ret) if (!ret)
ret = m5mols_set_mode(info, REG_CAPTURE); ret = m5mols_set_mode(info, REG_CAPTURE);
if (!ret) if (!ret)
......
...@@ -599,6 +599,51 @@ static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, ...@@ -599,6 +599,51 @@ static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
return ret; return ret;
} }
static int m5mols_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
struct v4l2_mbus_frame_desc *fd)
{
struct m5mols_info *info = to_m5mols(sd);
if (pad != 0 || fd == NULL)
return -EINVAL;
mutex_lock(&info->lock);
/*
* .get_frame_desc is only used for compressed formats,
* thus we always return the capture frame parameters here.
*/
fd->entry[0].length = info->cap.buf_size;
fd->entry[0].pixelcode = info->ffmt[M5MOLS_RESTYPE_CAPTURE].code;
mutex_unlock(&info->lock);
fd->entry[0].flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX;
fd->num_entries = 1;
return 0;
}
static int m5mols_set_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
struct v4l2_mbus_frame_desc *fd)
{
struct m5mols_info *info = to_m5mols(sd);
struct v4l2_mbus_framefmt *mf = &info->ffmt[M5MOLS_RESTYPE_CAPTURE];
if (pad != 0 || fd == NULL)
return -EINVAL;
fd->entry[0].flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX;
fd->num_entries = 1;
fd->entry[0].length = clamp_t(u32, fd->entry[0].length,
mf->width * mf->height,
M5MOLS_MAIN_JPEG_SIZE_MAX);
mutex_lock(&info->lock);
info->cap.buf_size = fd->entry[0].length;
mutex_unlock(&info->lock);
return 0;
}
static int m5mols_enum_mbus_code(struct v4l2_subdev *sd, static int m5mols_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_fh *fh, struct v4l2_subdev_fh *fh,
struct v4l2_subdev_mbus_code_enum *code) struct v4l2_subdev_mbus_code_enum *code)
...@@ -615,6 +660,8 @@ static struct v4l2_subdev_pad_ops m5mols_pad_ops = { ...@@ -615,6 +660,8 @@ static struct v4l2_subdev_pad_ops m5mols_pad_ops = {
.enum_mbus_code = m5mols_enum_mbus_code, .enum_mbus_code = m5mols_enum_mbus_code,
.get_fmt = m5mols_get_fmt, .get_fmt = m5mols_get_fmt,
.set_fmt = m5mols_set_fmt, .set_fmt = m5mols_set_fmt,
.get_frame_desc = m5mols_get_frame_desc,
.set_frame_desc = m5mols_set_frame_desc,
}; };
/** /**
......
...@@ -310,6 +310,7 @@ ...@@ -310,6 +310,7 @@
#define REG_JPEG 0x10 #define REG_JPEG 0x10
#define CAPP_MAIN_IMAGE_SIZE I2C_REG(CAT_CAPT_PARM, 0x01, 1) #define CAPP_MAIN_IMAGE_SIZE I2C_REG(CAT_CAPT_PARM, 0x01, 1)
#define CAPP_JPEG_SIZE_MAX I2C_REG(CAT_CAPT_PARM, 0x0f, 4)
#define CAPP_JPEG_RATIO I2C_REG(CAT_CAPT_PARM, 0x17, 1) #define CAPP_JPEG_RATIO I2C_REG(CAT_CAPT_PARM, 0x17, 1)
#define CAPP_MCC_MODE I2C_REG(CAT_CAPT_PARM, 0x1d, 1) #define CAPP_MCC_MODE I2C_REG(CAT_CAPT_PARM, 0x1d, 1)
......
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