Skip to content

Commit

Permalink
[media] v4l: Unify selection flags
Browse files Browse the repository at this point in the history
Unify flags on the selection interfaces on V4L2 and V4L2 subdev. Flags are
very similar to targets in this case: there are more similarities than
differences between the two interfaces.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Sakari Ailus authored and Mauro Carvalho Chehab committed Jul 6, 2012
1 parent 64b9ce8 commit 563df3d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion drivers/media/video/omap3isp/ispccdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
* pad. If the KEEP_CONFIG flag is set, just return the current crop
* rectangle.
*/
if (sel->flags & V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG) {
if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) {
sel->r = *__ccdc_get_crop(ccdc, fh, sel->which);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/omap3isp/isppreview.c
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ static int preview_set_selection(struct v4l2_subdev *sd,
* pad. If the KEEP_CONFIG flag is set, just return the current crop
* rectangle.
*/
if (sel->flags & V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG) {
if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) {
sel->r = *__preview_get_crop(prev, fh, sel->which);
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/video/smiapp/smiapp-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

#include "smiapp.h"

#define SMIAPP_ALIGN_DIM(dim, flags) \
((flags) & V4L2_SUBDEV_SEL_FLAG_SIZE_GE \
? ALIGN((dim), 2) \
#define SMIAPP_ALIGN_DIM(dim, flags) \
((flags) & V4L2_SEL_FLAG_GE \
? ALIGN((dim), 2) \
: (dim) & ~1)

/*
Expand Down Expand Up @@ -1747,14 +1747,14 @@ static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w,
h &= ~1;
ask_h &= ~1;

if (flags & V4L2_SUBDEV_SEL_FLAG_SIZE_GE) {
if (flags & V4L2_SEL_FLAG_GE) {
if (w < ask_w)
val -= SCALING_GOODNESS;
if (h < ask_h)
val -= SCALING_GOODNESS;
}

if (flags & V4L2_SUBDEV_SEL_FLAG_SIZE_LE) {
if (flags & V4L2_SEL_FLAG_LE) {
if (w > ask_w)
val -= SCALING_GOODNESS;
if (h > ask_h)
Expand Down
20 changes: 17 additions & 3 deletions include/linux/v4l2-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#ifndef __V4L2_COMMON__
#define __V4L2_COMMON__

/* Selection target definitions */
/*
*
* Selection interface definitions
*
*/

/* Current cropping area */
#define V4L2_SEL_TGT_CROP 0x0000
Expand All @@ -46,12 +50,22 @@
/* Current composing area plus all padding pixels */
#define V4L2_SEL_TGT_COMPOSE_PADDED 0x0103

/* Backward compatibility definitions */
/* Backward compatibility target definitions --- to be removed. */
#define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP
#define V4L2_SEL_TGT_COMPOSE_ACTIVE V4L2_SEL_TGT_COMPOSE
#define V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL \
V4L2_SEL_TGT_CROP
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL \
V4L2_SEL_TGT_COMPOSE

#endif /* __V4L2_COMMON__ */
/* Selection flags */
#define V4L2_SEL_FLAG_GE (1 << 0)
#define V4L2_SEL_FLAG_LE (1 << 1)
#define V4L2_SEL_FLAG_KEEP_CONFIG (1 << 2)

/* Backward compatibility flag definitions --- to be removed. */
#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE
#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE
#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG

#endif /* __V4L2_COMMON__ */
6 changes: 1 addition & 5 deletions include/linux/v4l2-subdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,14 @@ struct v4l2_subdev_frame_interval_enum {
__u32 reserved[9];
};

#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE (1 << 0)
#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE (1 << 1)
#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG (1 << 2)

/**
* struct v4l2_subdev_selection - selection info
*
* @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
* @pad: pad number, as reported by the media API
* @target: Selection target, used to choose one of possible rectangles,
* defined in v4l2-common.h; V4L2_SEL_TGT_* .
* @flags: constraint flags
* @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
* @r: coordinates of the selection window
* @reserved: for future use, set to zero for now
*
Expand Down
6 changes: 1 addition & 5 deletions include/linux/videodev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,16 +761,12 @@ struct v4l2_crop {
struct v4l2_rect c;
};

/* Hints for adjustments of selection rectangle */
#define V4L2_SEL_FLAG_GE 0x00000001
#define V4L2_SEL_FLAG_LE 0x00000002

/**
* struct v4l2_selection - selection info
* @type: buffer type (do not use *_MPLANE types)
* @target: Selection target, used to choose one of possible rectangles;
* defined in v4l2-common.h; V4L2_SEL_TGT_* .
* @flags: constraints flags
* @flags: constraints flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
* @r: coordinates of selection window
* @reserved: for future use, rounds structure size to 64 bytes, set to zero
*
Expand Down

0 comments on commit 563df3d

Please sign in to comment.