Skip to content

Commit

Permalink
[media] solo6x10: add control framework
Browse files Browse the repository at this point in the history
Note that the MOTION_THRESHOLD functionality has been temporarily reduced:
only the global threshold can be set, not the per-block. This will be
addressed in a later patch: controls are not the proper way to do this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 25, 2013
1 parent d9ebd62 commit c813bd3
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 329 deletions.
15 changes: 9 additions & 6 deletions drivers/staging/media/solo6x10/solo6x10.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include <media/videobuf-core.h>

#include "registers.h"
Expand Down Expand Up @@ -100,12 +101,12 @@
#define V4L2_BUF_FLAG_MOTION_ON 0x0400
#define V4L2_BUF_FLAG_MOTION_DETECTED 0x0800
#endif
#ifndef V4L2_CID_MOTION_ENABLE
#define PRIVATE_CIDS
#define V4L2_CID_MOTION_ENABLE (V4L2_CID_PRIVATE_BASE+0)
#define V4L2_CID_MOTION_THRESHOLD (V4L2_CID_PRIVATE_BASE+1)
#define V4L2_CID_MOTION_TRACE (V4L2_CID_PRIVATE_BASE+2)
#endif

#define SOLO_CID_CUSTOM_BASE (V4L2_CID_USER_BASE | 0xf000)
#define V4L2_CID_MOTION_ENABLE (SOLO_CID_CUSTOM_BASE+0)
#define V4L2_CID_MOTION_THRESHOLD (SOLO_CID_CUSTOM_BASE+1)
#define V4L2_CID_MOTION_TRACE (SOLO_CID_CUSTOM_BASE+2)
#define V4L2_CID_OSD_TEXT (SOLO_CID_CUSTOM_BASE+3)

enum SOLO_I2C_STATE {
IIC_STATE_IDLE,
Expand Down Expand Up @@ -137,6 +138,7 @@ struct solo_p2m_dev {
struct solo_enc_dev {
struct solo_dev *solo_dev;
/* V4L2 Items */
struct v4l2_ctrl_handler hdl;
struct video_device *vfd;
/* General accounting */
struct mutex enable_lock;
Expand Down Expand Up @@ -207,6 +209,7 @@ struct solo_dev {
unsigned int frame_blank;
u8 cur_disp_ch;
wait_queue_head_t disp_thread_wait;
struct v4l2_ctrl_handler disp_hdl;

/* V4L2 Encoder items */
struct solo_enc_dev *v4l2_enc[SOLO_MAX_CHANNELS];
Expand Down
12 changes: 8 additions & 4 deletions drivers/staging/media/solo6x10/tw28.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ u16 tw28_get_audio_status(struct solo_dev *solo_dev)
}
#endif

bool tw28_has_sharpness(struct solo_dev *solo_dev, u8 ch)
{
return is_tw286x(solo_dev, ch / 4);
}

int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch,
s32 val)
{
Expand All @@ -676,8 +681,6 @@ int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch,
switch (ctrl) {
case V4L2_CID_SHARPNESS:
/* Only 286x has sharpness */
if (val > 0x0f || val < 0)
return -ERANGE;
if (is_tw286x(solo_dev, chip_num)) {
u8 v = solo_i2c_readbyte(solo_dev, SOLO_I2C_TW,
TW_CHIP_OFFSET_ADDR(chip_num),
Expand All @@ -687,8 +690,9 @@ int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch,
solo_i2c_writebyte(solo_dev, SOLO_I2C_TW,
TW_CHIP_OFFSET_ADDR(chip_num),
TW286x_SHARPNESS(chip_num), v);
} else if (val != 0)
return -ERANGE;
} else {
return -EINVAL;
}
break;

case V4L2_CID_HUE:
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/media/solo6x10/tw28.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ int solo_tw28_init(struct solo_dev *solo_dev);

int tw28_set_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch, s32 val);
int tw28_get_ctrl_val(struct solo_dev *solo_dev, u32 ctrl, u8 ch, s32 *val);
bool tw28_has_sharpness(struct solo_dev *solo_dev, u8 ch);

u8 tw28_get_audio_gain(struct solo_dev *solo_dev, u8 ch);
void tw28_set_audio_gain(struct solo_dev *solo_dev, u8 ch, u8 val);
Expand Down
Loading

0 comments on commit c813bd3

Please sign in to comment.