Commit 076e834f authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] v4l: vsp1: Factorize frame size enumeration code

Most of the entities can't perform scaling and implement the same frame
size enumeration function. Factorize the code into a single
implementation.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent c431cbbb
...@@ -187,6 +187,58 @@ int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev, ...@@ -187,6 +187,58 @@ int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
return 0; return 0;
} }
/*
* vsp1_subdev_enum_frame_size - Subdev pad enum_frame_size handler
* @subdev: V4L2 subdevice
* @cfg: V4L2 subdev pad configuration
* @fse: Frame size enumeration
* @min_width: Minimum image width
* @min_height: Minimum image height
* @max_width: Maximum image width
* @max_height: Maximum image height
*
* This function implements the subdev enum_frame_size pad operation for
* entities that do not support scaling or cropping. It reports the given
* minimum and maximum frame width and height on the sink pad, and a fixed
* source pad size identical to the sink pad.
*/
int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_size_enum *fse,
unsigned int min_width, unsigned int min_height,
unsigned int max_width, unsigned int max_height)
{
struct vsp1_entity *entity = to_vsp1_entity(subdev);
struct v4l2_subdev_pad_config *config;
struct v4l2_mbus_framefmt *format;
config = vsp1_entity_get_pad_config(entity, cfg, fse->which);
if (!config)
return -EINVAL;
format = vsp1_entity_get_pad_format(entity, config, fse->pad);
if (fse->index || fse->code != format->code)
return -EINVAL;
if (fse->pad == 0) {
fse->min_width = min_width;
fse->max_width = max_width;
fse->min_height = min_height;
fse->max_height = max_height;
} else {
/* The size on the source pad are fixed and always identical to
* the size on the sink pad.
*/
fse->min_width = format->width;
fse->max_width = format->width;
fse->min_height = format->height;
fse->max_height = format->height;
}
return 0;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Media Operations * Media Operations
*/ */
......
...@@ -134,5 +134,10 @@ int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev, ...@@ -134,5 +134,10 @@ int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_mbus_code_enum *code, struct v4l2_subdev_mbus_code_enum *code,
const unsigned int *codes, unsigned int ncodes); const unsigned int *codes, unsigned int ncodes);
int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_size_enum *fse,
unsigned int min_w, unsigned int min_h,
unsigned int max_w, unsigned int max_h);
#endif /* __VSP1_ENTITY_H__ */ #endif /* __VSP1_ENTITY_H__ */
...@@ -59,35 +59,9 @@ static int hsit_enum_frame_size(struct v4l2_subdev *subdev, ...@@ -59,35 +59,9 @@ static int hsit_enum_frame_size(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_size_enum *fse) struct v4l2_subdev_frame_size_enum *fse)
{ {
struct vsp1_hsit *hsit = to_hsit(subdev); return vsp1_subdev_enum_frame_size(subdev, cfg, fse, HSIT_MIN_SIZE,
struct v4l2_subdev_pad_config *config; HSIT_MIN_SIZE, HSIT_MAX_SIZE,
struct v4l2_mbus_framefmt *format; HSIT_MAX_SIZE);
config = vsp1_entity_get_pad_config(&hsit->entity, cfg, fse->which);
if (!config)
return -EINVAL;
format = vsp1_entity_get_pad_format(&hsit->entity, config, fse->pad);
if (fse->index || fse->code != format->code)
return -EINVAL;
if (fse->pad == HSIT_PAD_SINK) {
fse->min_width = HSIT_MIN_SIZE;
fse->max_width = HSIT_MAX_SIZE;
fse->min_height = HSIT_MIN_SIZE;
fse->max_height = HSIT_MAX_SIZE;
} else {
/* The size on the source pad are fixed and always identical to
* the size on the sink pad.
*/
fse->min_width = format->width;
fse->max_width = format->width;
fse->min_height = format->height;
fse->max_height = format->height;
}
return 0;
} }
static int hsit_set_format(struct v4l2_subdev *subdev, static int hsit_set_format(struct v4l2_subdev *subdev,
......
...@@ -54,32 +54,9 @@ static int lif_enum_frame_size(struct v4l2_subdev *subdev, ...@@ -54,32 +54,9 @@ static int lif_enum_frame_size(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_size_enum *fse) struct v4l2_subdev_frame_size_enum *fse)
{ {
struct vsp1_lif *lif = to_lif(subdev); return vsp1_subdev_enum_frame_size(subdev, cfg, fse, LIF_MIN_SIZE,
struct v4l2_subdev_pad_config *config; LIF_MIN_SIZE, LIF_MAX_SIZE,
struct v4l2_mbus_framefmt *format; LIF_MAX_SIZE);
config = vsp1_entity_get_pad_config(&lif->entity, cfg, fse->which);
if (!config)
return -EINVAL;
format = vsp1_entity_get_pad_format(&lif->entity, config, LIF_PAD_SINK);
if (fse->index || fse->code != format->code)
return -EINVAL;
if (fse->pad == LIF_PAD_SINK) {
fse->min_width = LIF_MIN_SIZE;
fse->max_width = LIF_MAX_SIZE;
fse->min_height = LIF_MIN_SIZE;
fse->max_height = LIF_MAX_SIZE;
} else {
fse->min_width = format->width;
fse->max_width = format->width;
fse->min_height = format->height;
fse->max_height = format->height;
}
return 0;
} }
static int lif_set_format(struct v4l2_subdev *subdev, static int lif_set_format(struct v4l2_subdev *subdev,
......
...@@ -80,35 +80,9 @@ static int lut_enum_frame_size(struct v4l2_subdev *subdev, ...@@ -80,35 +80,9 @@ static int lut_enum_frame_size(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_frame_size_enum *fse) struct v4l2_subdev_frame_size_enum *fse)
{ {
struct vsp1_lut *lut = to_lut(subdev); return vsp1_subdev_enum_frame_size(subdev, cfg, fse, LUT_MIN_SIZE,
struct v4l2_subdev_pad_config *config; LUT_MIN_SIZE, LUT_MAX_SIZE,
struct v4l2_mbus_framefmt *format; LUT_MAX_SIZE);
config = vsp1_entity_get_pad_config(&lut->entity, cfg, fse->which);
if (!config)
return -EINVAL;
format = vsp1_entity_get_pad_format(&lut->entity, config, fse->pad);
if (fse->index || fse->code != format->code)
return -EINVAL;
if (fse->pad == LUT_PAD_SINK) {
fse->min_width = LUT_MIN_SIZE;
fse->max_width = LUT_MAX_SIZE;
fse->min_height = LUT_MIN_SIZE;
fse->max_height = LUT_MAX_SIZE;
} else {
/* The size on the source pad are fixed and always identical to
* the size on the sink pad.
*/
fse->min_width = format->width;
fse->max_width = format->width;
fse->min_height = format->height;
fse->max_height = format->height;
}
return 0;
} }
static int lut_set_format(struct v4l2_subdev *subdev, static int lut_set_format(struct v4l2_subdev *subdev,
......
...@@ -53,34 +53,10 @@ static int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev, ...@@ -53,34 +53,10 @@ static int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
struct v4l2_subdev_frame_size_enum *fse) struct v4l2_subdev_frame_size_enum *fse)
{ {
struct vsp1_rwpf *rwpf = to_rwpf(subdev); struct vsp1_rwpf *rwpf = to_rwpf(subdev);
struct v4l2_subdev_pad_config *config;
struct v4l2_mbus_framefmt *format;
config = vsp1_entity_get_pad_config(&rwpf->entity, cfg, fse->which);
if (!config)
return -EINVAL;
format = vsp1_entity_get_pad_format(&rwpf->entity, config, fse->pad);
if (fse->index || fse->code != format->code) return vsp1_subdev_enum_frame_size(subdev, cfg, fse, RWPF_MIN_WIDTH,
return -EINVAL; RWPF_MIN_HEIGHT, rwpf->max_width,
rwpf->max_height);
if (fse->pad == RWPF_PAD_SINK) {
fse->min_width = RWPF_MIN_WIDTH;
fse->max_width = rwpf->max_width;
fse->min_height = RWPF_MIN_HEIGHT;
fse->max_height = rwpf->max_height;
} else {
/* The size on the source pad are fixed and always identical to
* the size on the sink pad.
*/
fse->min_width = format->width;
fse->max_width = format->width;
fse->min_height = format->height;
fse->max_height = format->height;
}
return 0;
} }
static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
......
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