diff options
-rw-r--r-- | drivers/media/i2c/m5mols/m5mols.h | 9 | ||||
-rw-r--r-- | drivers/media/i2c/m5mols/m5mols_capture.c | 3 | ||||
-rw-r--r-- | drivers/media/i2c/m5mols/m5mols_core.c | 47 | ||||
-rw-r--r-- | drivers/media/i2c/m5mols/m5mols_reg.h | 1 |
4 files changed, 60 insertions, 0 deletions
diff --git a/drivers/media/i2c/m5mols/m5mols.h b/drivers/media/i2c/m5mols/m5mols.h index 86c815be348c..4ab8b370e665 100644 --- a/drivers/media/i2c/m5mols/m5mols.h +++ b/drivers/media/i2c/m5mols/m5mols.h | |||
@@ -19,6 +19,13 @@ | |||
19 | #include <media/v4l2-subdev.h> | 19 | #include <media/v4l2-subdev.h> |
20 | #include "m5mols_reg.h" | 20 | #include "m5mols_reg.h" |
21 | 21 | ||
22 | |||
23 | /* An amount of data transmitted in addition to the value | ||
24 | * determined by CAPP_JPEG_SIZE_MAX register. | ||
25 | */ | ||
26 | #define M5MOLS_JPEG_TAGS_SIZE 0x20000 | ||
27 | #define M5MOLS_MAIN_JPEG_SIZE_MAX (5 * SZ_1M) | ||
28 | |||
22 | extern int m5mols_debug; | 29 | extern int m5mols_debug; |
23 | 30 | ||
24 | enum m5mols_restype { | 31 | enum m5mols_restype { |
@@ -67,12 +74,14 @@ struct m5mols_exif { | |||
67 | /** | 74 | /** |
68 | * struct m5mols_capture - Structure for the capture capability | 75 | * struct m5mols_capture - Structure for the capture capability |
69 | * @exif: EXIF information | 76 | * @exif: EXIF information |
77 | * @buf_size: internal JPEG frame buffer size, in bytes | ||
70 | * @main: size in bytes of the main image | 78 | * @main: size in bytes of the main image |
71 | * @thumb: size in bytes of the thumb image, if it was accompanied | 79 | * @thumb: size in bytes of the thumb image, if it was accompanied |
72 | * @total: total size in bytes of the produced image | 80 | * @total: total size in bytes of the produced image |
73 | */ | 81 | */ |
74 | struct m5mols_capture { | 82 | struct m5mols_capture { |
75 | struct m5mols_exif exif; | 83 | struct m5mols_exif exif; |
84 | unsigned int buf_size; | ||
76 | u32 main; | 85 | u32 main; |
77 | u32 thumb; | 86 | u32 thumb; |
78 | u32 total; | 87 | u32 total; |
diff --git a/drivers/media/i2c/m5mols/m5mols_capture.c b/drivers/media/i2c/m5mols/m5mols_capture.c index cb243bd278ce..ab34ccedf31e 100644 --- a/drivers/media/i2c/m5mols/m5mols_capture.c +++ b/drivers/media/i2c/m5mols/m5mols_capture.c | |||
@@ -105,6 +105,7 @@ static int m5mols_capture_info(struct m5mols_info *info) | |||
105 | 105 | ||
106 | int m5mols_start_capture(struct m5mols_info *info) | 106 | int m5mols_start_capture(struct m5mols_info *info) |
107 | { | 107 | { |
108 | unsigned int framesize = info->cap.buf_size - M5MOLS_JPEG_TAGS_SIZE; | ||
108 | struct v4l2_subdev *sd = &info->sd; | 109 | struct v4l2_subdev *sd = &info->sd; |
109 | int ret; | 110 | int ret; |
110 | 111 | ||
@@ -121,6 +122,8 @@ int m5mols_start_capture(struct m5mols_info *info) | |||
121 | if (!ret) | 122 | if (!ret) |
122 | ret = m5mols_write(sd, CAPP_MAIN_IMAGE_SIZE, info->resolution); | 123 | ret = m5mols_write(sd, CAPP_MAIN_IMAGE_SIZE, info->resolution); |
123 | if (!ret) | 124 | if (!ret) |
125 | ret = m5mols_write(sd, CAPP_JPEG_SIZE_MAX, framesize); | ||
126 | if (!ret) | ||
124 | ret = m5mols_set_mode(info, REG_CAPTURE); | 127 | ret = m5mols_set_mode(info, REG_CAPTURE); |
125 | if (!ret) | 128 | if (!ret) |
126 | /* Wait until a frame is captured to ISP internal memory */ | 129 | /* Wait until a frame is captured to ISP internal memory */ |
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 2f490ef26c38..8131d651de9e 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c | |||
@@ -599,6 +599,51 @@ static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
599 | return ret; | 599 | return ret; |
600 | } | 600 | } |
601 | 601 | ||
602 | static int m5mols_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, | ||
603 | struct v4l2_mbus_frame_desc *fd) | ||
604 | { | ||
605 | struct m5mols_info *info = to_m5mols(sd); | ||
606 | |||
607 | if (pad != 0 || fd == NULL) | ||
608 | return -EINVAL; | ||
609 | |||
610 | mutex_lock(&info->lock); | ||
611 | /* | ||
612 | * .get_frame_desc is only used for compressed formats, | ||
613 | * thus we always return the capture frame parameters here. | ||
614 | */ | ||
615 | fd->entry[0].length = info->cap.buf_size; | ||
616 | fd->entry[0].pixelcode = info->ffmt[M5MOLS_RESTYPE_CAPTURE].code; | ||
617 | mutex_unlock(&info->lock); | ||
618 | |||
619 | fd->entry[0].flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX; | ||
620 | fd->num_entries = 1; | ||
621 | |||
622 | return 0; | ||
623 | } | ||
624 | |||
625 | static int m5mols_set_frame_desc(struct v4l2_subdev *sd, unsigned int pad, | ||
626 | struct v4l2_mbus_frame_desc *fd) | ||
627 | { | ||
628 | struct m5mols_info *info = to_m5mols(sd); | ||
629 | struct v4l2_mbus_framefmt *mf = &info->ffmt[M5MOLS_RESTYPE_CAPTURE]; | ||
630 | |||
631 | if (pad != 0 || fd == NULL) | ||
632 | return -EINVAL; | ||
633 | |||
634 | fd->entry[0].flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX; | ||
635 | fd->num_entries = 1; | ||
636 | fd->entry[0].length = clamp_t(u32, fd->entry[0].length, | ||
637 | mf->width * mf->height, | ||
638 | M5MOLS_MAIN_JPEG_SIZE_MAX); | ||
639 | mutex_lock(&info->lock); | ||
640 | info->cap.buf_size = fd->entry[0].length; | ||
641 | mutex_unlock(&info->lock); | ||
642 | |||
643 | return 0; | ||
644 | } | ||
645 | |||
646 | |||
602 | static int m5mols_enum_mbus_code(struct v4l2_subdev *sd, | 647 | static int m5mols_enum_mbus_code(struct v4l2_subdev *sd, |
603 | struct v4l2_subdev_fh *fh, | 648 | struct v4l2_subdev_fh *fh, |
604 | struct v4l2_subdev_mbus_code_enum *code) | 649 | struct v4l2_subdev_mbus_code_enum *code) |
@@ -615,6 +660,8 @@ static struct v4l2_subdev_pad_ops m5mols_pad_ops = { | |||
615 | .enum_mbus_code = m5mols_enum_mbus_code, | 660 | .enum_mbus_code = m5mols_enum_mbus_code, |
616 | .get_fmt = m5mols_get_fmt, | 661 | .get_fmt = m5mols_get_fmt, |
617 | .set_fmt = m5mols_set_fmt, | 662 | .set_fmt = m5mols_set_fmt, |
663 | .get_frame_desc = m5mols_get_frame_desc, | ||
664 | .set_frame_desc = m5mols_set_frame_desc, | ||
618 | }; | 665 | }; |
619 | 666 | ||
620 | /** | 667 | /** |
diff --git a/drivers/media/i2c/m5mols/m5mols_reg.h b/drivers/media/i2c/m5mols/m5mols_reg.h index 14d4be72aeff..58d8027508df 100644 --- a/drivers/media/i2c/m5mols/m5mols_reg.h +++ b/drivers/media/i2c/m5mols/m5mols_reg.h | |||
@@ -310,6 +310,7 @@ | |||
310 | #define REG_JPEG 0x10 | 310 | #define REG_JPEG 0x10 |
311 | 311 | ||
312 | #define CAPP_MAIN_IMAGE_SIZE I2C_REG(CAT_CAPT_PARM, 0x01, 1) | 312 | #define CAPP_MAIN_IMAGE_SIZE I2C_REG(CAT_CAPT_PARM, 0x01, 1) |
313 | #define CAPP_JPEG_SIZE_MAX I2C_REG(CAT_CAPT_PARM, 0x0f, 4) | ||
313 | #define CAPP_JPEG_RATIO I2C_REG(CAT_CAPT_PARM, 0x17, 1) | 314 | #define CAPP_JPEG_RATIO I2C_REG(CAT_CAPT_PARM, 0x17, 1) |
314 | 315 | ||
315 | #define CAPP_MCC_MODE I2C_REG(CAT_CAPT_PARM, 0x1d, 1) | 316 | #define CAPP_MCC_MODE I2C_REG(CAT_CAPT_PARM, 0x1d, 1) |