diff options
author | hoony.yu <hoony.yu@samsung.com> | 2010-10-18 11:46:24 -0700 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-10-19 17:23:24 +0800 |
commit | c0bfc3e068c780211edbf681b72e942b91eb518d (patch) | |
tree | 6b6e46ae58acd3ce66a8edb99b084697aea7f50c /liboverlay | |
parent | 1048e819c1966ea06259d89d6e6ccdfc43481774 (diff) | |
download | device_samsung_crespo-c0bfc3e068c780211edbf681b72e942b91eb518d.zip device_samsung_crespo-c0bfc3e068c780211edbf681b72e942b91eb518d.tar.gz device_samsung_crespo-c0bfc3e068c780211edbf681b72e942b91eb518d.tar.bz2 |
S5PC11X: OVERLAY: Add H-FLIP and V-FLIP options
bug:3059865
pid:3374
Change-Id: I3a73d814a16ac2afa00ba56d6361a813042643be
Signed-off-by: hoony.yu <hoony.yu@samsung.com>
Diffstat (limited to 'liboverlay')
-rw-r--r-- | liboverlay/overlay.cpp | 39 | ||||
-rw-r--r-- | liboverlay/v4l2_utils.c | 34 | ||||
-rw-r--r-- | liboverlay/v4l2_utils.h | 1 |
3 files changed, 73 insertions, 1 deletions
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp index 033b1d4..2a3e8db 100644 --- a/liboverlay/overlay.cpp +++ b/liboverlay/overlay.cpp @@ -67,6 +67,7 @@ typedef struct uint32_t posW; uint32_t posH; uint32_t rotation; + uint32_t flip; uint32_t posX_org; uint32_t posY_org; @@ -587,6 +588,11 @@ static overlay_t* overlay_createOverlay(struct overlay_control_device_t *dev, goto error1; } + if (v4l2_overlay_set_flip(fd, 0)) { + LOGE("Failed defaulting flip\n"); + goto error1; + } + if (v4l2_overlay_set_rotation(fd, 0, 0)) { LOGE("Failed defaulting rotation\n"); goto error1; @@ -774,16 +780,37 @@ static int overlay_setParameter(struct overlay_control_device_t *dev, { case 0: stage->rotation = 0; + stage->flip = 0; break; case OVERLAY_TRANSFORM_ROT_90: stage->rotation = 90; + stage->flip = 0; break; case OVERLAY_TRANSFORM_ROT_180: stage->rotation = 180; + stage->flip = 0; break; case OVERLAY_TRANSFORM_ROT_270: stage->rotation = 270; + stage->flip = 0; + break; + case OVERLAY_TRANSFORM_FLIP_H: + stage->rotation = 0; + stage->flip = V4L2_CID_HFLIP; + break; + case OVERLAY_TRANSFORM_FLIP_V: + stage->rotation = 0; + stage->flip = V4L2_CID_VFLIP; + break; + case OVERLAY_TRANSFORM_ROT_90+OVERLAY_TRANSFORM_FLIP_H: + stage->rotation = 90; + stage->flip = V4L2_CID_HFLIP; break; + case OVERLAY_TRANSFORM_ROT_90+OVERLAY_TRANSFORM_FLIP_V: + stage->rotation = 90; + stage->flip = V4L2_CID_VFLIP; + break; + default: rc = -EINVAL; break; @@ -847,7 +874,8 @@ static int overlay_commit(struct overlay_control_device_t *dev, if (data->posX == stage->posX && data->posY == stage->posY && data->posW == stage->posW && data->posH == stage->posH && - data->rotation == stage->rotation) { + data->rotation == stage->rotation && + data->flip == stage->flip) { LOGI("Nothing to do!\n"); goto end; } @@ -861,6 +889,14 @@ static int overlay_commit(struct overlay_control_device_t *dev, if ((ret = disable_streaming_locked(shared, fd))) goto end; + if (stage->flip != data->flip) { + ret = v4l2_overlay_set_flip(fd, stage->flip); + if (ret) { + LOGE("Set Flip Failed!/%d\n", ret); + goto end; + } + } + if (stage->rotation != data->rotation) { ret = v4l2_overlay_set_rotation(fd, stage->rotation, 0); if (ret) { @@ -882,6 +918,7 @@ static int overlay_commit(struct overlay_control_device_t *dev, data->posW = stage->posW; data->posH = stage->posH; data->rotation = stage->rotation; + data->flip = stage->flip; ret = enable_streaming_locked(shared, fd); diff --git a/liboverlay/v4l2_utils.c b/liboverlay/v4l2_utils.c index a300742..5c4457b 100644 --- a/liboverlay/v4l2_utils.c +++ b/liboverlay/v4l2_utils.c @@ -455,6 +455,40 @@ int v4l2_overlay_get_crop(int fd, uint32_t *x, uint32_t *y, uint32_t *w, return ret; } +int v4l2_overlay_set_flip(int fd, int flip) +{ + LOG_FUNCTION_NAME + + int ret; + struct v4l2_control ctrl_v; + struct v4l2_control ctrl_h; + + switch (flip) { + case 0: + ctrl_v.value = 0; + ctrl_h.value = 0; + break; + case V4L2_CID_HFLIP: + ctrl_v.value = 0; + ctrl_h.value = 1; + break; + case V4L2_CID_VFLIP: + ctrl_v.value = 1; + ctrl_h.value = 0; + break; + default: + return -1; + } + + ctrl_v.id = V4L2_CID_VFLIP; + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl_v, "set vflip"); + if (ret) return ret; + + ctrl_h.id = V4L2_CID_HFLIP; + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl_h, "set hflip"); + return ret; +} + int v4l2_overlay_set_rotation(int fd, int degree, int step) { LOG_FUNCTION_NAME diff --git a/liboverlay/v4l2_utils.h b/liboverlay/v4l2_utils.h index b582a8b..42bb211 100644 --- a/liboverlay/v4l2_utils.h +++ b/liboverlay/v4l2_utils.h @@ -31,6 +31,7 @@ int v4l2_overlay_set_crop(int fd, uint32_t x, uint32_t y, uint32_t w, uint32_t h); int v4l2_overlay_get_crop(int fd, uint32_t *x, uint32_t *y, uint32_t *w, uint32_t *h); +int v4l2_overlay_set_flip(int fd, int degree); int v4l2_overlay_set_rotation(int fd, int degree, int step); int v4l2_overlay_set_colorkey(int fd, int enable, int colorkey); int v4l2_overlay_set_global_alpha(int fd, int enable, int alpha); |