Skip to content

Commit

Permalink
[media] dm644x: replace the obsolete preset API by the timings API
Browse files Browse the repository at this point in the history
This patch replaces the preset API by the timings API, and
appropriate changes in board file.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com>
Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com>
Acked-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Oct 5, 2012
1 parent 182b967 commit 3686408
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 140 deletions.
15 changes: 8 additions & 7 deletions arch/arm/mach-davinci/board-dm644x-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/phy.h>
#include <linux/clk.h>
#include <linux/videodev2.h>
#include <linux/v4l2-dv-timings.h>
#include <linux/export.h>

#include <media/tvp514x.h>
Expand Down Expand Up @@ -620,7 +621,7 @@ static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = {
{
.name = "ntsc",
.timings_type = VPBE_ENC_STD,
.timings = {V4L2_STD_525_60},
.std_id = V4L2_STD_525_60,
.interlaced = 1,
.xres = 720,
.yres = 480,
Expand All @@ -632,7 +633,7 @@ static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = {
{
.name = "pal",
.timings_type = VPBE_ENC_STD,
.timings = {V4L2_STD_625_50},
.std_id = V4L2_STD_625_50,
.interlaced = 1,
.xres = 720,
.yres = 576,
Expand All @@ -647,8 +648,8 @@ static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = {
static struct vpbe_enc_mode_info dm644xevm_enc_preset_timing[] = {
{
.name = "480p59_94",
.timings_type = VPBE_ENC_DV_PRESET,
.timings = {V4L2_DV_480P59_94},
.timings_type = VPBE_ENC_CUSTOM_TIMINGS,
.dv_timings = V4L2_DV_BT_CEA_720X480P59_94,
.interlaced = 0,
.xres = 720,
.yres = 480,
Expand All @@ -659,8 +660,8 @@ static struct vpbe_enc_mode_info dm644xevm_enc_preset_timing[] = {
},
{
.name = "576p50",
.timings_type = VPBE_ENC_DV_PRESET,
.timings = {V4L2_DV_576P50},
.timings_type = VPBE_ENC_CUSTOM_TIMINGS,
.dv_timings = V4L2_DV_BT_CEA_720X576P50,
.interlaced = 0,
.xres = 720,
.yres = 576,
Expand Down Expand Up @@ -698,7 +699,7 @@ static struct vpbe_output dm644xevm_vpbe_outputs[] = {
.index = 1,
.name = "Component",
.type = V4L2_OUTPUT_TYPE_ANALOG,
.capabilities = V4L2_OUT_CAP_PRESETS,
.capabilities = V4L2_OUT_CAP_CUSTOM_TIMINGS,
},
.subdev_name = VPBE_VENC_SUBDEV_NAME,
.default_mode = "480p59_94",
Expand Down
17 changes: 4 additions & 13 deletions arch/arm/mach-davinci/dm644x.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ static struct resource dm644x_venc_resources[] = {
#define DM644X_VPSS_DACCLKEN BIT(4)

static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
unsigned int mode)
unsigned int pclock)
{
int ret = 0;
u32 v = DM644X_VPSS_VENCLKEN;
Expand All @@ -711,27 +711,18 @@ static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
v |= DM644X_VPSS_DACCLKEN;
writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
break;
case VPBE_ENC_DV_PRESET:
switch (mode) {
case V4L2_DV_480P59_94:
case V4L2_DV_576P50:
case VPBE_ENC_CUSTOM_TIMINGS:
if (pclock <= 27000000) {
v |= DM644X_VPSS_MUXSEL_PLL2_MODE |
DM644X_VPSS_DACCLKEN;
writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
break;
case V4L2_DV_720P60:
case V4L2_DV_1080I60:
case V4L2_DV_1080P30:
} else {
/*
* For HD, use external clock source since
* HD requires higher clock rate
*/
v |= DM644X_VPSS_MUXSEL_VPBECLK_MODE;
writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
break;
default:
ret = -EINVAL;
break;
}
break;
default:
Expand Down
110 changes: 47 additions & 63 deletions drivers/media/platform/davinci/vpbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,6 @@ static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev,
return 0;
}

static int vpbe_get_dv_preset_info(struct vpbe_device *vpbe_dev,
unsigned int dv_preset)
{
struct vpbe_config *cfg = vpbe_dev->cfg;
struct vpbe_enc_mode_info var;
int curr_output = vpbe_dev->current_out_index;
int i;

for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) {
var = cfg->outputs[curr_output].modes[i];
if ((var.timings_type & VPBE_ENC_DV_PRESET) &&
(var.timings.dv_preset == dv_preset)) {
vpbe_dev->current_timings = var;
return 0;
}
}

return -EINVAL;
}

/* Get std by std id */
static int vpbe_get_std_info(struct vpbe_device *vpbe_dev,
v4l2_std_id std_id)
Expand All @@ -206,7 +186,7 @@ static int vpbe_get_std_info(struct vpbe_device *vpbe_dev,
for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) {
var = cfg->outputs[curr_output].modes[i];
if ((var.timings_type & VPBE_ENC_STD) &&
(var.timings.std_id & std_id)) {
(var.std_id & std_id)) {
vpbe_dev->current_timings = var;
return 0;
}
Expand Down Expand Up @@ -344,38 +324,42 @@ static unsigned int vpbe_get_output(struct vpbe_device *vpbe_dev)
}

/**
* vpbe_s_dv_preset - Set the given preset timings in the encoder
* vpbe_s_dv_timings - Set the given preset timings in the encoder
*
* Sets the preset if supported by the current encoder. Return the status.
* Sets the timings if supported by the current encoder. Return the status.
* 0 - success & -EINVAL on error
*/
static int vpbe_s_dv_preset(struct vpbe_device *vpbe_dev,
struct v4l2_dv_preset *dv_preset)
static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev,
struct v4l2_dv_timings *dv_timings)
{
struct vpbe_config *cfg = vpbe_dev->cfg;
int out_index = vpbe_dev->current_out_index;
struct vpbe_output *output = &cfg->outputs[out_index];
int sd_index = vpbe_dev->current_sd_index;
int ret;
int ret, i;


if (!(cfg->outputs[out_index].output.capabilities &
V4L2_OUT_CAP_PRESETS))
V4L2_OUT_CAP_CUSTOM_TIMINGS))
return -EINVAL;

ret = vpbe_get_dv_preset_info(vpbe_dev, dv_preset->preset);

if (ret)
return ret;

for (i = 0; i < output->num_modes; i++) {
if (output->modes[i].timings_type == VPBE_ENC_CUSTOM_TIMINGS &&
!memcmp(&output->modes[i].dv_timings,
dv_timings, sizeof(*dv_timings)))
break;
}
if (i >= output->num_modes)
return -EINVAL;
vpbe_dev->current_timings = output->modes[i];
mutex_lock(&vpbe_dev->lock);


ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video,
s_dv_preset, dv_preset);
s_dv_timings, dv_timings);
if (!ret && (vpbe_dev->amp != NULL)) {
/* Call amplifier subdevice */
ret = v4l2_subdev_call(vpbe_dev->amp, video,
s_dv_preset, dv_preset);
s_dv_timings, dv_timings);
}
/* set the lcd controller output for the given mode */
if (!ret) {
Expand All @@ -392,54 +376,53 @@ static int vpbe_s_dv_preset(struct vpbe_device *vpbe_dev,
}

/**
* vpbe_g_dv_preset - Get the preset in the current encoder
* vpbe_g_dv_timings - Get the timings in the current encoder
*
* Get the preset in the current encoder. Return the status. 0 - success
* Get the timings in the current encoder. Return the status. 0 - success
* -EINVAL on error
*/
static int vpbe_g_dv_preset(struct vpbe_device *vpbe_dev,
struct v4l2_dv_preset *dv_preset)
static int vpbe_g_dv_timings(struct vpbe_device *vpbe_dev,
struct v4l2_dv_timings *dv_timings)
{
if (vpbe_dev->current_timings.timings_type &
VPBE_ENC_DV_PRESET) {
dv_preset->preset = vpbe_dev->current_timings.timings.dv_preset;
VPBE_ENC_CUSTOM_TIMINGS) {
*dv_timings = vpbe_dev->current_timings.dv_timings;
return 0;
}

return -EINVAL;
}

/**
* vpbe_enum_dv_presets - Enumerate the dv presets in the current encoder
* vpbe_enum_dv_timings - Enumerate the dv timings in the current encoder
*
* Get the preset in the current encoder. Return the status. 0 - success
* Get the timings in the current encoder. Return the status. 0 - success
* -EINVAL on error
*/
static int vpbe_enum_dv_presets(struct vpbe_device *vpbe_dev,
struct v4l2_dv_enum_preset *preset_info)
static int vpbe_enum_dv_timings(struct vpbe_device *vpbe_dev,
struct v4l2_enum_dv_timings *timings)
{
struct vpbe_config *cfg = vpbe_dev->cfg;
int out_index = vpbe_dev->current_out_index;
struct vpbe_output *output = &cfg->outputs[out_index];
int j = 0;
int i;

if (!(output->output.capabilities & V4L2_OUT_CAP_PRESETS))
if (!(output->output.capabilities & V4L2_OUT_CAP_CUSTOM_TIMINGS))
return -EINVAL;

for (i = 0; i < output->num_modes; i++) {
if (output->modes[i].timings_type == VPBE_ENC_DV_PRESET) {
if (j == preset_info->index)
if (output->modes[i].timings_type == VPBE_ENC_CUSTOM_TIMINGS) {
if (j == timings->index)
break;
j++;
}
}

if (i == output->num_modes)
return -EINVAL;

return v4l_fill_dv_preset_info(output->modes[i].timings.dv_preset,
preset_info);
timings->timings = output->modes[i].dv_timings;
return 0;
}

/**
Expand Down Expand Up @@ -489,10 +472,10 @@ static int vpbe_s_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id)
*/
static int vpbe_g_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id)
{
struct vpbe_enc_mode_info cur_timings = vpbe_dev->current_timings;
struct vpbe_enc_mode_info *cur_timings = &vpbe_dev->current_timings;

if (cur_timings.timings_type & VPBE_ENC_STD) {
*std_id = cur_timings.timings.std_id;
if (cur_timings->timings_type & VPBE_ENC_STD) {
*std_id = cur_timings->std_id;
return 0;
}

Expand All @@ -511,7 +494,7 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
{
struct vpbe_enc_mode_info *preset_mode = NULL;
struct vpbe_config *cfg = vpbe_dev->cfg;
struct v4l2_dv_preset dv_preset;
struct v4l2_dv_timings dv_timings;
struct osd_state *osd_device;
int out_index = vpbe_dev->current_out_index;
int ret = 0;
Expand All @@ -530,11 +513,12 @@ static int vpbe_set_mode(struct vpbe_device *vpbe_dev,
*/
if (preset_mode->timings_type & VPBE_ENC_STD)
return vpbe_s_std(vpbe_dev,
&preset_mode->timings.std_id);
if (preset_mode->timings_type & VPBE_ENC_DV_PRESET) {
dv_preset.preset =
preset_mode->timings.dv_preset;
return vpbe_s_dv_preset(vpbe_dev, &dv_preset);
&preset_mode->std_id);
if (preset_mode->timings_type &
VPBE_ENC_CUSTOM_TIMINGS) {
dv_timings =
preset_mode->dv_timings;
return vpbe_s_dv_timings(vpbe_dev, &dv_timings);
}
}
}
Expand Down Expand Up @@ -810,9 +794,9 @@ static struct vpbe_device_ops vpbe_dev_ops = {
.enum_outputs = vpbe_enum_outputs,
.set_output = vpbe_set_output,
.get_output = vpbe_get_output,
.s_dv_preset = vpbe_s_dv_preset,
.g_dv_preset = vpbe_g_dv_preset,
.enum_dv_presets = vpbe_enum_dv_presets,
.s_dv_timings = vpbe_s_dv_timings,
.g_dv_timings = vpbe_g_dv_timings,
.enum_dv_timings = vpbe_enum_dv_timings,
.s_std = vpbe_s_std,
.g_std = vpbe_g_std,
.initialize = vpbe_initialize,
Expand Down
Loading

0 comments on commit 3686408

Please sign in to comment.