From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
Volokh Konstantin <volokh84@gmail.com>,
Pete Eberlein <pete@sensoray.com>,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [REVIEW PATCH 12/42] tw9903: add new tw9903 video decoder.
Date: Sun, 24 Mar 2013 12:29:32 -0300 [thread overview]
Message-ID: <20130324122932.67985498@redhat.com> (raw)
In-Reply-To: <70b46354264bfe964430d87cbe6619749c71e96d.1363000605.git.hans.verkuil@cisco.com>
Em Mon, 11 Mar 2013 12:45:50 +0100
Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> This based on the wis-tw9903.c driver that's part of the go7007 driver.
> It has been converted to a v4l subdev driver by Pete Eberlein, and I made
> additional cleanups.
>
> Based on work by: Pete Eberlein <pete@sensoray.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: Pete Eberlein <pete@sensoray.com>
> ---
> drivers/media/i2c/Kconfig | 10 ++
> drivers/media/i2c/Makefile | 1 +
> drivers/media/i2c/tw9903.c | 274 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 285 insertions(+)
> create mode 100644 drivers/media/i2c/tw9903.c
>
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 8000642..eb9ef55 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -301,6 +301,16 @@ config VIDEO_TVP7002
> To compile this driver as a module, choose M here: the
> module will be called tvp7002.
>
> +config VIDEO_TW9903
> + tristate "Techwell TW9903 video decoder"
> + depends on VIDEO_V4L2 && I2C
> + ---help---
> + Support for the Techwell 9903 multi-standard video decoder
> + with high quality down scaler.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called tw9903.
> +
> config VIDEO_VPX3220
> tristate "vpx3220a, vpx3216b & vpx3214c video decoders"
> depends on VIDEO_V4L2 && I2C
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index b1775b3..af8fb29 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_VIDEO_THS7303) += ths7303.o
> obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
> obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o
> obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o
> +obj-$(CONFIG_VIDEO_TW9903) += tw9903.o
> obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
> obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
> obj-$(CONFIG_VIDEO_M52790) += m52790.o
> diff --git a/drivers/media/i2c/tw9903.c b/drivers/media/i2c/tw9903.c
> new file mode 100644
> index 0000000..82626ea
> --- /dev/null
> +++ b/drivers/media/i2c/tw9903.c
> @@ -0,0 +1,274 @@
> +/*
> + * Copyright (C) 2005-2006 Micronas USA Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License (Version 2) as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software Foundation,
> + * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/i2c.h>
> +#include <linux/videodev2.h>
> +#include <linux/ioctl.h>
> +#include <media/v4l2-device.h>
> +#include <media/v4l2-ctrls.h>
> +#include <linux/slab.h>
> +
> +MODULE_DESCRIPTION("TW9903 I2C subdev driver");
> +MODULE_LICENSE("GPL v2");
> +
> +/*
> + * This driver is based on the wis-tw9903.c source that was in
> + * drivers/staging/media/go7007. That source had commented out code for
> + * saturation and scaling (neither seemed to work). If anyone ever gets
> + * hardware to test this driver, then that code might be useful to look at.
> + * You need to get the kernel sources of, say, kernel 3.8 where that
> + * wis-tw9903 driver is still present.
> + */
> +
> +struct tw9903 {
> + struct v4l2_subdev sd;
> + struct v4l2_ctrl_handler hdl;
> + v4l2_std_id norm;
> +};
> +
> +static inline struct tw9903 *to_state(struct v4l2_subdev *sd)
> +{
> + return container_of(sd, struct tw9903, sd);
> +}
> +
> +static const u8 initial_registers[] = {
> + 0x02, 0x44, /* input 1, composite */
> + 0x03, 0x92, /* correct digital format */
> + 0x04, 0x00,
> + 0x05, 0x80, /* or 0x00 for PAL */
> + 0x06, 0x40, /* second internal current reference */
> + 0x07, 0x02, /* window */
> + 0x08, 0x14, /* window */
> + 0x09, 0xf0, /* window */
> + 0x0a, 0x81, /* window */
> + 0x0b, 0xd0, /* window */
> + 0x0c, 0x8c,
> + 0x0d, 0x00, /* scaling */
> + 0x0e, 0x11, /* scaling */
> + 0x0f, 0x00, /* scaling */
> + 0x10, 0x00, /* brightness */
> + 0x11, 0x60, /* contrast */
> + 0x12, 0x01, /* sharpness */
> + 0x13, 0x7f, /* U gain */
> + 0x14, 0x5a, /* V gain */
> + 0x15, 0x00, /* hue */
> + 0x16, 0xc3, /* sharpness */
> + 0x18, 0x00,
> + 0x19, 0x58, /* vbi */
> + 0x1a, 0x80,
> + 0x1c, 0x0f, /* video norm */
> + 0x1d, 0x7f, /* video norm */
> + 0x20, 0xa0, /* clamping gain (working 0x50) */
> + 0x21, 0x22,
> + 0x22, 0xf0,
> + 0x23, 0xfe,
> + 0x24, 0x3c,
> + 0x25, 0x38,
> + 0x26, 0x44,
> + 0x27, 0x20,
> + 0x28, 0x00,
> + 0x29, 0x15,
> + 0x2a, 0xa0,
> + 0x2b, 0x44,
> + 0x2c, 0x37,
> + 0x2d, 0x00,
> + 0x2e, 0xa5, /* burst PLL control (working: a9) */
> + 0x2f, 0xe0, /* 0xea is blue test frame -- 0xe0 for normal */
> + 0x31, 0x00,
> + 0x33, 0x22,
> + 0x34, 0x11,
> + 0x35, 0x35,
> + 0x3b, 0x05,
> + 0x06, 0xc0, /* reset device */
> + 0x00, 0x00, /* Terminator (reg 0x00 is read-only) */
> +};
> +
> +static int write_reg(struct v4l2_subdev *sd, u8 reg, u8 value)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(sd);
> +
> + return i2c_smbus_write_byte_data(client, reg, value);
> +}
> +
> +static int write_regs(struct v4l2_subdev *sd, const u8 *regs)
> +{
> + int i;
> +
> + for (i = 0; regs[i] != 0x00; i += 2)
> + if (write_reg(sd, regs[i], regs[i + 1]) < 0)
> + return -1;
> + return 0;
> +}
> +
> +static int tw9903_s_video_routing(struct v4l2_subdev *sd, u32 input,
> + u32 output, u32 config)
> +{
> + write_reg(sd, 0x02, 0x40 | (input << 1));
> + return 0;
> +}
> +
> +static int tw9903_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
> +{
> + struct tw9903 *dec = to_state(sd);
> + bool is_60hz = norm & V4L2_STD_525_60;
> + u8 regs[] = {
> + 0x05, is_60hz ? 0x80 : 0x00,
> + 0x07, is_60hz ? 0x02 : 0x12,
> + 0x08, is_60hz ? 0x14 : 0x18,
> + 0x09, is_60hz ? 0xf0 : 0x20,
> + 0, 0,
> + };
The above is ugly, and probably is wasting space at the code
segment.
I'll apply it for now, but the better would be to change it to
2 const tables.
Cheers,
Mauro
next prev parent reply other threads:[~2013-03-24 15:29 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 11:45 [REVIEW PATCH 00/42] go7007: complete overhaul Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 01/42] v4l2-ctrls: eliminate lockdep false alarms for struct v4l2_ctrl_handler.lock Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 02/42] v4l2-core: add code to check for specific ops Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 03/42] v4l2-ioctl: check if an ioctl is valid Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 04/42] saa7115: add config flag to change the IDQ polarity Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 05/42] saa7115: improve querystd handling for the saa7115 Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 06/42] saa7115: add support for double-rate ASCLK Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 07/42] go7007: fix i2c_xfer return codes Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 08/42] tuner: add Sony BTF tuners Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 09/42] sony-btf-mpx: the MPX driver for the sony BTF PAL/SECAM tuner Hans Verkuil
2013-03-24 15:21 ` Mauro Carvalho Chehab
2013-03-25 8:52 ` Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 10/42] ov7640: add new ov7640 driver Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 11/42] uda1342: add new uda1342 audio codec driver Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 12/42] tw9903: add new tw9903 video decoder Hans Verkuil
2013-03-24 15:29 ` Mauro Carvalho Chehab [this message]
2013-03-24 16:06 ` Mauro Carvalho Chehab
2013-03-25 8:55 ` Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 13/42] tw2804: add support for the Techwell tw2804 Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 14/42] tw2804: modify ADC power control Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 15/42] go7007: i2c initialization changes for tw2804 Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 16/42] go7007: switch to standard tuner/i2c subdevs Hans Verkuil
2013-03-24 15:35 ` Mauro Carvalho Chehab
2013-03-11 11:45 ` [REVIEW PATCH 17/42] go7007: remove all wis* drivers Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 18/42] go7007: add audio input ioctls Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 19/42] s2250-loader: use usbv2_cypress_load_firmware Hans Verkuil
2013-03-24 15:39 ` Mauro Carvalho Chehab
2013-03-24 15:49 ` Antti Palosaari
2013-03-25 8:56 ` Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 20/42] go7007: go7007: add device_caps and bus_info support to querycap Hans Verkuil
2013-03-11 11:45 ` [REVIEW PATCH 21/42] go7007: remove current_norm Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 22/42] go7007: fix DMA related errors Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 23/42] go7007: remember boot firmware Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 24/42] go7007: fix unregister/disconnect handling Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 25/42] go7007: convert to the control framework and remove obsolete JPEGCOMP support Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 26/42] s2250: convert to the control framework Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 27/42] go7007: add prio and control event support Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 28/42] go7007: add log_status support Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 29/42] go7007: tuner/std related fixes Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 30/42] go7007: standardize MPEG handling support Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 31/42] go7007: simplify the PX-TV402U board ID handling Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 32/42] go7007: set up the saa7115 audio clock correctly Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 33/42] go7007: drop struct go7007_file Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 34/42] go7007: convert to core locking and vb2 Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 35/42] go7007: embed struct video_device Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 36/42] go7007: remove cropping functions Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 37/42] saa7134-go7007: add support for this combination Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 38/42] s2250: add comment describing the hardware Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 39/42] go7007-loader: renamed from s2250-loader Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 40/42] go7007-loader: add support for the other devices and move fw files Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 41/42] go7007: update the README Hans Verkuil
2013-03-11 11:46 ` [REVIEW PATCH 42/42] MAINTAINERS: add the go7007 driver Hans Verkuil
2013-03-11 11:50 ` [REVIEW PATCH 01/42] v4l2-ctrls: eliminate lockdep false alarms for struct v4l2_ctrl_handler.lock Hans Verkuil
2013-03-11 22:01 ` [REVIEW PATCH 00/42] go7007: complete overhaul Hans Verkuil
2013-03-12 14:37 ` Darrick Burch
2013-03-12 15:05 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130324122932.67985498@redhat.com \
--to=mchehab@redhat.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=pete@sensoray.com \
--cc=volokh84@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).