Re: [PATCH v10 1/6] video: add display_timing and videomode

2012-11-16 Thread Steffen Trumtrar
Hi Grant,

On Thu, Nov 15, 2012 at 06:03:59PM +, Grant Likely wrote:
 On Thu, 15 Nov 2012 17:00:57 +0100, Laurent Pinchart 
 laurent.pinch...@ideasonboard.com wrote:
  Hi Grant,
  
  On Thursday 15 November 2012 15:47:53 Grant Likely wrote:
   On Thu, 15 Nov 2012 10:23:52 +0100, Steffen Trumtrar wrote:
Add display_timing structure and the according helper functions. This
allows the description of a display via its supported timing parameters.

Every timing parameter can be specified as a single value or a range
min typ max.

Also, add helper functions to convert from display timings to a generic
videomode structure. This videomode can then be converted to the
corresponding subsystem mode representation (e.g. fb_videomode).

Signed-off-by: Steffen Trumtrar s.trumt...@pengutronix.de
   
   Hmmm... here's my thoughts as an outside reviewer. Correct me if I'm
   making an incorrect assumption.
   
   It looks to me that the purpose of this entire series is to decode video
   timings from the device tree and (eventually) provide the data in the
   form 'struct videomode'. Correct?
   

For the time being it is straight from devicetree via struct videomode
to struct drm_display_mode or fb_videomode. Correct.

   If so, then it looks over engineered. Creating new infrastructure to
   allocate, maintain, and free a new 'struct display_timings' doesn't make
   any sense when it is an intermediary data format that will never be used
   by drivers.
   
   Can the DT parsing code instead return a table of struct videomode?
   

See below.

   But, wait... struct videomode is also a new structure. So it looks like
   this series creates two new intermediary data structures;
   display_timings and videomode. And at least as far as I can see in this
   series struct fb_videomode is the only user.

struct drm_display_mode is also a user in this series see 5/6 and 6/6.

  
  struct videomode is supposed to slowly replace the various video mode 
  structures we currently have in the kernel (struct drm_mode_modeinfo, 
  struct 
  fb_videomode and struct v4l2_bt_timings), at least where possible 
  (userspace 
  APIs can't be broken). This will make it possible to reuse code across the 
  DRM, FB and V4L2 subsystems, such as the EDID parser or HDMI encoder 
  drivers. 
  This rationale might not be clearly explained in the commit message, but 
  having a shared video mode structure is pretty important.


That.

 Okay that make sense. What about struct display_timings?
 

The reason for defining an intermediary step is because of the different things
that are described:
- struct display_timing describes the signal ranges a display supports
- struct display_timings describes all timing settings of a display
- struct videomode describes one single mode generated from that settings

It is possible to generate multiple struct videomodes from one
struct display_timing based on the circumstances. And that is a task for the
driver using the display_timing infos. This means drivers are supposed to use
struct display_timings if they need to generate a struct videomode from the
timing ranges of one entry.
This is just the first step in that direction.
I hope this makes the need for struct display_timings a little clearer.
The other solution would be the one Laurent suggested and pass multiple values
around. Which in my opinion doesn't make it better, more practical or cleaner.


Regards,
Steffen

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


How to get the DVB drivers to stop spamming my logs?

2012-11-16 Thread David Hagood
I have a MythTV box with 3 tuners: 2 USB and one PCI. One or more of the 
tuners' drivers keeps spamming syslog with the following (taken from the 
Logwatch summary):


lgdt330x: i2c_read_demod_bytes: addr 0x0e select 0x58 error (ret == 
-71) ...:  278497 Time(s)
lgdt330x: i2c_read_demod_bytes: addr 0x0e select 0x6e error (ret == 
-71) ...:  410252 Time(s)
lgdt330x: i2c_read_demod_bytes: addr 0x0e select 0x8b error (ret == 
-71) ...:  1278 Time(s)
lgdt330x: i2c_write_demod_bytes error (addr 02 - 00,  ...:  73945 
Time(s)
lgdt330x: i2c_write_demod_bytes error (addr 4c - 14,  ...:  1281 
Time(s)

xc2028 1-0061: Error on line 1294: -71 ...:  1234 Time(s)

Is there any way to get the drivers to stop spamming syslog, short of 
recompiling them with the error messages removed?


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] ARM: i.MX27: Add platform support for IRAM.

2012-11-16 Thread Sascha Hauer
On Mon, Nov 05, 2012 at 04:59:44PM +0100, Javier Martin wrote:
 Add support for IRAM to i.MX27 non-DT platforms using
 iram_init() function.
 
 Signed-off-by: Javier Martin javier.mar...@vista-silicon.com
 ---
  arch/arm/mach-imx/mm-imx27.c |3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
 index e7e24af..fd2416d 100644
 --- a/arch/arm/mach-imx/mm-imx27.c
 +++ b/arch/arm/mach-imx/mm-imx27.c
 @@ -27,6 +27,7 @@
  #include asm/pgtable.h
  #include asm/mach/map.h
  #include mach/iomux-v1.h
 +#include mach/iram.h
  
  /* MX27 memory map definition */
  static struct map_desc imx27_io_desc[] __initdata = {
 @@ -94,4 +95,6 @@ void __init imx27_soc_init(void)
   /* imx27 has the imx21 type audmux */
   platform_device_register_simple(imx21-audmux, 0, imx27_audmux_res,
   ARRAY_SIZE(imx27_audmux_res));
 + /* imx27 has an iram of 46080 bytes size */
 + iram_init(MX27_IRAM_BASE_ADDR, 46080);

For this rather Philipps sram allocater patches should be used. This
would also solve the problem that mach/iram.h cannot be accessed anymore
in current -next. Fabio already sent a patch addressing this, but I
think we should go for a proper fix rather than just moving iram.h
to include/linux/

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Barcelona Media Summit Report

2012-11-16 Thread Hans Verkuil
Hi all,

This is the report of the Barcelona Media Summit on November 8. For those who
were in attendence: please correct any mistakes I may have made.

My presentation for the 'Minimum Requirements for New Drivers' and the 'V4L2
Ambiguities' can be found here:

http://hverkuil.home.xs4all.nl/presentations/ambiguities2.odp

I'd appreciate it if other presentations shown during the meeting can be made
available as well.

Enjoy!

Hans

Merging Process
===

The morning was spent discussing the merging process. Basically the number of
patch submissions increased from 200 a month two years ago to 700 a month this
year. Mauro is unable to keep up with that flood and a solution needed to be
found.

Mauro explained the current merge process, and after that the floor was opened
for discussions.

One of the problems is that it can be difficult to categorize patches since
often they are just prefixed with [PATCH]. Depending on who mailed it that
might mean an urgent regression fix, a patch that's ready to be merged or a
patch that needs review. There is no reliable way of knowing that without
actually looking at the mail.

One thing that we want to improve is to make sure that the regular contributors
at least use well defined patch prefixes. That means that we need a standard
prefix for regression fixes that need to go into the current rcX kernel asap.
This will make it easy to recognize them. We also need a prefix for patches that
we want to have reviewed before a final git pull request is posted. Laurent will
look into extending patchwork to have such patches be marked as 'Under Review'
automatically.

There is a distinction between RFC patches and patches you consider final (i.e.
ready for merging), but want people to look at. RFC patches will typically need
more work, but you want people to check it out and make sure you are going in
the right direction. Review patches are what you consider the final version, but
you want to give people a final chance to comment on them before posting the 
pull
request.

We also want to improve the MAINTAINERS file: it must be complete (with the
exception of RC keymaps, where that doesn't make sense). When posting review
patches the reviewed-by/acked-by from the actual person mentioned in the
MAINTAINERS file is sufficient to get the patch merged. Obviously, if someone
not responsible for the driver in question has good technical arguments why
it's wrong, then that should be taken into account.

In addition, the current list of media driver maintainers in that file needs
to be validated: are all emails still current, and is everyone still willing
to maintain their driver?

New drivers also must come with a MAINTAINERS entry.

In other words, the MAINTAINERS file will become more important.

The final decision we made was to appoint submaintainers of parts of the media
subsystem. Those submaintainers will take over Mauro's job for those parts
that they are responsible for, and make periodic pull requests to Mauro to
pull in the patches they have collected.

The submaintainers will be:

- Mike Krufky: frontends/tuners/demodulators
In addition he'll be the reviewer for DVB core patches.
- Hans Verkuil: V4L2 drivers and video A/D and D/A subdev drivers (aka video
receivers and transmitters). In addition he'll be the reviewer for
V4L2 core patches.
- Laurent Pinchart: sensor subdev drivers
- Kamil Debski: codec (aka memory-to-memory) drivers
- Hans de Goede: non-UVC USB webcam drivers
- Guennadi Liakhovetski: soc-camera drivers

In addition, certain SoC vendors will remain responsible for their own drivers
(Samsung, TI) and will keep sending them straight to Mauro.

The first step is to get the MAINTAINERS file into shape and to improve
patchwork, after that we need to clearly document the new structure. Only
when that is done do the new submaintainers start their work.


Requirements for New V4L2 Drivers
=

The next topic was to document the requirements for new drivers.

For the staging tree we want drivers to compile at the time of submission.
That is all it should take to be accepted into staging.

For inclusion into the mainline kernel we require the following:

- Use struct v4l2_device for bridge drivers, use struct v4l2_subdev for
  sub-device drivers.
- Use the control framework for control handling.
- Use struct v4l2_fh if the driver supports events (implied by the use of
  controls) or priority handling.
- Use videobuf2 for buffer handling. Mike Krufky will look into extending
  vb2 to support DVB buffers.
- Must pass the v4l2-compliance tests.

This will be documented as well in 
Documentation/video4linux/SubmittingDrivers.txt.


V4L2 Ambiguities


In San Diego we discussed a lot of V4L2 ambiguities and how to resolve them,
but we didn't have time to go through all of them. We finished it in Barcelona.

- What to do if the colorspace is unknown? This happens with UVC webcams that
  

Re: How to get the DVB drivers to stop spamming my logs?

2012-11-16 Thread Mauro Carvalho Chehab

Em 16-11-2012 10:42, David Hagood escreveu:

I have a MythTV box with 3 tuners: 2 USB and one PCI. One or more of the 
tuners' drivers keeps spamming syslog with the following (taken from the 
Logwatch summary):

 lgdt330x: i2c_read_demod_bytes: addr 0x0e select 0x58 error (ret == -71) 
...:  278497 Time(s)
 lgdt330x: i2c_read_demod_bytes: addr 0x0e select 0x6e error (ret == -71) 
...:  410252 Time(s)
 lgdt330x: i2c_read_demod_bytes: addr 0x0e select 0x8b error (ret == -71) 
...:  1278 Time(s)
 lgdt330x: i2c_write_demod_bytes error (addr 02 - 00,  ...:  73945 Time(s)
 lgdt330x: i2c_write_demod_bytes error (addr 4c - 14,  ...:  1281 Time(s)
 xc2028 1-0061: Error on line 1294: -71 ...:  1234 Time(s)

Is there any way to get the drivers to stop spamming syslog, short of 
recompiling them with the error messages removed?


Error -71 is this one:

include/asm-generic/errno.h:#define   EPROTO  71  /* Protocol 
error */

It is generally due to some issue at USB level, like bad cabling
or bad contact.

Regards,
Mauro
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] [media] vivi: Teach it to tune FPS

2012-11-16 Thread Hans Verkuil
On Wed November 7 2012 12:30:01 Kirill Smelkov wrote:
 On Fri, Nov 02, 2012 at 03:42:21PM +0100, Hans Verkuil wrote:
  Thanks for the ping, I forgot about this patch...
 
 Thanks for feedback and for waiting. I'm here again...
 
 
  On Tue October 23 2012 15:35:21 Kirill Smelkov wrote:
   On Tue, Oct 23, 2012 at 08:40:04AM +0200, Hans Verkuil wrote:
On Mon October 22 2012 19:01:40 Kirill Smelkov wrote:
 On Mon, Oct 22, 2012 at 04:16:14PM +0200, Hans Verkuil wrote:
  On Mon October 22 2012 15:54:44 Kirill Smelkov wrote:
   I was testing my video-over-ethernet subsystem today, and vivi 
   seemed to
   be perfect video source for testing when one don't have lots of 
   capture
   boards and cameras. Only its framerate was hardcoded to NTSC's 
   30fps,
   while in my country we usually use PAL (25 fps). That's why the 
   patch.
   Thanks.
  
  Rather than introducing a module option, it's much nicer if you can
  implement enum_frameintervals and g/s_parm. This can be made quite 
  flexible
  allowing you to also support 50/59.94/60 fps.
 
 Thanks for feedback. I've reworked the patch for FPS to be set via
 -{g,s}_parm(), and yes now it is more flexble, because one can set
 different FPS on different vivi devices. Only I don't know V4L2 ioctls
 details well enough and various drivers do things differently. The 
 patch
 is below. Is it ok?

Close, but it's not quite there.

You should run the v4l2-compliance tool from the v4l-utils.git 
repository
(take the master branch). That will report any errors in your 
implementation.

In this case g/s_parm doesn't set readbuffers (set it to 1) and if 
timeperframe
equals { 0, 0 }, then you should get a nominal framerate (let's stick 
to 29.97
for that). I would set the nominal framerate whenever the denominator 
== 0.

For vidioc_enum_frameintervals you need to check the IN fields and fill 
in the
stepwise struct.
   
   Thanks for pointers and info about v4l2-compliance handy-tool. I've
   tried to correct all the issues you mentioned above and here is the
   patch.
   
   (Only requirement to set stepwise.step to 1.0 for
V4L2_FRMIVAL_TYPE_CONTINUOUS seems a bit illogical to me, but anyway,
that's what the V4L2 spec requires...)
   
   Thanks,
   Kirill
   
    8 
   From: Kirill Smelkov k...@mns.spb.ru
   Date: Tue, 23 Oct 2012 16:56:59 +0400
   Subject: [PATCH v3] [media] vivi: Teach it to tune FPS
   
   I was testing my video-over-ethernet subsystem yesterday, and vivi
   seemed to be perfect video source for testing when one don't have lots
   of capture boards and cameras. Only its framerate was hardcoded to
   NTSC's 30fps, while in my country we usually use PAL (25 fps) and I
   needed that to precisely simulate bandwidth.
   
   That's why here is this patch with -enum_frameintervals() and
   -{g,s}_parm() implemented as suggested by Hans Verkuil which passes
   v4l2-compliance and manual testing through v4l2-ctl -P / -p fps.
   
   Regarding newly introduced __get_format(u32 pixelformat) I decided not
   to convert original get_format() to operate on fourcc codes, since = 3
   places in driver need to deal with v4l2_format and otherwise it won't be
   handy.
   
   Thanks.
   
   Signed-off-by: Kirill Smelkov k...@mns.spb.ru
   ---
drivers/media/platform/vivi.c | 84 
   ++-
1 file changed, 75 insertions(+), 9 deletions(-)
   
   V3:
   - corrected issues with V4L2 spec compliance as pointed by Hans
 Verkuil.
   
   V2:
   
   - reworked FPS setting from module param to via -{g,s}_parm() as 
   suggested
 by Hans Verkuil.
   
   
   diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
   index 3e6902a..3adea58 100644
   --- a/drivers/media/platform/vivi.c
   +++ b/drivers/media/platform/vivi.c
   @@ -36,10 +36,6 @@

#define VIVI_MODULE_NAME vivi

   -/* Wake up at about 30 fps */
   -#define WAKE_NUMERATOR 30
   -#define WAKE_DENOMINATOR 1001
   -
#define MAX_WIDTH 1920
#define MAX_HEIGHT 1200

   @@ -69,6 +65,9 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
   megabytes);
/* Global font descriptor */
static const u8 *font8x16;

   +/* default to NTSC timeperframe */
   +static const struct v4l2_fract TPF_DEFAULT = {.numerator = 1001, 
   .denominator = 3};
  
  Keep the name lower case: tpf_default. Upper case is for defines only.
 
 ok
 
 [...]
 
   @@ -1049,6 +1054,63 @@ static int vidioc_s_input(struct file *file, void 
   *priv, unsigned int i)
 return 0;
}

   +/* timeperframe is arbitrary and continous */
   +static int vidioc_enum_frameintervals(struct file *file, void *priv,
   +  struct v4l2_frmivalenum *fival)
   +{
   + struct vivi_fmt *fmt;
   +
   + if (fival-index)
   +  

Re: [PATCH RFC v3 1/3] V4L: Add driver for S3C244X/S3C64XX SoC series camera interface

2012-11-16 Thread Hans Verkuil
Hi Sylwester,

Just one comment, see below...

On Thu November 15 2012 23:05:13 Sylwester Nawrocki wrote:
 This patch adds V4L2 driver for Samsung S3C244X/S3C64XX SoC series
 camera interface. The driver exposes a subdev device node for CAMIF
 pixel resolution and crop control and two video capture nodes - for
 the codec and preview data paths. It has been tested on Mini2440
 (s3c2440) and Mini6410 (s3c6410) board with gstreamer and mplayer.
 
 Signed-off-by: Sylwester Nawrocki sylvester.nawro...@gmail.com
 Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
 ---
  drivers/media/platform/Kconfig   |   12 +
  drivers/media/platform/Makefile  |1 +
  drivers/media/platform/s3c-camif/Makefile|5 +
  drivers/media/platform/s3c-camif/camif-capture.c | 1636 
 ++
  drivers/media/platform/s3c-camif/camif-core.c|  661 +
  drivers/media/platform/s3c-camif/camif-core.h|  382 +
  drivers/media/platform/s3c-camif/camif-regs.c|  579 
  drivers/media/platform/s3c-camif/camif-regs.h|  267 
  include/media/s3c_camif.h|   45 +
  9 files changed, 3588 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/platform/s3c-camif/Makefile
  create mode 100644 drivers/media/platform/s3c-camif/camif-capture.c
  create mode 100644 drivers/media/platform/s3c-camif/camif-core.c
  create mode 100644 drivers/media/platform/s3c-camif/camif-core.h
  create mode 100644 drivers/media/platform/s3c-camif/camif-regs.c
  create mode 100644 drivers/media/platform/s3c-camif/camif-regs.h
  create mode 100644 include/media/s3c_camif.h
 
 diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
 index 181c768..3dcfea6 100644
 --- a/drivers/media/platform/Kconfig
 +++ b/drivers/media/platform/Kconfig
 @@ -109,6 +109,18 @@ config VIDEO_OMAP3_DEBUG
   ---help---
 Enable debug messages on OMAP 3 camera controller driver.
  
 +config VIDEO_S3C_CAMIF
 + tristate Samsung S3C24XX/S3C64XX SoC Camera Interface driver
 + depends on VIDEO_V4L2  I2C  VIDEO_V4L2_SUBDEV_API
 + depends on (PLAT_S3C64XX || PLAT_S3C24XX)  PM_RUNTIME
 + select VIDEOBUF2_DMA_CONTIG
 + ---help---
 +   This is a v4l2 driver for s3c24xx and s3c64xx SoC series camera
 +   host interface (CAMIF).
 +
 +   To compile this driver as a module, choose M here: the module
 +   will be called s3c-camif.
 +
  source drivers/media/platform/soc_camera/Kconfig
  source drivers/media/platform/s5p-fimc/Kconfig
  source drivers/media/platform/s5p-tv/Kconfig
 diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
 index baaa550..4817d28 100644
 --- a/drivers/media/platform/Makefile
 +++ b/drivers/media/platform/Makefile
 @@ -27,6 +27,7 @@ obj-$(CONFIG_VIDEO_CODA)+= coda.o
  
  obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)  += m2m-deinterlace.o
  
 +obj-$(CONFIG_VIDEO_S3C_CAMIF)+= s3c-camif/
  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/
  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/
  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)  += s5p-mfc/
 diff --git a/drivers/media/platform/s3c-camif/Makefile 
 b/drivers/media/platform/s3c-camif/Makefile
 new file mode 100644
 index 000..50bf8c5
 --- /dev/null
 +++ b/drivers/media/platform/s3c-camif/Makefile
 @@ -0,0 +1,5 @@
 +# Makefile for s3c244x/s3c64xx CAMIF driver
 +
 +s3c-camif-objs := camif-core.o camif-capture.o camif-regs.o
 +
 +obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif.o
 diff --git a/drivers/media/platform/s3c-camif/camif-capture.c 
 b/drivers/media/platform/s3c-camif/camif-capture.c
 new file mode 100644
 index 000..8daf684
 --- /dev/null
 +++ b/drivers/media/platform/s3c-camif/camif-capture.c
 @@ -0,0 +1,1636 @@
 +/*
 + * s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
 + *
 + * Copyright (C) 2012 Sylwester Nawrocki sylvester.nawro...@gmail.com
 + * Copyright (C) 2012 Tomasz Figa tomasz.f...@gmail.com
 + *
 + * Based on drivers/media/platform/s5p-fimc,
 + * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
 + *
 + * 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.
 +*/
 +#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
 +
 +#include linux/bug.h
 +#include linux/clk.h
 +#include linux/device.h
 +#include linux/errno.h
 +#include linux/i2c.h
 +#include linux/interrupt.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/list.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/pm_runtime.h
 +#include linux/ratelimit.h
 +#include linux/slab.h
 +#include linux/types.h
 +#include linux/videodev2.h
 +
 +#include media/media-device.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-event.h
 +#include media/v4l2-ioctl.h
 +#include media/videobuf2-core.h
 +#include media/videobuf2-dma-contig.h
 +
 

Re: [PATCH 1/4] v4l: Define video buffer flags for timestamp types

2012-11-16 Thread Hans Verkuil
On Thu November 15 2012 23:06:44 Sakari Ailus wrote:
 Define video buffer flags for different timestamp types. Everything up to
 now have used either realtime clock or monotonic clock, without a way to
 tell which clock the timestamp was taken from.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  Documentation/DocBook/media/v4l/io.xml |   25 +
  include/uapi/linux/videodev2.h |4 
  2 files changed, 29 insertions(+), 0 deletions(-)
 
 diff --git a/Documentation/DocBook/media/v4l/io.xml 
 b/Documentation/DocBook/media/v4l/io.xml
 index 7e2f3d7..d598f2c 100644
 --- a/Documentation/DocBook/media/v4l/io.xml
 +++ b/Documentation/DocBook/media/v4l/io.xml
 @@ -938,6 +938,31 @@ Typically applications shall use this flag for output 
 buffers if the data
  in this buffer has not been created by the CPU but by some DMA-capable unit,
  in which case caches have not been used./entry
 /row
 +   row
 + entryconstantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant/entry
 + entry0xe000/entry
 + entryMask for timestamp types below. To test the
 + timestamp type, mask out bits not belonging to timestamp
 + type by performing a logical and operation with buffer
 + flags and timestamp mask./tt /entry
 +   /row
 +   row
 + entryconstantV4L2_BUF_FLAG_TIMESTAMP_UNKNOWN/constant/entry
 + entry0x/entry
 + entryUnknown timestamp type. This type is used by
 + drivers before Linux 3.8 and may be either monotonic (see
 + below) or realtime. Monotonic clock has been favoured in
 + embedded systems whereas most of the drivers use the
 + realtime clock./entry

Isn't 'wallclock time' a better expression? It is probably a good idea as well
to add the userspace call that gives the same clock: gettimeofday or
clock_gettime(CLOCK_REALTIME) for the wallclock time and 
clock_gettime(CLOCK_MONOTONIC)
for the monotonic time. That way apps can do the same call and compare it to the
timestamp received.

 +   /row
 +   row
 + 
 entryconstantV4L2_BUF_FLAG_TIMESTAMP_MONOTONIC/constant/entry
 + entry0x2000/entry
 + entryThe buffer timestamp has been taken from the
 + constantCLOCK_MONOTONIC/constant clock. To access the
 + same clock outside V4L2, use ttclock_gettime(2)/tt

Ah, you mentioned it here already for the monotonic clock :-)

 + ./entry
 +   /row
   /tbody
/tgroup
  /table
 diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
 index 2fff7ff..410ea9f 100644
 --- a/include/uapi/linux/videodev2.h
 +++ b/include/uapi/linux/videodev2.h
 @@ -686,6 +686,10 @@ struct v4l2_buffer {
  /* Cache handling flags */
  #define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE0x0800
  #define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000
 +/* Timestamp type */
 +#define V4L2_BUF_FLAG_TIMESTAMP_MASK 0xe000
 +#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN  0x
 +#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC0x2000
  
  /*
   *   O V E R L A Y   P R E V I E W
 

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] v4l: Helper function for obtaining timestamps

2012-11-16 Thread Hans Verkuil
On Thu November 15 2012 23:06:45 Sakari Ailus wrote:
 v4l2_get_timestamp() produces a monotonic timestamp but unlike
 ktime_get_ts(), it uses struct timeval instead of struct timespec, saving
 the drivers the conversion job when getting timestamps for v4l2_buffer's
 timestamp field.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 ---
  drivers/media/v4l2-core/v4l2-common.c |   10 ++
  include/media/v4l2-common.h   |2 ++
  2 files changed, 12 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/media/v4l2-core/v4l2-common.c 
 b/drivers/media/v4l2-core/v4l2-common.c
 index 380ddd8..614316f 100644
 --- a/drivers/media/v4l2-core/v4l2-common.c
 +++ b/drivers/media/v4l2-core/v4l2-common.c
 @@ -978,3 +978,13 @@ const struct v4l2_frmsize_discrete 
 *v4l2_find_nearest_format(
   return best;
  }
  EXPORT_SYMBOL_GPL(v4l2_find_nearest_format);
 +
 +void v4l2_get_timestamp(struct timeval *tv)
 +{
 + struct timespec ts;
 +
 + ktime_get_ts(ts);
 + tv-tv_sec = ts.tv_sec;
 + tv-tv_usec = ts.tv_nsec / NSEC_PER_USEC;
 +}
 +EXPORT_SYMBOL_GPL(v4l2_get_timestamp);
 diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
 index 1a0b2db..ec7c9c0 100644
 --- a/include/media/v4l2-common.h
 +++ b/include/media/v4l2-common.h
 @@ -225,4 +225,6 @@ bool v4l2_detect_gtf(unsigned frame_height, unsigned 
 hfreq, unsigned vsync,
  
  struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
  
 +void v4l2_get_timestamp(struct timeval *tv);
 +
  #endif /* V4L2_COMMON_H_ */
 

Acked-by: Hans Verkuil hans.verk...@cisco.com

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] v4l: Convert drivers to use monotonic timestamps

2012-11-16 Thread Hans Verkuil
On Thu November 15 2012 23:06:46 Sakari Ailus wrote:
 Convert drivers using wall clock time (CLOCK_REALTIME) to timestamp from the
 monotonic timer (CLOCK_MONOTONIC).
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi

Acked-by: Hans Verkuil hans.verk...@cisco.com

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] v4l: Tell user space we're using monotonic timestamps

2012-11-16 Thread Hans Verkuil
On Thu November 15 2012 23:06:47 Sakari Ailus wrote:
 Set buffer timestamp flags for videobuf, videobuf2 and drivers that use
 neither.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/media/pci/meye/meye.c |4 ++--
  drivers/media/pci/zoran/zoran_driver.c|2 +-
  drivers/media/platform/omap3isp/ispqueue.c|1 +
  drivers/media/platform/vino.c |3 +++
  drivers/media/usb/cpia2/cpia2_v4l.c   |5 -
  drivers/media/usb/sn9c102/sn9c102_core.c  |2 +-
  drivers/media/usb/stkwebcam/stk-webcam.c  |1 +
  drivers/media/usb/usbvision/usbvision-video.c |5 +++--
  drivers/media/v4l2-core/videobuf-core.c   |2 +-
  drivers/media/v4l2-core/videobuf2-core.c  |   10 ++
  10 files changed, 23 insertions(+), 12 deletions(-)
 
 diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
 index 288adea..ac7ab6e 100644
 --- a/drivers/media/pci/meye/meye.c
 +++ b/drivers/media/pci/meye/meye.c
 @@ -1426,7 +1426,7 @@ static int vidioc_querybuf(struct file *file, void *fh, 
 struct v4l2_buffer *buf)
   return -EINVAL;
  
   buf-bytesused = meye.grab_buffer[index].size;
 - buf-flags = V4L2_BUF_FLAG_MAPPED;
 + buf-flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
  
   if (meye.grab_buffer[index].state == MEYE_BUF_USING)
   buf-flags |= V4L2_BUF_FLAG_QUEUED;
 @@ -1499,7 +1499,7 @@ static int vidioc_dqbuf(struct file *file, void *fh, 
 struct v4l2_buffer *buf)
  
   buf-index = reqnr;
   buf-bytesused = meye.grab_buffer[reqnr].size;
 - buf-flags = V4L2_BUF_FLAG_MAPPED;
 + buf-flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
   buf-field = V4L2_FIELD_NONE;
   buf-timestamp = meye.grab_buffer[reqnr].timestamp;
   buf-sequence = meye.grab_buffer[reqnr].sequence;
 diff --git a/drivers/media/pci/zoran/zoran_driver.c 
 b/drivers/media/pci/zoran/zoran_driver.c
 index 53f12c7..33521a4 100644
 --- a/drivers/media/pci/zoran/zoran_driver.c
 +++ b/drivers/media/pci/zoran/zoran_driver.c
 @@ -1334,7 +1334,7 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
   struct zoran *zr = fh-zr;
   unsigned long flags;
  
 - buf-flags = V4L2_BUF_FLAG_MAPPED;
 + buf-flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
  
   switch (fh-map_mode) {
   case ZORAN_MAP_MODE_RAW:
 diff --git a/drivers/media/platform/omap3isp/ispqueue.c 
 b/drivers/media/platform/omap3isp/ispqueue.c
 index 15bf3ea..6599963 100644
 --- a/drivers/media/platform/omap3isp/ispqueue.c
 +++ b/drivers/media/platform/omap3isp/ispqueue.c
 @@ -674,6 +674,7 @@ static int isp_video_queue_alloc(struct isp_video_queue 
 *queue,
   buf-vbuf.index = i;
   buf-vbuf.length = size;
   buf-vbuf.type = queue-type;
 + buf-vbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
   buf-vbuf.field = V4L2_FIELD_NONE;
   buf-vbuf.memory = memory;
  
 diff --git a/drivers/media/platform/vino.c b/drivers/media/platform/vino.c
 index 28350e7..eb5d6f9 100644
 --- a/drivers/media/platform/vino.c
 +++ b/drivers/media/platform/vino.c
 @@ -3410,6 +3410,9 @@ static void vino_v4l2_get_buffer_status(struct 
 vino_channel_settings *vcs,
   if (fb-map_count  0)
   b-flags |= V4L2_BUF_FLAG_MAPPED;
  
 + b-flags = ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
 + b-flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 +
   b-index = fb-id;
   b-memory = (vcs-fb_queue.type == VINO_MEMORY_MMAP) ?
   V4L2_MEMORY_MMAP : V4L2_MEMORY_USERPTR;
 diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c 
 b/drivers/media/usb/cpia2/cpia2_v4l.c
 index aeb9d22..d5d42b6 100644
 --- a/drivers/media/usb/cpia2/cpia2_v4l.c
 +++ b/drivers/media/usb/cpia2/cpia2_v4l.c
 @@ -825,6 +825,8 @@ static int cpia2_querybuf(struct file *file, void *fh, 
 struct v4l2_buffer *buf)
   else
   buf-flags = 0;
  
 + buf-flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 +
   switch (cam-buffers[buf-index].status) {
   case FRAME_EMPTY:
   case FRAME_ERROR:
 @@ -943,7 +945,8 @@ static int cpia2_dqbuf(struct file *file, void *fh, 
 struct v4l2_buffer *buf)
  
   buf-index = frame;
   buf-bytesused = cam-buffers[buf-index].length;
 - buf-flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE;
 + buf-flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE
 + | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
   buf-field = V4L2_FIELD_NONE;
   buf-timestamp = cam-buffers[buf-index].timestamp;
   buf-sequence = cam-buffers[buf-index].seq;
 diff --git a/drivers/media/usb/sn9c102/sn9c102_core.c 
 b/drivers/media/usb/sn9c102/sn9c102_core.c
 index 843fadc..2e0e2ff 100644
 --- a/drivers/media/usb/sn9c102/sn9c102_core.c
 +++ b/drivers/media/usb/sn9c102/sn9c102_core.c
 @@ -173,7 +173,7 @@ 

Re: [PATCH 4/6] uvcvideo: Set device_caps in VIDIOC_QUERYCAP

2012-11-16 Thread Hans Verkuil
On Thu September 27 2012 17:16:18 Laurent Pinchart wrote:
 Set the capabilities field to global capabilities, and the device_caps
 field to the video node capabilities.
 
 This issue was found by the v4l2-compliance tool.
 
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/media/usb/uvc/uvc_driver.c |5 +
  drivers/media/usb/uvc/uvc_v4l2.c   |   10 ++
  drivers/media/usb/uvc/uvcvideo.h   |2 ++
  3 files changed, 13 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/media/usb/uvc/uvc_driver.c 
 b/drivers/media/usb/uvc/uvc_driver.c
 index 5967081..ae24f7d 100644
 --- a/drivers/media/usb/uvc/uvc_driver.c
 +++ b/drivers/media/usb/uvc/uvc_driver.c
 @@ -1741,6 +1741,11 @@ static int uvc_register_video(struct uvc_device *dev,
   return ret;
   }
  
 + if (stream-type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
 + stream-chain-caps |= V4L2_CAP_VIDEO_CAPTURE;
 + else
 + stream-chain-caps |= V4L2_CAP_VIDEO_OUTPUT;
 +
   atomic_inc(dev-nstreams);
   return 0;
  }
 diff --git a/drivers/media/usb/uvc/uvc_v4l2.c 
 b/drivers/media/usb/uvc/uvc_v4l2.c
 index 3bd9373..b1aa55f 100644
 --- a/drivers/media/usb/uvc/uvc_v4l2.c
 +++ b/drivers/media/usb/uvc/uvc_v4l2.c
 @@ -565,12 +565,14 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   usb_make_path(stream-dev-udev,
 cap-bus_info, sizeof(cap-bus_info));
   cap-version = LINUX_VERSION_CODE;
 + cap-capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
 +   | chain-caps;
   if (stream-type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
 - cap-capabilities = V4L2_CAP_VIDEO_CAPTURE
 -   | V4L2_CAP_STREAMING;
 + cap-device_caps = V4L2_CAP_VIDEO_CAPTURE
 +  | V4L2_CAP_STREAMING;
   else
 - cap-capabilities = V4L2_CAP_VIDEO_OUTPUT
 -   | V4L2_CAP_STREAMING;
 + cap-device_caps = V4L2_CAP_VIDEO_OUTPUT
 +  | V4L2_CAP_STREAMING;

This seems weird. Wouldn't it be easier to do:

cap-device_caps = chain-caps | V4L2_CAP_STREAMING;

You don't need the if/else here.

   break;
   }
  
 diff --git a/drivers/media/usb/uvc/uvcvideo.h 
 b/drivers/media/usb/uvc/uvcvideo.h
 index 7244455..28ff015 100644
 --- a/drivers/media/usb/uvc/uvcvideo.h
 +++ b/drivers/media/usb/uvc/uvcvideo.h
 @@ -371,6 +371,8 @@ struct uvc_video_chain {
   struct uvc_entity *selector;/* Selector unit */
  
   struct mutex ctrl_mutex;/* Protects ctrl.info */
 +
 + u32 caps;   /* V4L2 chain-wide caps */
  };
  
  struct uvc_stats_frame {
 

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/6] uvcvideo: Add VIDIOC_[GS]_PRIORITY support

2012-11-16 Thread Hans Verkuil
On Thu September 27 2012 17:16:20 Laurent Pinchart wrote:
 Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/media/usb/uvc/uvc_driver.c |3 ++
  drivers/media/usb/uvc/uvc_v4l2.c   |   45 
 
  drivers/media/usb/uvc/uvcvideo.h   |1 +
  3 files changed, 49 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/media/usb/uvc/uvc_driver.c 
 b/drivers/media/usb/uvc/uvc_driver.c
 index ae24f7d..22f14d2 100644
 --- a/drivers/media/usb/uvc/uvc_driver.c
 +++ b/drivers/media/usb/uvc/uvc_driver.c
 @@ -1562,6 +1562,7 @@ static int uvc_scan_device(struct uvc_device *dev)
   INIT_LIST_HEAD(chain-entities);
   mutex_init(chain-ctrl_mutex);
   chain-dev = dev;
 + v4l2_prio_init(chain-prio);
  
   if (uvc_scan_chain(chain, term)  0) {
   kfree(chain);
 @@ -1722,6 +1723,8 @@ static int uvc_register_video(struct uvc_device *dev,
   vdev-v4l2_dev = dev-vdev;
   vdev-fops = uvc_fops;
   vdev-release = uvc_release;
 + vdev-prio = stream-chain-prio;
 + set_bit(V4L2_FL_USE_FH_PRIO, vdev-flags);

This set_bit() doesn't do anything as long as you are not using video_ioctl2().
And why aren't you using video_ioctl2()? This is the last driver to do it all
manually. If you'd switch to video_ioctl2(), then setting this bit would be
all you had to do.

   if (stream-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
   vdev-vfl_dir = VFL_DIR_TX;
   strlcpy(vdev-name, dev-name, sizeof vdev-name);
 diff --git a/drivers/media/usb/uvc/uvc_v4l2.c 
 b/drivers/media/usb/uvc/uvc_v4l2.c
 index bf9d073..d6aa402 100644
 --- a/drivers/media/usb/uvc/uvc_v4l2.c
 +++ b/drivers/media/usb/uvc/uvc_v4l2.c
 @@ -576,6 +576,19 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   break;
   }
  
 + /* Priority */
 + case VIDIOC_G_PRIORITY:
 + *(u32 *)arg = v4l2_prio_max(vdev-prio);
 + break;
 +
 + case VIDIOC_S_PRIORITY:
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
 + return v4l2_prio_change(vdev-prio, handle-vfh.prio,
 + *(u32 *)arg);
 +
   /* Get, Set  Query control */
   case VIDIOC_QUERYCTRL:
   return uvc_query_v4l2_ctrl(chain, arg);
 @@ -606,6 +619,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   struct v4l2_control *ctrl = arg;
   struct v4l2_ext_control xctrl;
  
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
   memset(xctrl, 0, sizeof xctrl);
   xctrl.id = ctrl-id;
   xctrl.value = ctrl-value;
 @@ -653,6 +670,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   }
  
   case VIDIOC_S_EXT_CTRLS:
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
   case VIDIOC_TRY_EXT_CTRLS:
   {
   struct v4l2_ext_controls *ctrls = arg;
 @@ -747,6 +768,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   {
   u32 input = *(u32 *)arg + 1;
  
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
   if ((ret = uvc_acquire_privileges(handle))  0)
   return ret;
  
 @@ -800,6 +825,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   }
  
   case VIDIOC_S_FMT:
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
   if ((ret = uvc_acquire_privileges(handle))  0)
   return ret;
  
 @@ -902,6 +931,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   return uvc_v4l2_get_streamparm(stream, arg);
  
   case VIDIOC_S_PARM:
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
   if ((ret = uvc_acquire_privileges(handle))  0)
   return ret;
  
 @@ -936,6 +969,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
  
   /* Buffers  streaming */
   case VIDIOC_REQBUFS:
 + ret = v4l2_prio_check(vdev-prio, handle-vfh.prio);
 + if (ret  0)
 + return ret;
 +
   if ((ret = uvc_acquire_privileges(handle))  0)
   return ret;
  
 @@ -981,6 +1018,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, 
 unsigned int cmd, void *arg)
   if (*type != stream-type)
  

Re: [PATCH 0/6] uvcvideo: V4L2 compliance fixes

2012-11-16 Thread Hans Verkuil
Hi Laurent,

My apologies for the long delay before I got around to reviewing these.

On Thu September 27 2012 17:16:14 Laurent Pinchart wrote:
 Hi everybody,
 
 Here are 6 patches that fix V4L2 compliance issues in the uvcvideo driver 
 found
 by the v4l2-compliance tool.
 
 I'm working on the last remaining issue (control classes not implemented).
 
 Laurent Pinchart (6):
   uvcvideo: Set error_idx properly for extended controls API failures
   uvcvideo: Return -EACCES when trying to access a read/write-only
 control
   uvcvideo: Don't fail when an unsupported format is requested
   uvcvideo: Set device_caps in VIDIOC_QUERYCAP
   uvcvideo: Return -ENOTTY for unsupported ioctls
   uvcvideo: Add VIDIOC_[GS]_PRIORITY support
 
  drivers/media/usb/uvc/uvc_ctrl.c   |   21 +
  drivers/media/usb/uvc/uvc_driver.c |8 +++
  drivers/media/usb/uvc/uvc_v4l2.c   |   89 ---
  drivers/media/usb/uvc/uvc_video.c  |1 +
  drivers/media/usb/uvc/uvcvideo.h   |4 ++
  5 files changed, 96 insertions(+), 27 deletions(-)
 
 

For patches 1, 2, 3 and 5:

Acked-by: Hans Verkuil hans.verk...@cisco.com

I've got some comments for patches 4 and 6. See my reply to those.

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RFC v3 1/3] V4L: Add driver for S3C244X/S3C64XX SoC series camera interface

2012-11-16 Thread Alexey Klimov
Hi Sylwester,

 On Fri, Nov 16, 2012 at 2:05 AM, Sylwester Nawrocki
 sylvester.nawro...@gmail.com wrote:

 This patch adds V4L2 driver for Samsung S3C244X/S3C64XX SoC series
 camera interface. The driver exposes a subdev device node for CAMIF
 pixel resolution and crop control and two video capture nodes - for
 the codec and preview data paths. It has been tested on Mini2440
 (s3c2440) and Mini6410 (s3c6410) board with gstreamer and mplayer.

 Signed-off-by: Sylwester Nawrocki sylvester.nawro...@gmail.com
 Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
 ---
  drivers/media/platform/Kconfig   |   12 +
  drivers/media/platform/Makefile  |1 +
  drivers/media/platform/s3c-camif/Makefile|5 +
  drivers/media/platform/s3c-camif/camif-capture.c | 1636
 ++
  drivers/media/platform/s3c-camif/camif-core.c|  661 +
  drivers/media/platform/s3c-camif/camif-core.h|  382 +
  drivers/media/platform/s3c-camif/camif-regs.c|  579 
  drivers/media/platform/s3c-camif/camif-regs.h|  267 
  include/media/s3c_camif.h|   45 +
  9 files changed, 3588 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/platform/s3c-camif/Makefile
  create mode 100644 drivers/media/platform/s3c-camif/camif-capture.c
  create mode 100644 drivers/media/platform/s3c-camif/camif-core.c
  create mode 100644 drivers/media/platform/s3c-camif/camif-core.h
  create mode 100644 drivers/media/platform/s3c-camif/camif-regs.c
  create mode 100644 drivers/media/platform/s3c-camif/camif-regs.h
  create mode 100644 include/media/s3c_camif.h

 diff --git a/drivers/media/platform/Kconfig
 b/drivers/media/platform/Kconfig
 index 181c768..3dcfea6 100644
 --- a/drivers/media/platform/Kconfig
 +++ b/drivers/media/platform/Kconfig
 @@ -109,6 +109,18 @@ config VIDEO_OMAP3_DEBUG
 ---help---
   Enable debug messages on OMAP 3 camera controller driver.

 +config VIDEO_S3C_CAMIF
 +   tristate Samsung S3C24XX/S3C64XX SoC Camera Interface driver
 +   depends on VIDEO_V4L2  I2C  VIDEO_V4L2_SUBDEV_API
 +   depends on (PLAT_S3C64XX || PLAT_S3C24XX)  PM_RUNTIME
 +   select VIDEOBUF2_DMA_CONTIG
 +   ---help---
 + This is a v4l2 driver for s3c24xx and s3c64xx SoC series camera
 + host interface (CAMIF).
 +
 + To compile this driver as a module, choose M here: the module
 + will be called s3c-camif.
 +
  source drivers/media/platform/soc_camera/Kconfig
  source drivers/media/platform/s5p-fimc/Kconfig
  source drivers/media/platform/s5p-tv/Kconfig
 diff --git a/drivers/media/platform/Makefile
 b/drivers/media/platform/Makefile
 index baaa550..4817d28 100644
 --- a/drivers/media/platform/Makefile
 +++ b/drivers/media/platform/Makefile
 @@ -27,6 +27,7 @@ obj-$(CONFIG_VIDEO_CODA)  += coda.o

  obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)+= m2m-deinterlace.o

 +obj-$(CONFIG_VIDEO_S3C_CAMIF)  += s3c-camif/
  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC)   += s5p-fimc/
  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)   += s5p-jpeg/
  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)+= s5p-mfc/
 diff --git a/drivers/media/platform/s3c-camif/Makefile
 b/drivers/media/platform/s3c-camif/Makefile
 new file mode 100644
 index 000..50bf8c5
 --- /dev/null
 +++ b/drivers/media/platform/s3c-camif/Makefile
 @@ -0,0 +1,5 @@
 +# Makefile for s3c244x/s3c64xx CAMIF driver
 +
 +s3c-camif-objs := camif-core.o camif-capture.o camif-regs.o
 +
 +obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif.o
 diff --git a/drivers/media/platform/s3c-camif/camif-capture.c
 b/drivers/media/platform/s3c-camif/camif-capture.c
 new file mode 100644
 index 000..8daf684
 --- /dev/null
 +++ b/drivers/media/platform/s3c-camif/camif-capture.c
 @@ -0,0 +1,1636 @@
 +/*
 + * s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
 + *
 + * Copyright (C) 2012 Sylwester Nawrocki sylvester.nawro...@gmail.com
 + * Copyright (C) 2012 Tomasz Figa tomasz.f...@gmail.com
 + *
 + * Based on drivers/media/platform/s5p-fimc,
 + * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
 + *
 + * 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.
 +*/
 +#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
 +
 +#include linux/bug.h
 +#include linux/clk.h
 +#include linux/device.h
 +#include linux/errno.h
 +#include linux/i2c.h
 +#include linux/interrupt.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/list.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/pm_runtime.h
 +#include linux/ratelimit.h
 +#include linux/slab.h
 +#include linux/types.h
 +#include linux/videodev2.h
 +
 +#include media/media-device.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-event.h
 +#include media/v4l2-ioctl.h
 +#include media/videobuf2-core.h
 +#include 

Re: [PATCH v3 2/6] Add the main bulk of core driver for SI476x code

2012-11-16 Thread Hans Verkuil
Hi Andrey,

I'm really sorry for the long delay, but I finally have time to review v4 of 
this
code.

On Tue October 23 2012 20:44:28 Andrey Smirnov wrote:
 This patch adds main part(out of three) of the I2C driver for the
 core of MFD device.
 
 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/mfd/si476x-i2c.c |  966 
 ++
  1 file changed, 966 insertions(+)
  create mode 100644 drivers/mfd/si476x-i2c.c
 
 diff --git a/drivers/mfd/si476x-i2c.c b/drivers/mfd/si476x-i2c.c
 new file mode 100644
 index 000..6d581bd
 --- /dev/null
 +++ b/drivers/mfd/si476x-i2c.c
 @@ -0,0 +1,966 @@
 +/*
 + * include/media/si476x-i2c.c -- Core device driver for si476x MFD
 + * device
 + *
 + * Copyright (C) 2012 Innovative Converged Devices(ICD)
 + *
 + * Author: Andrey Smirnov andrey.smir...@convergeddevices.net
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; version 2 of the License.
 + *
 + * 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.
 + *
 + */
 +#include linux/module.h
 +
 +#include linux/slab.h
 +#include linux/interrupt.h
 +#include linux/delay.h
 +#include linux/gpio.h
 +#include linux/regulator/consumer.h
 +#include linux/i2c.h
 +#include linux/err.h
 +
 +#include linux/mfd/si476x-core.h
 +
 +/* Command Timeouts */
 +#define DEFAULT_TIMEOUT  10
 +#define TIMEOUT_TUNE 70
 +#define TIMEOUT_POWER_UP 33
 +
 +#define MAX_IO_ERRORS 10
 +
 +#define SI476X_DRIVER_RDS_FIFO_DEPTH 128
 +
 +#define SI476X_STATUS_POLL_US 0
 +
 +/**
 + * si476x_core_config_pinmux() - pin function configuration function
 + *
 + * @core: Core device structure
 + *
 + * Configure the functions of the pins of the radio chip.
 + *
 + * The function returns zero in case of succes or negative error code
 + * otherwise.
 + */
 +static int si476x_core_config_pinmux(struct si476x_core *core)
 +{
 + int err;
 + dev_dbg(core-client-dev, Configuring pinmux\n);
 + err = si476x_core_cmd_dig_audio_pin_cfg(core,
 + core-pinmux.dclk,
 + core-pinmux.dfs,
 + core-pinmux.dout,
 + core-pinmux.xout);
 + if (err  0) {
 + dev_err(core-client-dev,
 + Failed to configure digital audio pins(err = %d)\n,
 + err);
 + return err;
 + }
 +
 + err = si476x_core_cmd_zif_pin_cfg(core,
 +   core-pinmux.iqclk,
 +   core-pinmux.iqfs,
 +   core-pinmux.iout,
 +   core-pinmux.qout);
 + if (err  0) {
 + dev_err(core-client-dev,
 + Failed to configure ZIF pins(err = %d)\n,
 + err);
 + return err;
 + }
 +
 + err = si476x_core_cmd_ic_link_gpo_ctl_pin_cfg(core,
 +   core-pinmux.icin,
 +   core-pinmux.icip,
 +   core-pinmux.icon,
 +   core-pinmux.icop);
 + if (err  0) {
 + dev_err(core-client-dev,
 + Failed to configure IC-Link/GPO pins(err = %d)\n,
 + err);
 + return err;
 + }
 +
 + err = si476x_core_cmd_ana_audio_pin_cfg(core,
 + core-pinmux.lrout);
 + if (err  0) {
 + dev_err(core-client-dev,
 + Failed to configure analog audio pins(err = %d)\n,
 + err);
 + return err;
 + }
 +
 + err = si476x_core_cmd_intb_pin_cfg(core,
 +core-pinmux.intb,
 +core-pinmux.a1);
 + if (err  0) {
 + dev_err(core-client-dev,
 + Failed to configure interrupt pins(err = %d)\n,
 + err);
 + return err;
 + }
 +
 + return 0;
 +}
 +
 +static inline void si476x_core_schedule_polling_work(struct si476x_core 
 *core)
 +{
 + schedule_delayed_work(core-status_monitor,
 + usecs_to_jiffies(atomic_read(core-polling_interval)));
 +}
 +
 +/**
 + * si476x_core_start() - early chip startup function
 + * @core: Core device structure
 + * @soft: When set, this flag forces soft startup, where soft
 

[PATCH v2 00/12] Media Controller capture driver for DM365

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

This patch set adds media controller based capture driver for
DM365.

This driver bases its design on Laurent Pinchart's Media Controller Design
whose patches for Media Controller and subdev enhancements form the base.
The driver also takes copious elements taken from Laurent Pinchart and
others' OMAP ISP driver based on Media Controller. So thank you all the
people who are responsible for the Media Controller and the OMAP ISP driver.

Also, the core functionality of the driver comes from the arago vpfe capture
driver of which the isif capture was based on V4L2, with other drivers like
ipipe, ipipeif and Resizer.

Changes for v2:
1: Migrated the driver for videobuf2 usage pointed Hans.
2: Changed the design as pointed by Laurent, Exposed one more subdevs
   ipipeif and split the resizer subdev into three subdevs.
3: Rearrganed the patch sequence and changed the commit messages.
4: Changed the file architecture as pointed by Laurent.

Manjunath Hadli (12):
  davinci: vpfe: add v4l2 capture driver with media interface
  davinci: vpfe: add v4l2 video driver support
  davinci: vpfe: dm365: add IPIPEIF driver based on media framework
  davinci: vpfe: dm365: add ISIF driver based on media framework
  davinci: vpfe: dm365: add IPIPE support for media controller driver
  davinci: vpfe: dm365: add IPIPE hardware layer support
  davinci: vpfe: dm365: resizer driver based on media framework
  davinci: vpss: dm365: enable ISP registers
  davinci: vpss: dm365: set vpss clk ctrl
  davinci: vpss: dm365: add vpss helper functions to be used in the
main driver for setting hardware parameters
  davinci: vpfe: dm365: add build infrastructure for capture driver
  davinci: vpfe: Add documentation

 Documentation/video4linux/davinci-vpfe-mc.txt|  154 ++
 drivers/media/platform/davinci/Kconfig   |   11 +
 drivers/media/platform/davinci/Makefile  |3 +
 drivers/media/platform/davinci/dm365_ipipe.c | 1863 +++
 drivers/media/platform/davinci/dm365_ipipe.h |  179 ++
 drivers/media/platform/davinci/dm365_ipipe_hw.c  | 1048 +++
 drivers/media/platform/davinci/dm365_ipipe_hw.h  |  559 ++
 drivers/media/platform/davinci/dm365_ipipeif.c   | 1063 +++
 drivers/media/platform/davinci/dm365_ipipeif.h   |  233 +++
 drivers/media/platform/davinci/dm365_isif.c  | 2095 ++
 drivers/media/platform/davinci/dm365_isif.h  |  203 +++
 drivers/media/platform/davinci/dm365_isif_regs.h |  294 +++
 drivers/media/platform/davinci/dm365_resizer.c   | 1999 +
 drivers/media/platform/davinci/dm365_resizer.h   |  244 +++
 drivers/media/platform/davinci/vpfe_mc_capture.c |  741 
 drivers/media/platform/davinci/vpfe_mc_capture.h |   97 +
 drivers/media/platform/davinci/vpfe_video.c  | 1620 +
 drivers/media/platform/davinci/vpfe_video.h  |  155 ++
 drivers/media/platform/davinci/vpss.c|   59 +
 include/media/davinci/vpfe.h |   86 +
 include/media/davinci/vpss.h |   16 +
 include/uapi/linux/Kbuild|2 +
 include/uapi/linux/davinci_vpfe.h| 1285 +
 include/uapi/linux/dm365_ipipeif.h   |   93 +
 24 files changed, 14102 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/davinci-vpfe-mc.txt
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe.c
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe.h
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.c
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.h
 create mode 100644 drivers/media/platform/davinci/dm365_ipipeif.c
 create mode 100644 drivers/media/platform/davinci/dm365_ipipeif.h
 create mode 100644 drivers/media/platform/davinci/dm365_isif.c
 create mode 100644 drivers/media/platform/davinci/dm365_isif.h
 create mode 100644 drivers/media/platform/davinci/dm365_isif_regs.h
 create mode 100644 drivers/media/platform/davinci/dm365_resizer.c
 create mode 100644 drivers/media/platform/davinci/dm365_resizer.h
 create mode 100644 drivers/media/platform/davinci/vpfe_mc_capture.c
 create mode 100644 drivers/media/platform/davinci/vpfe_mc_capture.h
 create mode 100644 drivers/media/platform/davinci/vpfe_video.c
 create mode 100644 drivers/media/platform/davinci/vpfe_video.h
 create mode 100644 include/media/davinci/vpfe.h
 create mode 100644 include/uapi/linux/davinci_vpfe.h
 create mode 100644 include/uapi/linux/dm365_ipipeif.h

-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/12] davinci: vpss: dm365: set vpss clk ctrl

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

request_mem_region for VPSS_CLK_CTRL register and ioremap.
and enable clocks appropriately.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpss.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/vpss.c 
b/drivers/media/platform/davinci/vpss.c
index 34ad7bd..a36d694 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -103,6 +103,7 @@ struct vpss_hw_ops {
 struct vpss_oper_config {
__iomem void *vpss_regs_base0;
__iomem void *vpss_regs_base1;
+   resource_size_t *vpss_regs_base2;
enum vpss_platform_type platform;
spinlock_t vpss_lock;
struct vpss_hw_ops hw_ops;
@@ -484,11 +485,24 @@ static struct platform_driver vpss_driver = {
 
 static void vpss_exit(void)
 {
+   iounmap(oper_cfg.vpss_regs_base2);
+   release_mem_region(*oper_cfg.vpss_regs_base2, 4);
platform_driver_unregister(vpss_driver);
 }
 
+#define VPSS_CLK_CTRL  0x01c40044
+#define VPSS_CLK_CTRL_VENCCLKENBIT(3)
+#define VPSS_CLK_CTRL_DACCLKEN BIT(4)
+
 static int __init vpss_init(void)
 {
+   if (request_mem_region(VPSS_CLK_CTRL, 4, vpss_clock_control)) {
+   oper_cfg.vpss_regs_base2 = ioremap(VPSS_CLK_CTRL, 4);
+   __raw_writel(VPSS_CLK_CTRL_VENCCLKEN |
+VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2);
+   } else {
+   return -EBUSY;
+   }
return platform_driver_register(vpss_driver);
 }
 subsys_initcall(vpss_init);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/12] davinci: vpfe: Add documentation

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add documentation on the Davinci VPFE driver. Document the subdevs,
and private IOTCLs the driver implements.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
Cc: Rob Landley r...@landley.net
Cc: linux-...@vger.kernel.org
---
 Documentation/video4linux/davinci-vpfe-mc.txt |  154 +
 1 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/davinci-vpfe-mc.txt

diff --git a/Documentation/video4linux/davinci-vpfe-mc.txt 
b/Documentation/video4linux/davinci-vpfe-mc.txt
new file mode 100644
index 000..1dbd564
--- /dev/null
+++ b/Documentation/video4linux/davinci-vpfe-mc.txt
@@ -0,0 +1,154 @@
+Davinci Video processing Front End (VPFE) driver
+
+Copyright (C) 2012 Texas Instruments Inc
+
+Contacts: Manjunath Hadli manjunath.ha...@ti.com
+ Prabhakar Lad prabhakar@ti.com
+
+
+Introduction
+
+
+This file documents the Texas Instruments Davinci Video processing Front End
+(VPFE) driver located under drivers/media/platform/davinci. The original driver
+exists for Davinci VPFE, which is now being changed to Media Controller
+Framework.
+
+Currently the driver has been successfully used on the following
+version of Davinci:
+
+   DM365/DM368
+
+The driver implements V4L2, Media controller and v4l2_subdev interfaces. 
Sensor,
+lens and flash drivers using the v4l2_subdev interface in the kernel are
+supported.
+
+
+Split to subdevs
+
+
+The Davinci VPFE is split into V4L2 subdevs, each of the blocks inside the VPFE
+having one subdev to represent it. Each of the subdevs provide a V4L2 subdev
+interface to userspace.
+
+   DAVINCI ISIF
+   DAVINCI IPIPEIF
+   DAVINCI IPIPE
+   DAVINCI CROP RESIZER
+   DAVINCI RESIZER A
+   DAVINCI RESIZER B
+
+Each possible link in the VPFE is modeled by a link in the Media controller
+interface. For an example program see [1].
+
+
+ISIF, IPIPE, and RESIZER block IOCTLs
+==
+
+The Davinci Video processing Front End (VPFE) driver supports standard V4L2
+IOCTLs and controls where possible and practical. Much of the functions 
provided
+by the VPFE, however, does not fall under the standard IOCTL's.
+
+In general, there is a private ioctl for configuring each of the blocks
+containing hardware-dependent functions.
+
+The following private IOCTLs are supported:
+
+   VIDIOC_VPFE_ISIF_[S/G]_RAW_PARAMS
+   VIDIOC_VPFE_IPIPE_[S/G]_CONFIG
+   VIDIOC_VPFE_RSZ_[S/G]_CONFIG
+
+The parameter structures used by these ioctl's are described in
+include/uapi/linux/davinci_vpfe.h.
+
+The VIDIOC_VPFE_ISIF_S_RAW_PARAMS, VIDIOC_VPFE_IPIPE_S_CONFIG and
+VIDIOC_VPFE_RSZ_S_CONFIG are used to configure, enable and disable functions in
+the isif, ipipe and resizer blocks respectively. These IOCTL's control several
+functions in the blocks they control. VIDIOC_VPFE_ISIF_S_RAW_PARAMS IOCTL
+accepts a pointer to struct vpfe_isif_raw_config as its argument. Similarly
+VIDIOC_VPFE_IPIPE_S_CONFIG accepts a pointer to struct vpfe_ipipe_config. And
+VIDIOC_VPFE_RSZ_S_CONFIG accepts a pointer to struct vpfe_rsz_config as its
+argument. Similarly VIDIOC_VPFE_ISIF_G_RAW_PARAMS, VIDIOC_VPFE_IPIPE_G_CONFIG
+and VIDIOC_VPFE_RSZ_G_CONFIG are used to get the current configuration set in
+the isif, ipipe and resizer blocks respectively.
+
+The detailed functions of the VPFE itself related to a given VPFE block is
+described in the Technical Reference Manuals (TRMs) --- see the end of the
+document for those.
+
+
+IPIPEIF block IOCTLs
+==
+
+The following private IOCTLs are supported:
+
+   VIDIOC_VPFE_IPIPEIF_[S/G]_CONFIG
+
+The parameter structures used by these ioctl's are described in
+include/uapi/linux/dm365_ipipeif.h
+
+The VIDIOC_VPFE_IPIPEIF_S_CONFIG is used to configure the ipipeif
+hardware block. The VIDIOC_VPFE_IPIPEIF_S_CONFIG and
+VIDIOC_VPFE_IPIPEIF_G_CONFIG accepts a pointer to struct ipipeif_params
+as its argument.
+
+
+VPFE Operating Modes
+==
+
+a: Continuous Modes
+
+
+1: tvp514x/tvp7002/mt9p031--- DAVINCI ISIF--- SDRAM
+
+2: tvp514x/tvp7002/mt9p031--- DAVINCI ISIF--- DAVINCI IPIPEIF---|
+   |
+   |
+   |
+   V
+ DAVINCI CROP RESIZER---DAVINCI RESIZER [A/B]--- SDRAM
+
+3: tvp514x/tvp7002/mt9p031--- DAVINCI ISIF--- DAVINCI IPIPEIF---|
+   |
+   |
+   |
+   V
+ DAVINCI IPIPE--- DAVINCI CROP RESIZER---DAVINCI RESIZER [A/B]--- SDRAM
+
+a: Single Shot Modes
+
+
+1: SDRAM--- DAVINCI IPIPEIF--- DAVINCI IPIPE--- DAVINCI CROP RESIZER---|
+  

Re: [PATCH v5] [media] vivi: Teach it to tune FPS

2012-11-16 Thread Kirill Smelkov
On Fri, Nov 16, 2012 at 02:38:09PM +0100, Hans Verkuil wrote:
 On Wed November 7 2012 12:30:01 Kirill Smelkov wrote:
[...]

  diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
  index 37d0af8..5d1b374 100644
  --- a/drivers/media/platform/vivi.c
  +++ b/drivers/media/platform/vivi.c
  @@ -65,8 +65,11 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
  megabytes);
   /* Global font descriptor */
   static const u8 *font8x16;
   
  -/* default to NTSC timeperframe */
  -static const struct v4l2_fract TPF_DEFAULT = {.numerator = 1001, 
  .denominator = 3};
  +/* timeperframe: min/max and default */
  +static const struct v4l2_fract
  +   tpf_min = {.numerator = 1,  .denominator = UINT_MAX},  /* 
  1/infty */
  +   tpf_max = {.numerator = UINT_MAX,   .denominator = 1}, /* 
  infty */
 
 I understand your reasoning here, but I wouldn't go with UINT_MAX here. 
 Something like
 1/1000 tpf (or 1 ms) up to 86400/1 tpf (or once a day). With UINT_MAX I am 
 afraid we
 might hit application errors when they manipulate these values. The shortest 
 time
 between frames is 1 ms anyway.
 
 It's the only comment I have, it looks good otherwise.

Thanks, Let's then merge it with 1/1000 - 1000/1 limit. Ok?

Thanks again,
Kirill


 8 
From: Kirill Smelkov k...@mns.spb.ru
Date: Tue, 23 Oct 2012 16:56:59 +0400
Subject: [PATCH v5] [media] vivi: Teach it to tune FPS

I was testing my video-over-ethernet subsystem recently, and vivi
seemed to be perfect video source for testing when one don't have lots
of capture boards and cameras. Only its framerate was hardcoded to
NTSC's 30fps, while in my country we usually use PAL (25 fps) and I
needed that to precisely simulate bandwidth.

That's why here is this patch with -enum_frameintervals() and
-{g,s}_parm() implemented as suggested by Hans Verkuil which passes
v4l2-compliance and manual testing through v4l2-ctl -P / -p fps.

Regarding newly introduced __get_format(u32 pixelformat) I decided not
to convert original get_format() to operate on fourcc codes, since = 3
places in driver need to deal with v4l2_format and otherwise it won't be
handy.

Thanks.

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
---
 drivers/media/platform/vivi.c | 92 ++-
 1 file changed, 83 insertions(+), 9 deletions(-)

V5:
- changed  1/infty - infty/1  limits to  1/1000 - 1000/1, to avoid
  hitting aplication errors when they try to manipulato those
  values, as suggested by Hans Verkuil.

V4:
- corrected fival-stepwise setting and added its check to s_parm();
  also cosmetics - all as per Hans Verkuil review.

V3:
- corrected issues with V4L2 spec compliance as pointed by Hans
  Verkuil.

V2:

- reworked FPS setting from module param to via -{g,s}_parm() as suggested
  by Hans Verkuil.

diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 6e6dd25..793d7ee 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -36,10 +36,6 @@
 
 #define VIVI_MODULE_NAME vivi
 
-/* Wake up at about 30 fps */
-#define WAKE_NUMERATOR 30
-#define WAKE_DENOMINATOR 1001
-
 #define MAX_WIDTH 1920
 #define MAX_HEIGHT 1200
 
@@ -69,6 +65,12 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
megabytes);
 /* Global font descriptor */
 static const u8 *font8x16;
 
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+   tpf_min = {.numerator = 1,  .denominator = 1000},   /* 
~1/infty */
+   tpf_max = {.numerator = 1000,   .denominator = 1},  /* 
~infty */
+   tpf_default = {.numerator = 1001,   .denominator = 3};  /* NTSC 
*/
+
 #define dprintk(dev, level, fmt, arg...) \
v4l2_dbg(level, debug, dev-v4l2_dev, fmt, ## arg)
 
@@ -150,14 +152,14 @@ static struct vivi_fmt formats[] = {
},
 };
 
-static struct vivi_fmt *get_format(struct v4l2_format *f)
+static struct vivi_fmt *__get_format(u32 pixelformat)
 {
struct vivi_fmt *fmt;
unsigned int k;
 
for (k = 0; k  ARRAY_SIZE(formats); k++) {
fmt = formats[k];
-   if (fmt-fourcc == f-fmt.pix.pixelformat)
+   if (fmt-fourcc == pixelformat)
break;
}
 
@@ -167,6 +169,11 @@ static struct vivi_fmt *get_format(struct v4l2_format *f)
return formats[k];
 }
 
+static struct vivi_fmt *get_format(struct v4l2_format *f)
+{
+   return __get_format(f-fmt.pix.pixelformat);
+}
+
 /* buffer for one video frame */
 struct vivi_buffer {
/* common v4l buffer stuff -- must be first */
@@ -232,6 +239,7 @@ struct vivi_dev {
 
/* video capture */
struct vivi_fmt*fmt;
+   struct v4l2_fract  timeperframe;
unsigned int   width, height;
struct vb2_queue   vb_vidq;
unsigned int   field_count;
@@ -691,8 +699,8 @@ static void 

[PATCH v2 11/12] davinci: vpfe: dm365: add build infrastructure for capture driver

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add build infrastructure for dm365 specific modules for VPFE
capture driver.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/Kconfig  |   11 +++
 drivers/media/platform/davinci/Makefile |3 +++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/Kconfig 
b/drivers/media/platform/davinci/Kconfig
index 78e26d2..b52c642 100644
--- a/drivers/media/platform/davinci/Kconfig
+++ b/drivers/media/platform/davinci/Kconfig
@@ -119,3 +119,14 @@ config VIDEO_VPBE_DISPLAY
 
To compile this driver as a module, choose M here: the
module will be called vpbe_display.
+
+
+config VIDEO_DM365_VPFE_CAPTURE
+   tristate DM365 VPFE Media Controller Capture Driver
+   depends on VIDEO_V4L2  ARCH_DAVINCI_DM365  !VIDEO_VPFE_CAPTURE
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ Support for DM365 VPFE based Media Controller Capture driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called vpfe-mc-capture.
diff --git a/drivers/media/platform/davinci/Makefile 
b/drivers/media/platform/davinci/Makefile
index 74ed92d..8ca702e 100644
--- a/drivers/media/platform/davinci/Makefile
+++ b/drivers/media/platform/davinci/Makefile
@@ -18,3 +18,6 @@ obj-$(CONFIG_VIDEO_DM355_CCDC) += dm355_ccdc.o
 obj-$(CONFIG_VIDEO_ISIF) += isif.o
 obj-$(CONFIG_VIDEO_DM644X_VPBE) += vpbe.o vpbe_osd.o vpbe_venc.o
 obj-$(CONFIG_VIDEO_VPBE_DISPLAY) += vpbe_display.o
+obj-$(CONFIG_VIDEO_DM365_VPFE_CAPTURE) += \
+   dm365_isif.o dm365_ipipe_hw.o dm365_ipipe.o \
+   dm365_resizer.o dm365_ipipeif.o vpfe_mc_capture.o vpfe_video.o
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/12] davinci: vpfe: add v4l2 video driver support

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

Add a generic video driver functionality to be used by all the vpfe
drivers for davinci SoCs. The functionality includes all the
standard v4l2 interfaces including streaming. The video node
interface can be used both as an input and output node for both
continuous and single shot modes. Also supports dv_presets to include
HD modes, wth support for both user pointer IO and mmap. The buffering
mechanism is based on videobuf2 interface.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpfe_video.c | 1620 +++
 drivers/media/platform/davinci/vpfe_video.h |  155 +++
 2 files changed, 1775 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/vpfe_video.c
 create mode 100644 drivers/media/platform/davinci/vpfe_video.h

diff --git a/drivers/media/platform/davinci/vpfe_video.c 
b/drivers/media/platform/davinci/vpfe_video.c
new file mode 100644
index 000..6c57da0
--- /dev/null
+++ b/drivers/media/platform/davinci/vpfe_video.c
@@ -0,0 +1,1620 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * 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
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include linux/module.h
+#include linux/slab.h
+
+#include media/davinci/vpfe.h
+#include media/v4l2-ioctl.h
+
+#include vpfe_mc_capture.h
+
+/* minimum number of buffers needed in cont-mode */
+#define MIN_NUM_BUFFERS3
+
+static int debug;
+
+/* get v4l2 subdev pointer to external subdev which is active */
+static struct media_entity *vpfe_get_input_entity
+   (struct vpfe_video_device *video)
+{
+   struct vpfe_device *vpfe_dev = video-vpfe_dev;
+   struct media_pad *remote;
+
+   remote = media_entity_remote_source(vpfe_dev-vpfe_isif.pads[0]);
+   if (remote == NULL) {
+   pr_err(Invalid media connection to isif/ccdc\n);
+   return NULL;
+   }
+   return remote-entity;
+}
+
+/* updates external subdev(sensor/decoder) which is active */
+static int vpfe_update_current_ext_subdev(struct vpfe_video_device *video)
+{
+   struct vpfe_device *vpfe_dev = video-vpfe_dev;
+   struct vpfe_config *vpfe_cfg;
+   struct v4l2_subdev *subdev;
+   struct media_pad *remote;
+   int i;
+
+   remote = media_entity_remote_source(vpfe_dev-vpfe_isif.pads[0]);
+   if (remote == NULL) {
+   pr_err(Invalid media connection to isif/ccdc\n);
+   return -EINVAL;
+   }
+
+   subdev = media_entity_to_v4l2_subdev(remote-entity);
+   vpfe_cfg = vpfe_dev-pdev-platform_data;
+   for (i = 0; i  vpfe_cfg-num_subdevs; i++) {
+   if (!strcmp(vpfe_cfg-sub_devs[i].module_name, subdev-name)) {
+   video-current_ext_subdev = vpfe_cfg-sub_devs[i];
+   break;
+   }
+   }
+
+   /* if user not linked decoder/sensor to isif/ccdc */
+   if (i == vpfe_cfg-num_subdevs) {
+   pr_err(Invalid media chain connection to isif/ccdc\n);
+   return -EINVAL;
+   }
+   /* find the v4l2 subdev pointer */
+   for (i = 0; i  vpfe_dev-num_ext_subdevs; i++) {
+   if (!strcmp(video-current_ext_subdev-module_name,
+   vpfe_dev-sd[i]-name))
+   video-current_ext_subdev-subdev = vpfe_dev-sd[i];
+   }
+   return 0;
+}
+
+/* get the subdev which is connected to the output video node */
+static struct v4l2_subdev *
+vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad)
+{
+   struct media_pad *remote = media_entity_remote_source(video-pad);
+
+   if (remote == NULL || remote-entity-type != MEDIA_ENT_T_V4L2_SUBDEV)
+   return NULL;
+   if (pad)
+   *pad = remote-index;
+   return media_entity_to_v4l2_subdev(remote-entity);
+}
+
+/* get the format set at output pad of the adjacent subdev */
+static int
+__vpfe_video_get_format(struct vpfe_video_device *video,
+   struct v4l2_format *format)
+{
+   struct v4l2_subdev_format fmt;
+   struct v4l2_subdev *subdev;
+   struct media_pad *remote;
+   u32 pad;
+   int ret;
+
+   

[PATCH v2 03/12] davinci: vpfe: dm365: add IPIPEIF driver based on media framework

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add support for dm365 IPIPEIF driver based on media framework.
The IPIPEIF is exposed as a subdev, and it supports features
like fault pixel correction, dark frame subtraction and other
necessary hardware setup.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/dm365_ipipeif.c | 1063 
 drivers/media/platform/davinci/dm365_ipipeif.h |  233 ++
 include/uapi/linux/Kbuild  |1 +
 include/uapi/linux/dm365_ipipeif.h |   93 ++
 4 files changed, 1390 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/dm365_ipipeif.c
 create mode 100644 drivers/media/platform/davinci/dm365_ipipeif.h
 create mode 100644 include/uapi/linux/dm365_ipipeif.h

diff --git a/drivers/media/platform/davinci/dm365_ipipeif.c 
b/drivers/media/platform/davinci/dm365_ipipeif.c
new file mode 100644
index 000..a63ee58
--- /dev/null
+++ b/drivers/media/platform/davinci/dm365_ipipeif.c
@@ -0,0 +1,1063 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * 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
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include dm365_ipipeif.h
+#include vpfe_mc_capture.h
+
+static const unsigned int ipipeif_input_fmts[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+   V4L2_MBUS_FMT_SGRBG12_1X12,
+   V4L2_MBUS_FMT_Y8_1X8,
+   V4L2_MBUS_FMT_UV8_1X8,
+   V4L2_MBUS_FMT_YDYUYDYV8_1X16,
+   V4L2_MBUS_FMT_SBGGR8_1X8,
+};
+
+static const unsigned int ipipeif_output_fmts[] = {
+   V4L2_MBUS_FMT_UYVY8_2X8,
+   V4L2_MBUS_FMT_SGRBG12_1X12,
+   V4L2_MBUS_FMT_Y8_1X8,
+   V4L2_MBUS_FMT_UV8_1X8,
+   V4L2_MBUS_FMT_YDYUYDYV8_1X16,
+   V4L2_MBUS_FMT_SBGGR8_1X8,
+   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
+   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+};
+
+static int
+ipipeif_get_pack_mode(enum v4l2_mbus_pixelcode in_pix_fmt)
+{
+   switch (in_pix_fmt) {
+   case V4L2_MBUS_FMT_SBGGR8_1X8:
+   case V4L2_MBUS_FMT_Y8_1X8:
+   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
+   case V4L2_MBUS_FMT_UV8_1X8:
+   return IPIPEIF_5_1_PACK_8_BIT;
+
+   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
+   return IPIPEIF_5_1_PACK_8_BIT_A_LAW;
+
+   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   return IPIPEIF_5_1_PACK_16_BIT;
+
+   case V4L2_MBUS_FMT_SBGGR12_1X12:
+   return IPIPEIF_5_1_PACK_12_BIT;
+
+   default:
+   return IPIPEIF_5_1_PACK_16_BIT;
+   }
+}
+
+static inline u32 ipipeif_read(void *addr, u32 offset)
+{
+   return readl(addr + offset);
+}
+
+static inline void ipipeif_write(u32 val, void *addr, u32 offset)
+{
+   writel(val, addr + offset);
+}
+
+static void ipipeif_config_dpc(void *addr, struct ipipeif_dpc *dpc)
+{
+   u32 val = 0;
+
+   if (dpc-en) {
+   val = (dpc-en  1)  IPIPEIF_DPC2_EN_SHIFT;
+   val |= dpc-thr  IPIPEIF_DPC2_THR_MASK;
+   }
+   ipipeif_write(val, addr, IPIPEIF_DPC2);
+}
+
+#define IPIPEIF_MODE_CONTINUOUS0
+#define IPIPEIF_MODE_ONE_SHOT  1
+
+static int get_oneshot_mode(enum ipipeif_input_entity input)
+{
+   if (input == IPIPEIF_INPUT_MEMORY)
+   return IPIPEIF_MODE_ONE_SHOT;
+   else if (input == IPIPEIF_INPUT_ISIF)
+   return IPIPEIF_MODE_CONTINUOUS;
+
+   return -EINVAL;
+}
+
+static int
+ipipeif_get_cfg_src1(struct vpfe_ipipeif_device *ipipeif)
+{
+   struct v4l2_mbus_framefmt *informat;
+
+   informat = ipipeif-formats[IPIPEIF_PAD_SINK];
+   if (ipipeif-input == IPIPEIF_INPUT_MEMORY 
+  (informat-code == V4L2_MBUS_FMT_Y8_1X8 ||
+   informat-code == V4L2_MBUS_FMT_UV8_1X8))
+   return IPIPEIF_CCDC;
+
+   return IPIPEIF_SRC1_PARALLEL_PORT;
+}
+
+static int
+ipipeif_get_data_shift(struct vpfe_ipipeif_device *ipipeif)
+{
+   struct v4l2_mbus_framefmt *informat;
+
+   informat = ipipeif-formats[IPIPEIF_PAD_SINK];
+
+   switch (informat-code) {
+   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   return IPIPEIF_5_1_BITS11_0;
+
+   case V4L2_MBUS_FMT_Y8_1X8:
+   case V4L2_MBUS_FMT_UV8_1X8:
+   return 

[PATCH v2 06/12] davinci: vpfe: dm365: add IPIPE hardware layer support

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

IPIPE is the hardware IP which implements the functionality
required for resizer, ipipe(colorspace converter) and
the associated hardware support. This patch implements hardware
setup including coefficient programming for various hardware
filters, gamma, cfa and clock enabling.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/dm365_ipipe_hw.c | 1048 +++
 drivers/media/platform/davinci/dm365_ipipe_hw.h |  559 
 2 files changed, 1607 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.c
 create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.h

diff --git a/drivers/media/platform/davinci/dm365_ipipe_hw.c 
b/drivers/media/platform/davinci/dm365_ipipe_hw.c
new file mode 100644
index 000..e027b92
--- /dev/null
+++ b/drivers/media/platform/davinci/dm365_ipipe_hw.c
@@ -0,0 +1,1048 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * 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
+ *
+ * Contributors:
+ *  Manjunath Hadli manjunath.ha...@ti.com
+ *  Prabhakar Lad prabhakar@ti.com
+ */
+
+#include dm365_ipipe_hw.h
+
+#define IPIPE_MODE_CONTINUOUS  0
+#define IPIPE_MODE_SINGLE_SHOT 1
+
+static void ipipe_clock_enable(void *__iomem base_addr)
+{
+   /* enable IPIPE MMR for register write access */
+   regw_ip(base_addr, IPIPE_GCK_MMR_DEFAULT, IPIPE_GCK_MMR);
+
+   /* enable the clock wb,cfa,dfc,d2f,pre modules */
+   regw_ip(base_addr, IPIPE_GCK_PIX_DEFAULT, IPIPE_GCK_PIX);
+}
+
+static void
+rsz_set_common_params(void *__iomem rsz_base, struct resizer_params *params)
+{
+   struct rsz_common_params *rsz_common = params-rsz_common;
+   u32 val;
+
+   /* Set mode */
+   regw_rsz(rsz_base, params-oper_mode, RSZ_SRC_MODE);
+
+   /* data source selection  and bypass */
+   val = (rsz_common-passthrough  RSZ_BYPASS_SHIFT) |
+ rsz_common-source;
+   regw_rsz(rsz_base, val, RSZ_SRC_FMT0);
+
+   /* src image selection */
+   val = (rsz_common-raw_flip  1) |
+ (rsz_common-src_img_fmt  RSZ_SRC_IMG_FMT_SHIFT) |
+ ((rsz_common-y_c  1)  RSZ_SRC_Y_C_SEL_SHIFT);
+   regw_rsz(rsz_base, val, RSZ_SRC_FMT1);
+
+   regw_rsz(rsz_base, rsz_common-vps  IPIPE_RSZ_VPS_MASK, RSZ_SRC_VPS);
+   regw_rsz(rsz_base, rsz_common-hps  IPIPE_RSZ_HPS_MASK, RSZ_SRC_HPS);
+   regw_rsz(rsz_base, rsz_common-vsz  IPIPE_RSZ_VSZ_MASK, RSZ_SRC_VSZ);
+   regw_rsz(rsz_base, rsz_common-hsz  IPIPE_RSZ_HSZ_MASK, RSZ_SRC_HSZ);
+   regw_rsz(rsz_base, rsz_common-yuv_y_min, RSZ_YUV_Y_MIN);
+   regw_rsz(rsz_base, rsz_common-yuv_y_max, RSZ_YUV_Y_MAX);
+   regw_rsz(rsz_base, rsz_common-yuv_c_min, RSZ_YUV_C_MIN);
+   regw_rsz(rsz_base, rsz_common-yuv_c_max, RSZ_YUV_C_MAX);
+   /* chromatic position */
+   regw_rsz(rsz_base, rsz_common-out_chr_pos, RSZ_YUV_PHS);
+}
+
+static void
+rsz_set_rsz_regs(void *__iomem rsz_base, unsigned int rsz_id,
+struct resizer_params *params)
+{
+   struct resizer_scale_param *rsc_params;
+   struct rsz_ext_mem_param *ext_mem;
+   struct resizer_rgb *rgb;
+   u32 reg_base;
+   u32 val;
+
+   rsc_params = params-rsz_rsc_param[rsz_id];
+   rgb = params-rsz2rgb[rsz_id];
+   ext_mem = params-ext_mem_param[rsz_id];
+
+   if (rsz_id == RSZ_A) {
+   val = rsc_params-h_flip  RSZA_H_FLIP_SHIFT;
+   val |= rsc_params-v_flip  RSZA_V_FLIP_SHIFT;
+   reg_base = RSZ_EN_A;
+   } else {
+   val = rsc_params-h_flip  RSZB_H_FLIP_SHIFT;
+   val |= rsc_params-v_flip  RSZB_V_FLIP_SHIFT;
+   reg_base = RSZ_EN_B;
+   }
+   /* update flip settings */
+   regw_rsz(rsz_base, val, RSZ_SEQ);
+
+   regw_rsz(rsz_base, params-oper_mode, reg_base + RSZ_MODE);
+
+   val = (rsc_params-cen  RSZ_CEN_SHIFT) | rsc_params-yen;
+   regw_rsz(rsz_base, val, reg_base + RSZ_420);
+
+   regw_rsz(rsz_base, rsc_params-i_vps  RSZ_VPS_MASK,
+reg_base + RSZ_I_VPS);
+   regw_rsz(rsz_base, rsc_params-i_hps  RSZ_HPS_MASK,
+reg_base + RSZ_I_HPS);
+   regw_rsz(rsz_base, rsc_params-o_vsz  RSZ_O_VSZ_MASK,
+

[PATCH v2 08/12] davinci: vpss: dm365: enable ISP registers

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

enable PPCR, enbale ISIF out on BCR and disable all events to
get the correct operation from ISIF.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpss.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/vpss.c 
b/drivers/media/platform/davinci/vpss.c
index 146e4b0..34ad7bd 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -52,9 +52,11 @@ MODULE_AUTHOR(Texas Instruments);
 #define DM355_VPSSBL_EVTSEL_DEFAULT0x4
 
 #define DM365_ISP5_PCCR0x04
+#define DM365_ISP5_BCR 0x08
 #define DM365_ISP5_INTSEL1 0x10
 #define DM365_ISP5_INTSEL2 0x14
 #define DM365_ISP5_INTSEL3 0x18
+#define DM365_ISP5_EVTSEL  0x1c
 #define DM365_ISP5_CCDCMUX 0x20
 #define DM365_ISP5_PG_FRAME_SIZE   0x28
 #define DM365_VPBE_CLK_CTRL0x00
@@ -357,6 +359,10 @@ void dm365_vpss_set_pg_frame_size(struct 
vpss_pg_frame_size frame_size)
 }
 EXPORT_SYMBOL(dm365_vpss_set_pg_frame_size);
 
+#define DM365_ISP5_EVTSEL_EVT_DISABLE  0x
+#define DM365_ISP5_BCR_ISIF_OUT_ENABLE 0x0002
+#define DM365_ISP5_PCCR_CLK_ENABLE 0x007f
+
 static int __devinit vpss_probe(struct platform_device *pdev)
 {
struct resource *r1, *r2;
@@ -426,9 +432,16 @@ static int __devinit vpss_probe(struct platform_device 
*pdev)
oper_cfg.hw_ops.enable_clock = dm365_enable_clock;
oper_cfg.hw_ops.select_ccdc_source = dm365_select_ccdc_source;
/* Setup vpss interrupts */
+   isp5_write((isp5_read(DM365_ISP5_PCCR) |
+   DM365_ISP5_PCCR_CLK_ENABLE), DM365_ISP5_PCCR);
+   isp5_write((isp5_read(DM365_ISP5_BCR) |
+DM365_ISP5_BCR_ISIF_OUT_ENABLE), DM365_ISP5_BCR);
isp5_write(DM365_ISP5_INTSEL1_DEFAULT, DM365_ISP5_INTSEL1);
isp5_write(DM365_ISP5_INTSEL2_DEFAULT, DM365_ISP5_INTSEL2);
isp5_write(DM365_ISP5_INTSEL3_DEFAULT, DM365_ISP5_INTSEL3);
+   /* No event selected */
+   isp5_write((isp5_read(DM365_ISP5_EVTSEL) |
+   DM365_ISP5_EVTSEL_EVT_DISABLE), DM365_ISP5_EVTSEL);
} else
oper_cfg.hw_ops.clear_wbl_overflow = dm644x_clear_wbl_overflow;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/12] davinci: vpss: dm365: add vpss helper functions to be used in the main driver for setting hardware parameters

2012-11-16 Thread Prabhakar Lad
From: Manjunath Hadli manjunath.ha...@ti.com

add interface functions to set sync polarity, interrupt
completion and pageframe size in vpss to be used by the main driver.

Signed-off-by: Manjunath Hadli manjunath.ha...@ti.com
Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 drivers/media/platform/davinci/vpss.c |   32 
 include/media/davinci/vpss.h  |   16 
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/media/platform/davinci/vpss.c 
b/drivers/media/platform/davinci/vpss.c
index a36d694..4b7c7ecc 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -97,6 +97,12 @@ struct vpss_hw_ops {
void (*select_ccdc_source)(enum vpss_ccdc_source_sel src_sel);
/* clear wbl overflow bit */
int (*clear_wbl_overflow)(enum vpss_wbl_sel wbl_sel);
+   /* set sync polarity */
+   void (*set_sync_pol)(struct vpss_sync_pol);
+   /* set the PG_FRAME_SIZE register*/
+   void (*set_pg_frame_size)(struct vpss_pg_frame_size);
+   /* check and clear interrupt if occured */
+   int (*dma_complete_interrupt)(void);
 };
 
 /* vpss configuration */
@@ -161,6 +167,14 @@ static void dm355_select_ccdc_source(enum 
vpss_ccdc_source_sel src_sel)
bl_regw(src_sel  VPSS_HSSISEL_SHIFT, DM355_VPSSBL_CCDCMUX);
 }
 
+int vpss_dma_complete_interrupt(void)
+{
+   if (!oper_cfg.hw_ops.dma_complete_interrupt)
+   return 2;
+   return oper_cfg.hw_ops.dma_complete_interrupt();
+}
+EXPORT_SYMBOL(vpss_dma_complete_interrupt);
+
 int vpss_select_ccdc_source(enum vpss_ccdc_source_sel src_sel)
 {
if (!oper_cfg.hw_ops.select_ccdc_source)
@@ -186,6 +200,15 @@ static int dm644x_clear_wbl_overflow(enum vpss_wbl_sel 
wbl_sel)
return 0;
 }
 
+void vpss_set_sync_pol(struct vpss_sync_pol sync)
+{
+   if (!oper_cfg.hw_ops.set_sync_pol)
+   return;
+
+   oper_cfg.hw_ops.set_sync_pol(sync);
+}
+EXPORT_SYMBOL(vpss_set_sync_pol);
+
 int vpss_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel)
 {
if (!oper_cfg.hw_ops.clear_wbl_overflow)
@@ -351,6 +374,15 @@ void dm365_vpss_set_sync_pol(struct vpss_sync_pol sync)
 }
 EXPORT_SYMBOL(dm365_vpss_set_sync_pol);
 
+void vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size)
+{
+   if (!oper_cfg.hw_ops.set_pg_frame_size)
+   return;
+
+   oper_cfg.hw_ops.set_pg_frame_size(frame_size);
+}
+EXPORT_SYMBOL(vpss_set_pg_frame_size);
+
 void dm365_vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size)
 {
int current_reg = ((frame_size.hlpfr  1) - 1)  16;
diff --git a/include/media/davinci/vpss.h b/include/media/davinci/vpss.h
index b586495..153473d 100644
--- a/include/media/davinci/vpss.h
+++ b/include/media/davinci/vpss.h
@@ -105,4 +105,20 @@ enum vpss_wbl_sel {
 };
 /* clear wbl overflow flag for DM6446 */
 int vpss_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel);
+
+/* set sync polarity*/
+void vpss_set_sync_pol(struct vpss_sync_pol sync);
+/* set the PG_FRAME_SIZE register */
+void vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size);
+/*
+ * vpss_check_and_clear_interrupt - check and clear interrupt
+ * @irq - common enumerator for IRQ
+ *
+ * Following return values used:-
+ * 0 - interrupt occurred and cleared
+ * 1 - interrupt not occurred
+ * 2 - interrupt status not available
+ */
+int vpss_dma_complete_interrupt(void);
+
 #endif
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5] [media] vivi: Teach it to tune FPS

2012-11-16 Thread Hans Verkuil
On Fri November 16 2012 15:48:41 Kirill Smelkov wrote:
 On Fri, Nov 16, 2012 at 02:38:09PM +0100, Hans Verkuil wrote:
  On Wed November 7 2012 12:30:01 Kirill Smelkov wrote:
 [...]
 
   diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
   index 37d0af8..5d1b374 100644
   --- a/drivers/media/platform/vivi.c
   +++ b/drivers/media/platform/vivi.c
   @@ -65,8 +65,11 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
   megabytes);
/* Global font descriptor */
static const u8 *font8x16;

   -/* default to NTSC timeperframe */
   -static const struct v4l2_fract TPF_DEFAULT = {.numerator = 1001, 
   .denominator = 3};
   +/* timeperframe: min/max and default */
   +static const struct v4l2_fract
   + tpf_min = {.numerator = 1,  .denominator = UINT_MAX},  /* 
   1/infty */
   + tpf_max = {.numerator = UINT_MAX,   .denominator = 1}, /* 
   infty */
  
  I understand your reasoning here, but I wouldn't go with UINT_MAX here. 
  Something like
  1/1000 tpf (or 1 ms) up to 86400/1 tpf (or once a day). With UINT_MAX I am 
  afraid we
  might hit application errors when they manipulate these values. The 
  shortest time
  between frames is 1 ms anyway.
  
  It's the only comment I have, it looks good otherwise.
 
 Thanks, Let's then merge it with 1/1000 - 1000/1 limit. Ok?

OK.

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/12] Media Controller capture driver for DM365

2012-11-16 Thread Prabhakar Lad
Hi All,

On Fri, Nov 16, 2012 at 8:15 PM, Prabhakar Lad
prabhakar.cse...@gmail.com wrote:
 From: Manjunath Hadli manjunath.ha...@ti.com

 This patch set adds media controller based capture driver for
 DM365.

 This driver bases its design on Laurent Pinchart's Media Controller Design
 whose patches for Media Controller and subdev enhancements form the base.
 The driver also takes copious elements taken from Laurent Pinchart and
 others' OMAP ISP driver based on Media Controller. So thank you all the
 people who are responsible for the Media Controller and the OMAP ISP driver.

 Also, the core functionality of the driver comes from the arago vpfe capture
 driver of which the isif capture was based on V4L2, with other drivers like
 ipipe, ipipeif and Resizer.

 Changes for v2:
 1: Migrated the driver for videobuf2 usage pointed Hans.
 2: Changed the design as pointed by Laurent, Exposed one more subdevs
ipipeif and split the resizer subdev into three subdevs.
 3: Rearrganed the patch sequence and changed the commit messages.
 4: Changed the file architecture as pointed by Laurent.

Attached is the ps file to give a clear picture of entity connections.

Regards,
--Prabhakar Lad

 Manjunath Hadli (12):
   davinci: vpfe: add v4l2 capture driver with media interface
   davinci: vpfe: add v4l2 video driver support
   davinci: vpfe: dm365: add IPIPEIF driver based on media framework
   davinci: vpfe: dm365: add ISIF driver based on media framework
   davinci: vpfe: dm365: add IPIPE support for media controller driver
   davinci: vpfe: dm365: add IPIPE hardware layer support
   davinci: vpfe: dm365: resizer driver based on media framework
   davinci: vpss: dm365: enable ISP registers
   davinci: vpss: dm365: set vpss clk ctrl
   davinci: vpss: dm365: add vpss helper functions to be used in the
 main driver for setting hardware parameters
   davinci: vpfe: dm365: add build infrastructure for capture driver
   davinci: vpfe: Add documentation

  Documentation/video4linux/davinci-vpfe-mc.txt|  154 ++
  drivers/media/platform/davinci/Kconfig   |   11 +
  drivers/media/platform/davinci/Makefile  |3 +
  drivers/media/platform/davinci/dm365_ipipe.c | 1863 +++
  drivers/media/platform/davinci/dm365_ipipe.h |  179 ++
  drivers/media/platform/davinci/dm365_ipipe_hw.c  | 1048 +++
  drivers/media/platform/davinci/dm365_ipipe_hw.h  |  559 ++
  drivers/media/platform/davinci/dm365_ipipeif.c   | 1063 +++
  drivers/media/platform/davinci/dm365_ipipeif.h   |  233 +++
  drivers/media/platform/davinci/dm365_isif.c  | 2095 
 ++
  drivers/media/platform/davinci/dm365_isif.h  |  203 +++
  drivers/media/platform/davinci/dm365_isif_regs.h |  294 +++
  drivers/media/platform/davinci/dm365_resizer.c   | 1999 +
  drivers/media/platform/davinci/dm365_resizer.h   |  244 +++
  drivers/media/platform/davinci/vpfe_mc_capture.c |  741 
  drivers/media/platform/davinci/vpfe_mc_capture.h |   97 +
  drivers/media/platform/davinci/vpfe_video.c  | 1620 +
  drivers/media/platform/davinci/vpfe_video.h  |  155 ++
  drivers/media/platform/davinci/vpss.c|   59 +
  include/media/davinci/vpfe.h |   86 +
  include/media/davinci/vpss.h |   16 +
  include/uapi/linux/Kbuild|2 +
  include/uapi/linux/davinci_vpfe.h| 1285 +
  include/uapi/linux/dm365_ipipeif.h   |   93 +
  24 files changed, 14102 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/video4linux/davinci-vpfe-mc.txt
  create mode 100644 drivers/media/platform/davinci/dm365_ipipe.c
  create mode 100644 drivers/media/platform/davinci/dm365_ipipe.h
  create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.c
  create mode 100644 drivers/media/platform/davinci/dm365_ipipe_hw.h
  create mode 100644 drivers/media/platform/davinci/dm365_ipipeif.c
  create mode 100644 drivers/media/platform/davinci/dm365_ipipeif.h
  create mode 100644 drivers/media/platform/davinci/dm365_isif.c
  create mode 100644 drivers/media/platform/davinci/dm365_isif.h
  create mode 100644 drivers/media/platform/davinci/dm365_isif_regs.h
  create mode 100644 drivers/media/platform/davinci/dm365_resizer.c
  create mode 100644 drivers/media/platform/davinci/dm365_resizer.h
  create mode 100644 drivers/media/platform/davinci/vpfe_mc_capture.c
  create mode 100644 drivers/media/platform/davinci/vpfe_mc_capture.h
  create mode 100644 drivers/media/platform/davinci/vpfe_video.c
  create mode 100644 drivers/media/platform/davinci/vpfe_video.h
  create mode 100644 include/media/davinci/vpfe.h
  create mode 100644 include/uapi/linux/davinci_vpfe.h
  create mode 100644 include/uapi/linux/dm365_ipipeif.h

 --
 1.7.4.1



graph.ps
Description: PostScript document


Re: [PATCH v5] [media] vivi: Teach it to tune FPS

2012-11-16 Thread Kirill Smelkov
On Fri, Nov 16, 2012 at 03:51:23PM +0100, Hans Verkuil wrote:
 On Fri November 16 2012 15:48:41 Kirill Smelkov wrote:
  On Fri, Nov 16, 2012 at 02:38:09PM +0100, Hans Verkuil wrote:
   On Wed November 7 2012 12:30:01 Kirill Smelkov wrote:
  [...]
  
diff --git a/drivers/media/platform/vivi.c 
b/drivers/media/platform/vivi.c
index 37d0af8..5d1b374 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -65,8 +65,11 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
megabytes);
 /* Global font descriptor */
 static const u8 *font8x16;
 
-/* default to NTSC timeperframe */
-static const struct v4l2_fract TPF_DEFAULT = {.numerator = 1001, 
.denominator = 3};
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+   tpf_min = {.numerator = 1,  .denominator = 
UINT_MAX},  /* 1/infty */
+   tpf_max = {.numerator = UINT_MAX,   .denominator = 1},  
   /* infty */
   
   I understand your reasoning here, but I wouldn't go with UINT_MAX here. 
   Something like
   1/1000 tpf (or 1 ms) up to 86400/1 tpf (or once a day). With UINT_MAX I 
   am afraid we
   might hit application errors when they manipulate these values. The 
   shortest time
   between frames is 1 ms anyway.
   
   It's the only comment I have, it looks good otherwise.
  
  Thanks, Let's then merge it with 1/1000 - 1000/1 limit. Ok?
 
 OK.

Thanks.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 5/6] Add a V4L2 driver for SI476X MFD

2012-11-16 Thread Hans Verkuil
Hi Andrey,

Some more comments...

On Tue October 23 2012 20:44:31 Andrey Smirnov wrote:
 This commit adds a driver that exposes all the radio related
 functionality of the Si476x series of chips via the V4L2 subsystem.
 
 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/media/radio/Kconfig|   17 +
  drivers/media/radio/Makefile   |1 +
  drivers/media/radio/radio-si476x.c | 1549 
 
  3 files changed, 1567 insertions(+)
  create mode 100644 drivers/media/radio/radio-si476x.c
 

cut

 diff --git a/drivers/media/radio/radio-si476x.c 
 b/drivers/media/radio/radio-si476x.c
 new file mode 100644
 index 000..c8fa90f
 --- /dev/null
 +++ b/drivers/media/radio/radio-si476x.c
 @@ -0,0 +1,1549 @@
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/interrupt.h
 +#include linux/slab.h
 +#include linux/atomic.h
 +#include linux/videodev2.h
 +#include linux/mutex.h
 +#include linux/debugfs.h
 +#include media/v4l2-common.h
 +#include media/v4l2-ioctl.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-event.h
 +#include media/v4l2-device.h
 +
 +
 +#include linux/mfd/si476x-core.h
 +
 +#define FM_FREQ_RANGE_LOW   6400
 +#define FM_FREQ_RANGE_HIGH 10800
 +
 +#define AM_FREQ_RANGE_LOW52
 +#define AM_FREQ_RANGE_HIGH 3000
 +
 +#define PWRLINEFLTR (1  8)
 +
 +#define FREQ_MUL (1000 / 625)
 +
 +#define SI476X_PHDIV_STATUS_LINK_LOCKED(status) (0b1000  (status))
 +
 +#define DRIVER_NAME si476x-radio
 +#define DRIVER_CARD SI476x AM/FM Receiver
 +
 +enum si476x_freq_bands {
 + SI476X_BAND_FM,
 + SI476X_BAND_AM,
 +};
 +
 +static const struct v4l2_frequency_band si476x_bands[] = {
 + [SI476X_BAND_FM] = {
 + .type   = V4L2_TUNER_RADIO,
 + .index  = SI476X_BAND_FM,
 + .capability = V4L2_TUNER_CAP_LOW
 + | V4L2_TUNER_CAP_STEREO
 + | V4L2_TUNER_CAP_RDS
 + | V4L2_TUNER_CAP_RDS_BLOCK_IO
 + | V4L2_TUNER_CAP_FREQ_BANDS,
 + .rangelow   =  64 * FREQ_MUL,
 + .rangehigh  = 108 * FREQ_MUL,
 + .modulation = V4L2_BAND_MODULATION_FM,
 + },
 + [SI476X_BAND_AM] = {
 + .type   = V4L2_TUNER_RADIO,
 + .index  = SI476X_BAND_AM,
 + .capability = V4L2_TUNER_CAP_LOW | 
 V4L2_TUNER_CAP_FREQ_BANDS,
 + .rangelow   = 0.52 * FREQ_MUL,
 + .rangehigh  = 30 * FREQ_MUL,
 + .modulation = V4L2_BAND_MODULATION_AM,
 + },
 +};
 +
 +static inline bool si476x_radio_freq_is_inside_of_the_band(u32 freq, int 
 band)
 +{
 + return freq = si476x_bands[band].rangelow 
 + freq = si476x_bands[band].rangehigh;
 +}
 +
 +static inline bool si476x_radio_range_is_inside_of_the_band(u32 low, u32 
 high, int band)
 +{
 + return low  = si476x_bands[band].rangelow 
 + high = si476x_bands[band].rangehigh;
 +}
 +
 +#define PRIVATE_CTL_IDX(x) (x - V4L2_CID_PRIVATE_BASE)

No. The new control IDs need to be added to include/uapi/linux/v4l2-controls.h
with unique IDs. V4L2_CID_PRIVATE_BASE must not be used anymore for new 
controls.

Since Halli Manjunatha hasn't worked on a new version of his patch with the new
fm controls it might be something you want to take on (I'm referring to the FM 
RX
control class).

 +
 +static int si476x_radio_s_ctrl(struct v4l2_ctrl *ctrl);
 +static int si476x_radio_g_volatile_ctrl(struct v4l2_ctrl *ctrl);
 +
 +static const char * const deemphasis[] = {
 + 75 us,
 + 50 us,
 +};
 +
 +enum phase_diversity_modes_idx {
 + SI476X_IDX_PHDIV_DISABLED,
 + SI476X_IDX_PHDIV_PRIMARY_COMBINING,
 + SI476X_IDX_PHDIV_PRIMARY_ANTENNA,
 + SI476X_IDX_PHDIV_SECONDARY_ANTENNA,
 + SI476X_IDX_PHDIV_SECONDARY_COMBINING,
 +};
 +
 +static const char * const phase_diversity_modes[] = {
 + [SI476X_IDX_PHDIV_DISABLED] = disabled,
 + [SI476X_IDX_PHDIV_PRIMARY_COMBINING]= primary w/secondary,
 + [SI476X_IDX_PHDIV_PRIMARY_ANTENNA]  = primary(primary antenna),
 + [SI476X_IDX_PHDIV_SECONDARY_ANTENNA]= primary(seconadary antenna),
 + [SI476X_IDX_PHDIV_SECONDARY_COMBINING]  = secondary w/primary,
 +};
 +
 +static inline enum phase_diversity_modes_idx
 +si476x_phase_diversity_mode_to_idx(enum si476x_phase_diversity_mode mode)
 +{
 + switch (mode) {
 + default:/* FALLTHROUGH */
 + case SI476X_PHDIV_DISABLED:
 + return SI476X_IDX_PHDIV_DISABLED;
 + case SI476X_PHDIV_PRIMARY_COMBINING:
 + return SI476X_IDX_PHDIV_PRIMARY_COMBINING;
 + case SI476X_PHDIV_PRIMARY_ANTENNA:
 + return SI476X_IDX_PHDIV_PRIMARY_ANTENNA;
 + case SI476X_PHDIV_SECONDARY_ANTENNA:
 + return SI476X_IDX_PHDIV_SECONDARY_ANTENNA;
 + case SI476X_PHDIV_SECONDARY_COMBINING:
 + return SI476X_IDX_PHDIV_SECONDARY_COMBINING;
 + }
 +}

Re: [PATCH 1/4] v4l: Define video buffer flags for timestamp types

2012-11-16 Thread Sakari Ailus
Hi Hans,

Thanks for the comments!

On Fri, Nov 16, 2012 at 02:51:29PM +0100, Hans Verkuil wrote:
 On Thu November 15 2012 23:06:44 Sakari Ailus wrote:
  diff --git a/Documentation/DocBook/media/v4l/io.xml 
  b/Documentation/DocBook/media/v4l/io.xml
  index 7e2f3d7..d598f2c 100644
  --- a/Documentation/DocBook/media/v4l/io.xml
  +++ b/Documentation/DocBook/media/v4l/io.xml
  @@ -938,6 +938,31 @@ Typically applications shall use this flag for output 
  buffers if the data
   in this buffer has not been created by the CPU but by some DMA-capable 
  unit,
   in which case caches have not been used./entry
/row
  + row
  +   entryconstantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant/entry
  +   entry0xe000/entry
  +   entryMask for timestamp types below. To test the
  +   timestamp type, mask out bits not belonging to timestamp
  +   type by performing a logical and operation with buffer
  +   flags and timestamp mask./tt /entry
  + /row
  + row
  +   entryconstantV4L2_BUF_FLAG_TIMESTAMP_UNKNOWN/constant/entry
  +   entry0x/entry
  +   entryUnknown timestamp type. This type is used by
  +   drivers before Linux 3.8 and may be either monotonic (see
  +   below) or realtime. Monotonic clock has been favoured in
  +   embedded systems whereas most of the drivers use the
  +   realtime clock./entry
 
 Isn't 'wallclock time' a better expression? It is probably a good idea as
 well to add the userspace call that gives the same clock: gettimeofday or
 clock_gettime(CLOCK_REALTIME) for the wallclock time and
 clock_gettime(CLOCK_MONOTONIC) for the monotonic time. That way apps can
 do the same call and compare it to the timestamp received.

I'll add a reference to clock_gettime() and change realtime to wall clock
time. I wonder if I should also add that the unknown timestamp means either
of the two, or can we allow different kinds of unknown timestamps in the
future. Probably we should limit this to realtime and monotonic.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] [media] vivi: Teach it to tune FPS

2012-11-16 Thread Mauro Carvalho Chehab

Em 16-11-2012 11:38, Hans Verkuil escreveu:

On Wed November 7 2012 12:30:01 Kirill Smelkov wrote:

On Fri, Nov 02, 2012 at 03:42:21PM +0100, Hans Verkuil wrote:

Thanks for the ping, I forgot about this patch...


Thanks for feedback and for waiting. I'm here again...



On Tue October 23 2012 15:35:21 Kirill Smelkov wrote:

On Tue, Oct 23, 2012 at 08:40:04AM +0200, Hans Verkuil wrote:

On Mon October 22 2012 19:01:40 Kirill Smelkov wrote:

On Mon, Oct 22, 2012 at 04:16:14PM +0200, Hans Verkuil wrote:

On Mon October 22 2012 15:54:44 Kirill Smelkov wrote:

I was testing my video-over-ethernet subsystem today, and vivi seemed to
be perfect video source for testing when one don't have lots of capture
boards and cameras. Only its framerate was hardcoded to NTSC's 30fps,
while in my country we usually use PAL (25 fps). That's why the patch.
Thanks.


Rather than introducing a module option, it's much nicer if you can
implement enum_frameintervals and g/s_parm. This can be made quite flexible
allowing you to also support 50/59.94/60 fps.


Thanks for feedback. I've reworked the patch for FPS to be set via
-{g,s}_parm(), and yes now it is more flexble, because one can set
different FPS on different vivi devices. Only I don't know V4L2 ioctls
details well enough and various drivers do things differently. The patch
is below. Is it ok?


Close, but it's not quite there.

You should run the v4l2-compliance tool from the v4l-utils.git repository
(take the master branch). That will report any errors in your implementation.

In this case g/s_parm doesn't set readbuffers (set it to 1) and if timeperframe
equals { 0, 0 }, then you should get a nominal framerate (let's stick to 29.97
for that). I would set the nominal framerate whenever the denominator == 0.

For vidioc_enum_frameintervals you need to check the IN fields and fill in the
stepwise struct.


Thanks for pointers and info about v4l2-compliance handy-tool. I've
tried to correct all the issues you mentioned above and here is the
patch.

(Only requirement to set stepwise.step to 1.0 for
  V4L2_FRMIVAL_TYPE_CONTINUOUS seems a bit illogical to me, but anyway,
  that's what the V4L2 spec requires...)

Thanks,
Kirill

 8 
From: Kirill Smelkov k...@mns.spb.ru
Date: Tue, 23 Oct 2012 16:56:59 +0400
Subject: [PATCH v3] [media] vivi: Teach it to tune FPS

I was testing my video-over-ethernet subsystem yesterday, and vivi
seemed to be perfect video source for testing when one don't have lots
of capture boards and cameras. Only its framerate was hardcoded to
NTSC's 30fps, while in my country we usually use PAL (25 fps) and I
needed that to precisely simulate bandwidth.

That's why here is this patch with -enum_frameintervals() and
-{g,s}_parm() implemented as suggested by Hans Verkuil which passes
v4l2-compliance and manual testing through v4l2-ctl -P / -p fps.

Regarding newly introduced __get_format(u32 pixelformat) I decided not
to convert original get_format() to operate on fourcc codes, since = 3
places in driver need to deal with v4l2_format and otherwise it won't be
handy.

Thanks.

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
---
  drivers/media/platform/vivi.c | 84 ++-
  1 file changed, 75 insertions(+), 9 deletions(-)

V3:
 - corrected issues with V4L2 spec compliance as pointed by Hans
   Verkuil.

V2:

 - reworked FPS setting from module param to via -{g,s}_parm() as suggested
   by Hans Verkuil.


diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 3e6902a..3adea58 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -36,10 +36,6 @@

  #define VIVI_MODULE_NAME vivi

-/* Wake up at about 30 fps */
-#define WAKE_NUMERATOR 30
-#define WAKE_DENOMINATOR 1001
-
  #define MAX_WIDTH 1920
  #define MAX_HEIGHT 1200

@@ -69,6 +65,9 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in 
megabytes);
  /* Global font descriptor */
  static const u8 *font8x16;

+/* default to NTSC timeperframe */
+static const struct v4l2_fract TPF_DEFAULT = {.numerator = 1001, .denominator 
= 3};


Keep the name lower case: tpf_default. Upper case is for defines only.


ok

[...]


@@ -1049,6 +1054,63 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int i)
return 0;
  }

+/* timeperframe is arbitrary and continous */
+static int vidioc_enum_frameintervals(struct file *file, void *priv,
+struct v4l2_frmivalenum *fival)
+{
+   struct vivi_fmt *fmt;
+
+   if (fival-index)
+   return -EINVAL;
+
+   fmt = __get_format(fival-pixel_format);
+   if (!fmt)
+   return -EINVAL;
+
+   /* regarding width width  height - we support any */
+
+   fival-type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
+
+   /* fill in stepwise as required by V4L2 spec, i.e.
+*
+* min = (step = 1.0) = max
+*/
+   fival-stepwise.step = (struct v4l2_fract) {1, 

Re: [PATCH 1/4] v4l: Define video buffer flags for timestamp types

2012-11-16 Thread Hans Verkuil
On Fri November 16 2012 16:20:03 Sakari Ailus wrote:
 Hi Hans,
 
 Thanks for the comments!
 
 On Fri, Nov 16, 2012 at 02:51:29PM +0100, Hans Verkuil wrote:
  On Thu November 15 2012 23:06:44 Sakari Ailus wrote:
   diff --git a/Documentation/DocBook/media/v4l/io.xml 
   b/Documentation/DocBook/media/v4l/io.xml
   index 7e2f3d7..d598f2c 100644
   --- a/Documentation/DocBook/media/v4l/io.xml
   +++ b/Documentation/DocBook/media/v4l/io.xml
   @@ -938,6 +938,31 @@ Typically applications shall use this flag for 
   output buffers if the data
in this buffer has not been created by the CPU but by some DMA-capable 
   unit,
in which case caches have not been used./entry
   /row
   +   row
   + entryconstantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant/entry
   + entry0xe000/entry
   + entryMask for timestamp types below. To test the
   + timestamp type, mask out bits not belonging to timestamp
   + type by performing a logical and operation with buffer
   + flags and timestamp mask./tt /entry
   +   /row
   +   row
   + entryconstantV4L2_BUF_FLAG_TIMESTAMP_UNKNOWN/constant/entry
   + entry0x/entry
   + entryUnknown timestamp type. This type is used by
   + drivers before Linux 3.8 and may be either monotonic (see
   + below) or realtime. Monotonic clock has been favoured in
   + embedded systems whereas most of the drivers use the
   + realtime clock./entry
  
  Isn't 'wallclock time' a better expression? It is probably a good idea as
  well to add the userspace call that gives the same clock: gettimeofday or
  clock_gettime(CLOCK_REALTIME) for the wallclock time and
  clock_gettime(CLOCK_MONOTONIC) for the monotonic time. That way apps can
  do the same call and compare it to the timestamp received.
 
 I'll add a reference to clock_gettime() and change realtime to wall clock
 time. I wonder if I should also add that the unknown timestamp means either
 of the two, or can we allow different kinds of unknown timestamps in the
 future.

No. UNKNOWN should never be used in the future. It is specific to the pre
timestamp flag era where the timestamp is really only one of two options.

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv1 PATCH 0/2] Two vpif fixes protecting the dma_queue by a lock

2012-11-16 Thread Hans Verkuil
Hi Prabhakar,

These two patches add protection to the dma_queue. We discovered that not
locking caused race conditions, which caused the display DMA to jam. After
adding the lock we never saw this again.

It makes sense as well since the interrupt routine and normal code both
manipulated the same list.

It's fixed for both capture and display.

Regards,

Hans

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv1 PATCH 1/2] vpif_capture: protect dma_queue by a spin_lock.

2012-11-16 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The dma_queue list is accessed by both the interrupt handler and by normal
code. It needs to be protected by a lock to prevent possible list corruption.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/davinci/vpif_capture.c |   26 ++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index fcabc02..f4f15f1 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -201,13 +201,16 @@ static void vpif_buffer_queue(struct vb2_buffer *vb)
struct vpif_cap_buffer *buf = container_of(vb,
struct vpif_cap_buffer, vb);
struct common_obj *common;
+   unsigned long flags;
 
common = ch-common[VPIF_VIDEO_INDEX];
 
vpif_dbg(2, debug, vpif_buffer_queue\n);
 
+   spin_lock_irqsave(common-irqlock, flags);
/* add the buffer to the DMA queue */
list_add_tail(buf-list, common-dma_queue);
+   spin_unlock_irqrestore(common-irqlock, flags);
 }
 
 /**
@@ -278,10 +281,13 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
struct common_obj *common = ch-common[VPIF_VIDEO_INDEX];
struct vpif_params *vpif = ch-vpifparams;
unsigned long addr = 0;
+   unsigned long flags;
int ret;
 
-   /* If buffer queue is empty, return error */
+   /* If buffer queue is empty, return error */
+   spin_lock_irqsave(common-irqlock, flags);
if (list_empty(common-dma_queue)) {
+   spin_unlock_irqrestore(common-irqlock, flags);
vpif_dbg(1, debug, buffer queue is empty\n);
return -EIO;
}
@@ -291,6 +297,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
struct vpif_cap_buffer, list);
/* Remove buffer from the buffer queue */
list_del(common-cur_frm-list);
+   spin_unlock_irqrestore(common-irqlock, flags);
/* Mark state of the current frame to active */
common-cur_frm-vb.state = VB2_BUF_STATE_ACTIVE;
/* Initialize field_id and started member */
@@ -362,6 +369,7 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
struct vpif_fh *fh = vb2_get_drv_priv(vq);
struct channel_obj *ch = fh-channel;
struct common_obj *common;
+   unsigned long flags;
 
if (!vb2_is_streaming(vq))
return 0;
@@ -369,12 +377,14 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
common = ch-common[VPIF_VIDEO_INDEX];
 
/* release all active buffers */
+   spin_lock_irqsave(common-irqlock, flags);
while (!list_empty(common-dma_queue)) {
common-next_frm = list_entry(common-dma_queue.next,
struct vpif_cap_buffer, list);
list_del(common-next_frm-list);
vb2_buffer_done(common-next_frm-vb, VB2_BUF_STATE_ERROR);
}
+   spin_unlock_irqrestore(common-irqlock, flags);
 
return 0;
 }
@@ -420,10 +430,12 @@ static void vpif_schedule_next_buffer(struct common_obj 
*common)
 {
unsigned long addr = 0;
 
+   spin_lock(common-irqlock);
common-next_frm = list_entry(common-dma_queue.next,
 struct vpif_cap_buffer, list);
/* Remove that buffer from the buffer queue */
list_del(common-next_frm-list);
+   spin_unlock(common-irqlock);
common-next_frm-vb.state = VB2_BUF_STATE_ACTIVE;
addr = vb2_dma_contig_plane_dma_addr(common-next_frm-vb, 0);
 
@@ -468,8 +480,12 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
/* Check the field format */
if (1 == ch-vpifparams.std_info.frm_fmt) {
/* Progressive mode */
-   if (list_empty(common-dma_queue))
+   spin_lock(common-irqlock);
+   if (list_empty(common-dma_queue)) {
+   spin_unlock(common-irqlock);
continue;
+   }
+   spin_unlock(common-irqlock);
 
if (!channel_first_int[i][channel_id])
vpif_process_buffer_complete(common);
@@ -513,9 +529,13 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
vpif_process_buffer_complete(common);
} else if (1 == fid) {
/* odd field */
+   spin_lock(common-irqlock);
if (list_empty(common-dma_queue) ||
-   (common-cur_frm != common-next_frm))
+   

[RFCv1 PATCH 2/2] vpif_display: protect dma_queue by a spin_lock.

2012-11-16 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The dma_queue list is accessed by both the interrupt handler and by normal
code. It needs to be protected by a lock to prevent possible list corruption.

Corruption has been observed in 'real-life' conditions. Adding this lock made
it go away.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/davinci/vpif_display.c |   22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index b716fbd..a8c6bd3 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -177,11 +177,14 @@ static void vpif_buffer_queue(struct vb2_buffer *vb)
struct vpif_disp_buffer, vb);
struct channel_obj *ch = fh-channel;
struct common_obj *common;
+   unsigned long flags;
 
common = ch-common[VPIF_VIDEO_INDEX];
 
/* add the buffer to the DMA queue */
+   spin_lock_irqsave(common-irqlock, flags);
list_add_tail(buf-list, common-dma_queue);
+   spin_unlock_irqrestore(common-irqlock, flags);
 }
 
 /*
@@ -246,10 +249,13 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
struct common_obj *common = ch-common[VPIF_VIDEO_INDEX];
struct vpif_params *vpif = ch-vpifparams;
unsigned long addr = 0;
+   unsigned long flags;
int ret;
 
/* If buffer queue is empty, return error */
+   spin_lock_irqsave(common-irqlock, flags);
if (list_empty(common-dma_queue)) {
+   spin_unlock_irqrestore(common-irqlock, flags);
vpif_err(buffer queue is empty\n);
return -EIO;
}
@@ -260,6 +266,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
   struct vpif_disp_buffer, list);
 
list_del(common-cur_frm-list);
+   spin_unlock_irqrestore(common-irqlock, flags);
/* Mark state of the current frame to active */
common-cur_frm-vb.state = VB2_BUF_STATE_ACTIVE;
 
@@ -330,6 +337,7 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
struct vpif_fh *fh = vb2_get_drv_priv(vq);
struct channel_obj *ch = fh-channel;
struct common_obj *common;
+   unsigned long flags;
 
if (!vb2_is_streaming(vq))
return 0;
@@ -337,12 +345,14 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
common = ch-common[VPIF_VIDEO_INDEX];
 
/* release all active buffers */
+   spin_lock_irqsave(common-irqlock, flags);
while (!list_empty(common-dma_queue)) {
common-next_frm = list_entry(common-dma_queue.next,
struct vpif_disp_buffer, list);
list_del(common-next_frm-list);
vb2_buffer_done(common-next_frm-vb, VB2_BUF_STATE_ERROR);
}
+   spin_unlock_irqrestore(common-irqlock, flags);
 
return 0;
 }
@@ -363,11 +373,13 @@ static void process_progressive_mode(struct common_obj 
*common)
 {
unsigned long addr = 0;
 
+   spin_lock(common-irqlock);
/* Get the next buffer from buffer queue */
common-next_frm = list_entry(common-dma_queue.next,
struct vpif_disp_buffer, list);
/* Remove that buffer from the buffer queue */
list_del(common-next_frm-list);
+   spin_unlock(common-irqlock);
/* Mark status of the buffer as active */
common-next_frm-vb.state = VB2_BUF_STATE_ACTIVE;
 
@@ -398,16 +410,18 @@ static void process_interlaced_mode(int fid, struct 
common_obj *common)
common-cur_frm = common-next_frm;
 
} else if (1 == fid) {  /* odd field */
+   spin_lock(common-irqlock);
if (list_empty(common-dma_queue)
|| (common-cur_frm != common-next_frm)) {
+   spin_unlock(common-irqlock);
return;
}
+   spin_unlock(common-irqlock);
/* one field is displayed configure the next
 * frame if it is available else hold on current
 * frame */
/* Get next from the buffer queue */
process_progressive_mode(common);
-
}
 }
 
@@ -437,8 +451,12 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
continue;
 
if (1 == ch-vpifparams.std_info.frm_fmt) {
-   if (list_empty(common-dma_queue))
+   spin_lock(common-irqlock);
+   if (list_empty(common-dma_queue)) {
+   spin_unlock(common-irqlock);
continue;
+   }
+   spin_unlock(common-irqlock);
 

Re: Bugs in DVB-S Prof-Tuner 8000 driver (idle suspend)

2012-11-16 Thread Wojciech Myrda
W dniu 08.10.2012 16:39, Wojciech Myrda pisze:
 Hi,

 I am using these new driver http://patchwork.linuxtv.org/patch/14300/
 for my card. It generally works great allowing me to send DiseqC
 commands, tune to LNBs etc but only as long as I do not use idle or
 suspend with it which in first circumstance leads to kernel panics for
 which I acquired number of pictures http://bigvo.dyndns.org/dvb/cx23885/
 and in second requires reloading the driver to work properly


 CARD INFO
 [4.600476] cx23885 driver version 0.0.3 loaded
 [4.600828] CORE cx23885[0]: subsystem: 8000:3034, board: Prof
 Revolution DVB-S2 8000 [card=37,autodetected]
 [5.334312] cx23885_dvb_register() allocating 1 frontend(s)
 [5.334342] cx23885[0]: cx23885 based dvb card
 [5.423938] DVB: registering new adapter (cx23885[0])
 [5.424427] cx23885_dev_checkrevision() Hardware revision = 0xb0
 [5.424437] cx23885[0]/0: found at :02:00.0, rev: 2, irq: 16,
 latency: 0, mmio: 0xfe60

 More info here: http://bigvo.dyndns.org/dvb/

 If anyone is willing to take time and effort to improve the code for the
 driver I would greatly appreciate it and I am willing to test it

 Regards,
 _WM

hi guys,

I tried to use my Prof card once again now that 3.7 kernel reached rc-5
to find my system crash after something about 2 hours of testing the
card. This time for a change I did notice that first after I made number
of tunnings to different channels few minutes before the crash I was not
able to tune to in to any frequency.

My system without the card did work for a month with no problem
therefore the problem is definetly with the card or the way the in
kernel driver for it works. Please take a look at the error and let me
know if there is any thing I can do to get rid of this problem :(



BUG: unable to handle kernel NULL pointer deference at 00a8
IP: [a01d38a0] cx23885_video_wakeup+0x20/0x160 [ cx23885]
PGD 127716067 PUD 12b2f1067 PMD 0
Oops:  [#1] SMP
Modules linked in: des_generic ecb md4 sha256_generic md5 hmac
nls_cp1250 cifs ipv6 dvb_ttpci saa7146_vv ttpci_eeprom saa7146
ir_rc6_decoder ir_lirc_codec lirc_dev w83627ehf hwmon_vid phx_k8(O)
mperf(O) thermal fan rc_imon_pad imon usbhid stb6100 stv090x cx23885
btcx_risc psmouse snd_hda_codec_realtek altera_ci videobuf_dvb tda18271
pcspkr altera_stapi tveeprom cx2341x videobuf_dma_sg k10temp dvb_core
rc_core v4l2_common xhci_hcd r8169 videodev mii media snd_hda_codec_hdmi
videobuf_core ohci_hcd sr_mod cdrom snd_hda_intel ehci_hcd snd_hda_codec
snd_hwdep snd_pcm usbcore snd_page_alloc usb_common snd_timer snd
parport_pc parport processor thermal_sys
CPU 1
Pid: 0, comm: swapper/1 Tained: G 0 3.7.0-rc5 #1 System manufacuter
System Product Name/E35M1-M PRO
RIP: 0010:[a01d38a0] [a01d38a0]
cx23885_video_wakeup+0x20/0x160 [ cx23885]
RSP: 0018:88013ed03de8 EFLAGS: 00010082
RAX: c9001140 RBX:  RCX: 0060
RDX:  RSI: 880137586070 RDI: 880137584000
RBP: 880137586070 R08: 000a R09: 
R10: 03cb R11: 03ca R12: 
R13:  R14:  R15: 
FS: 7f1b27b73700() GS:88013ed0() knlGS:f1bfab40
CS: 0010 DS:  ES:  CR0: 8005003b
CR2: 00a8 CR3: 00012743b000 CR4: 07e0
DR0:  DR1:  DR2: 
DR3:  DR6: 0ff0 DR7: 0400
Process swapper/1 (pid: 0, threadinfo 88013a8a6000, task
88013a87c080
Stack:
88013ed03e38 88013ed03df8  
880137584000   
 a01d4360 880137584000 
Call Trace:
IRQ
[a01d4360] ? cx23885_video_irq+0x100/0x1c0 [ cx23885]
[a01d7ea4] ? cx23885_irq+0x434/0x920 [ cx23885]
[8109cab9] ? rcu_process_callbacks+0x459/0x540
[a00067a5] ? azx_interrupt+0x105/0x1b0 [snd_hda_intel]
[81096624] ? handle_irq_event_percpu+0x54/0x1f0
[810967f6] ? handle_irq_event+0x36/0x60
[8109967c] ? handle_fasteoi_irq+0x4c/0xe0
[81003df5] ? handle_irq+0x15/0x20
[81003ac3] ? do_IRQ+0x53/0xd0
[814ab9ea] ? common_interrupt+0x6a/0x6a
EOI
[a0012005] ? acpi_idle_enter_simple+0xb5/0xe6 [processor]
[a0012000] ? acpi_idle_enter_simple+0xb0/0xe6 [processor]
[813e6b12] ? cpuidle_idle_call+0xa2/0x270
[8100b24a] ? cpu_idle+0x7a/0xd0
Code: 12 2d e1 e9 52 ff ff ff 0f 1f 00 41 57 41 56 41 89 d6 41 55 41 54
55 48 89 f5 53 48 83 ec 18 48 8b 1e 48 39 de 0f 84 e1 00 00 00 66 3b
93 a8 00 00 00 41 89 d4 0f 88 b4 00 00 00 48 8d 43 c8 45
RIP [a01d38a0] cx23885_video_wakeup+0x20/0x160 [ cx23885]
RSP 88013ed03de8
CR2: 00a8
Kernel panic – not syncing: Fatal exception in interrupt
panic occured, switching back to text 

[PATCH v1.1 1/4] v4l: Define video buffer flags for timestamp types

2012-11-16 Thread Sakari Ailus
Define video buffer flags for different timestamp types. Everything up to
now have used either realtime clock or monotonic clock, without a way to
tell which clock the timestamp was taken from.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
Changes since v1:

- Mention about timestamps in API changes
- Bump API version to 3.8
- DocBook compile fixes
- Tell realtime clock is the same as wall clock, and mention how to get such
  timestamps in the user space

 Documentation/DocBook/media/v4l/compat.xml |   12 +++
 Documentation/DocBook/media/v4l/io.xml |   29 
 Documentation/DocBook/media/v4l/v4l2.xml   |   12 ++-
 include/uapi/linux/videodev2.h |4 +++
 4 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index 4fdf6b5..651ca52 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2477,6 +2477,18 @@ that used it. It was originally scheduled for removal in 
2.6.35.
   /orderedlist
 /section
 
+section
+  titleV4L2 in Linux 3.8/title
+  orderedlist
+listitem
+ paraAdded timestamp types to
+ structfieldflags/structfield field in
+ structnamev4l2_buffer/structname. See xref
+ linkend=buffer-flags /./para
+/listitem
+  /orderedlist
+/section
+
 section id=other
   titleRelation of V4L2 to other Linux multimedia APIs/title
 
diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 7e2f3d7..bcd1c8f7 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -938,6 +938,35 @@ Typically applications shall use this flag for output 
buffers if the data
 in this buffer has not been created by the CPU but by some DMA-capable unit,
 in which case caches have not been used./entry
  /row
+ row
+   entryconstantV4L2_BUF_FLAG_TIMESTAMP_MASK/constant/entry
+   entry0xe000/entry
+   entryMask for timestamp types below. To test the
+   timestamp type, mask out bits not belonging to timestamp
+   type by performing a logical and operation with buffer
+   flags and timestamp mask./entry
+ /row
+ row
+   entryconstantV4L2_BUF_FLAG_TIMESTAMP_UNKNOWN/constant/entry
+   entry0x/entry
+   entryUnknown timestamp type. This type is used by
+   drivers before Linux 3.8 and may be either monotonic (see
+   below) or realtime (wall clock). Monotonic clock has been
+   favoured in embedded systems whereas most of the drivers
+   use the realtime clock. Either kinds of timestamps are
+   available in user space via
+   functionclock_gettime(2)/function using clock IDs
+   constantCLOCK_MONOTONIC/constant and
+   constantCLOCK_REALTIME/constant, respectively./entry
+ /row
+ row
+   
entryconstantV4L2_BUF_FLAG_TIMESTAMP_MONOTONIC/constant/entry
+   entry0x2000/entry
+   entryThe buffer timestamp has been taken from the
+   constantCLOCK_MONOTONIC/constant clock. To access the
+   same clock outside V4L2, use
+   functionclock_gettime(2)/function ./entry
+ /row
/tbody
   /tgroup
 /table
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index 10ccde9..8b6f29e 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -140,6 +140,16 @@ structs, ioctls) must be noted in more detail in the 
history chapter
 applications. --
 
   revision
+   revnumber3.8/revnumber
+   date2012-11-16/date
+   authorinitialssa/authorinitials
+   revremarkAdded timestamp types to
+   structnamev4l2_buffer/structname, see xref
+   linkend=buffer-flags /.
+   /revremark
+  /revision
+
+  revision
revnumber3.6/revnumber
date2012-07-02/date
authorinitialshv/authorinitials
@@ -472,7 +482,7 @@ and discussions on the V4L mailing list./revremark
 /partinfo
 
 titleVideo for Linux Two API Specification/title
- subtitleRevision 3.6/subtitle
+ subtitleRevision 3.8/subtitle
 
   chapter id=common
 sub-common;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 2fff7ff..410ea9f 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -686,6 +686,10 @@ struct v4l2_buffer {
 /* Cache handling flags */
 #define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE  0x0800
 #define V4L2_BUF_FLAG_NO_CACHE_CLEAN   0x1000
+/* Timestamp type */
+#define V4L2_BUF_FLAG_TIMESTAMP_MASK   0xe000
+#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN0x
+#define 

[PATCH 1/1] v4l: There's no __unsigned

2012-11-16 Thread Sakari Ailus
Correct a typo. v4l2_plane.m.userptr is unsigned long, not __unsigned long.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 Documentation/DocBook/media/v4l/io.xml |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index bcd1c8f7..1565f31 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -736,7 +736,7 @@ should set this to 0./entry
  /row
  row
entry/entry
-   entry__unsigned long/entry
+   entryunsigned long/entry
entrystructfielduserptr/structfield/entry
entryWhen the memory type in the containing v4l2-buffer; is
  constantV4L2_MEMORY_USERPTR/constant, this is a userspace
-- 
1.7.2.5

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Patch] dvb-apps / Add frequencies for CH-WWZ

2012-11-16 Thread Silvan Imsand
Hi
I've attached a patch to add new frequencies for dvb-apps/scan
I would appreciate if someone could apply the patch.
Thanks.

Regards,
Silvan


dvb-apps-wwz-frequencies.patch
Description: Binary data


cron job: media_tree daily build: WARNINGS

2012-11-16 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:Fri Nov 16 19:00:22 CET 2012
git hash:2c4e11b7c15af70580625657a154ea7ea70b8c76
gcc version:  i686-linux-gcc (GCC) 4.7.1
host hardware:x86_64
host os:  3.4.07-marune

linux-git-arm-eabi-davinci: WARNINGS
linux-git-arm-eabi-exynos: WARNINGS
linux-git-arm-eabi-omap: WARNINGS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: WARNINGS
linux-git-x86_64: OK
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-3.0-i686: WARNINGS
linux-3.1-i686: WARNINGS
linux-3.2.1-i686: WARNINGS
linux-3.3-i686: WARNINGS
linux-3.4-i686: WARNINGS
linux-3.5-i686: WARNINGS
linux-3.6-i686: WARNINGS
linux-3.7-rc1-i686: WARNINGS
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
linux-3.0-x86_64: WARNINGS
linux-3.1-x86_64: WARNINGS
linux-3.2.1-x86_64: WARNINGS
linux-3.3-x86_64: WARNINGS
linux-3.4-x86_64: WARNINGS
linux-3.5-x86_64: WARNINGS
linux-3.6-x86_64: WARNINGS
linux-3.7-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.tar.bz2

The V4L-DVB specification from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Email blocked, contains executable attachment] [Virus email-worm:w32/mydoom.gen!a] Returned mail: see transcript for details

2012-11-16 Thread proofpoint-pps
This message and the file attached to the message, was NOT sent to the 
recipient, because it contains an Executable Attachment file type that is 
currently being blocked. A copy was also sent to the Quarantine folder 
“EXEstrip”. 

Subject: [Virus email-worm:w32/mydoom.gen!a] Returned mail: see transcript for 
details
Recipient: h...@alico-egypt.com
Date: 2012-11-16 - 19:28:43

Please contact local helpdesk for support.

Alico Security
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch] MAINTAINERS: add an entry for radio-mr800 driver

2012-11-16 Thread Alexey Klimov
This patch adds MAINTAINERS entry for radio-mr800 usb radio driver.

Signed-off-by: Alexey Klimov klimov.li...@gmail.com

diff --git a/MAINTAINERS b/MAINTAINERS
index f4b3aa8..e1d9e38 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4909,6 +4909,13 @@ S:   Maintained
 F: Documentation/serial/moxa-smartio
 F: drivers/tty/mxser.*
 
+MR800 AVERMEDIA USB FM RADIO DRIVER
+M: Alexey Klimov klimov.li...@gmail.com
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/radio/radio-mr800.c
+
 MSI LAPTOP SUPPORT
 M: Lee, Chun-Yi j...@novell.com
 L: platform-driver-...@vger.kernel.org


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 5/6] Add a V4L2 driver for SI476X MFD

2012-11-16 Thread Alexey Klimov
Hello Andrey,

On Tue, Oct 23, 2012 at 10:44 PM, Andrey Smirnov
andrey.smir...@convergeddevices.net wrote:
 This commit adds a driver that exposes all the radio related
 functionality of the Si476x series of chips via the V4L2 subsystem.

 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/media/radio/Kconfig|   17 +
  drivers/media/radio/Makefile   |1 +
  drivers/media/radio/radio-si476x.c | 1549 
 
  3 files changed, 1567 insertions(+)
  create mode 100644 drivers/media/radio/radio-si476x.c

 diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
 index 8090b87..3c79d09 100644
 --- a/drivers/media/radio/Kconfig
 +++ b/drivers/media/radio/Kconfig
 @@ -16,6 +16,23 @@ config RADIO_SI470X
 bool Silicon Labs Si470x FM Radio Receiver support
 depends on VIDEO_V4L2

 +config RADIO_SI476X
 +   tristate Silicon Laboratories Si476x I2C FM Radio
 +   depends on I2C  VIDEO_V4L2
 +   select MFD_CORE
 +   select MFD_SI476X_CORE
 +   select SND_SOC_SI476X
 +   ---help---
 + Choose Y here if you have this FM radio chip.
 +
 + In order to control your radio card, you will need to use programs
 + that are compatible with the Video For Linux 2 API.  Information on
 + this API and pointers to v4l2 programs may be found at
 + file:Documentation/video4linux/API.html.
 +
 + To compile this driver as a module, choose M here: the
 + module will be called radio-si476x.
 +
  source drivers/media/radio/si470x/Kconfig

  config USB_MR800
 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
 index c03ce4f..c4618e0 100644
 --- a/drivers/media/radio/Makefile
 +++ b/drivers/media/radio/Makefile
 @@ -19,6 +19,7 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
  obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
  obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
  obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
 +obj-$(CONFIG_RADIO_SI476X) += radio-si476x.o
  obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
  obj-$(CONFIG_USB_DSBR) += dsbr100.o
  obj-$(CONFIG_RADIO_SI470X) += si470x/
 diff --git a/drivers/media/radio/radio-si476x.c 
 b/drivers/media/radio/radio-si476x.c
 new file mode 100644
 index 000..c8fa90f
 --- /dev/null
 +++ b/drivers/media/radio/radio-si476x.c
 @@ -0,0 +1,1549 @@
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/interrupt.h
 +#include linux/slab.h
 +#include linux/atomic.h
 +#include linux/videodev2.h
 +#include linux/mutex.h
 +#include linux/debugfs.h
 +#include media/v4l2-common.h
 +#include media/v4l2-ioctl.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-event.h
 +#include media/v4l2-device.h
 +
 +
 +#include linux/mfd/si476x-core.h
 +
 +#define FM_FREQ_RANGE_LOW   6400
 +#define FM_FREQ_RANGE_HIGH 10800
 +
 +#define AM_FREQ_RANGE_LOW52
 +#define AM_FREQ_RANGE_HIGH 3000
 +
 +#define PWRLINEFLTR (1  8)
 +
 +#define FREQ_MUL (1000 / 625)
 +
 +#define SI476X_PHDIV_STATUS_LINK_LOCKED(status) (0b1000  (status))
 +
 +#define DRIVER_NAME si476x-radio
 +#define DRIVER_CARD SI476x AM/FM Receiver
 +
 +enum si476x_freq_bands {
 +   SI476X_BAND_FM,
 +   SI476X_BAND_AM,
 +};
 +
 +static const struct v4l2_frequency_band si476x_bands[] = {
 +   [SI476X_BAND_FM] = {
 +   .type   = V4L2_TUNER_RADIO,
 +   .index  = SI476X_BAND_FM,
 +   .capability = V4L2_TUNER_CAP_LOW
 +   | V4L2_TUNER_CAP_STEREO
 +   | V4L2_TUNER_CAP_RDS
 +   | V4L2_TUNER_CAP_RDS_BLOCK_IO
 +   | V4L2_TUNER_CAP_FREQ_BANDS,
 +   .rangelow   =  64 * FREQ_MUL,
 +   .rangehigh  = 108 * FREQ_MUL,
 +   .modulation = V4L2_BAND_MODULATION_FM,
 +   },
 +   [SI476X_BAND_AM] = {
 +   .type   = V4L2_TUNER_RADIO,
 +   .index  = SI476X_BAND_AM,
 +   .capability = V4L2_TUNER_CAP_LOW | 
 V4L2_TUNER_CAP_FREQ_BANDS,
 +   .rangelow   = 0.52 * FREQ_MUL,
 +   .rangehigh  = 30 * FREQ_MUL,
 +   .modulation = V4L2_BAND_MODULATION_AM,
 +   },
 +};
 +
 +static inline bool si476x_radio_freq_is_inside_of_the_band(u32 freq, int 
 band)
 +{
 +   return freq = si476x_bands[band].rangelow 
 +   freq = si476x_bands[band].rangehigh;
 +}
 +
 +static inline bool si476x_radio_range_is_inside_of_the_band(u32 low, u32 
 high, int band)
 +{
 +   return low  = si476x_bands[band].rangelow 
 +   high = si476x_bands[band].rangehigh;
 +}
 +
 +#define PRIVATE_CTL_IDX(x) (x - V4L2_CID_PRIVATE_BASE)
 +
 +static int si476x_radio_s_ctrl(struct v4l2_ctrl *ctrl);
 +static int si476x_radio_g_volatile_ctrl(struct v4l2_ctrl *ctrl);
 +
 +static const char * const deemphasis[] = {
 +   75 us,
 +   50 us,
 +};
 +
 +enum phase_diversity_modes_idx {
 +   

[PATCH] staging/media/solo6x10/v4l2-enc.c: fix error-handling.

2012-11-16 Thread Cyril Roelandt
The return values of copy_to_user() and copy_from_user() cannot be negative.

Found using the following semantich patch:

spml
@exists@
identifier ret;
statement S;
expression E;
@@
(
* ret = copy_to_user(...);
|
* ret = copy_from_user(...);
)
... when != ret = E
when != if (ret) { +... ret = E; ...+ }
* if (ret  0)
  S
/spml

Signed-off-by: Cyril Roelandt tipec...@gmail.com
---
 drivers/staging/media/solo6x10/v4l2-enc.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/solo6x10/v4l2-enc.c 
b/drivers/staging/media/solo6x10/v4l2-enc.c
index f8f0da9..4977e86 100644
--- a/drivers/staging/media/solo6x10/v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/v4l2-enc.c
@@ -1619,6 +1619,8 @@ static int solo_s_ext_ctrls(struct file *file, void *priv,
solo_enc-osd_text[OSD_TEXT_MAX] = '\0';
if (!err)
err = solo_osd_print(solo_enc);
+   else
+   err = -EFAULT;
}
break;
default:
@@ -1654,6 +1656,8 @@ static int solo_g_ext_ctrls(struct file *file, void *priv,
err = copy_to_user(ctrl-string,
   solo_enc-osd_text,
   OSD_TEXT_MAX);
+   if (err)
+   err = -EFAULT;
}
break;
default:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RFC v3 1/3] V4L: Add driver for S3C244X/S3C64XX SoC series camera interface

2012-11-16 Thread Sylwester Nawrocki

Hi Alexey,

On 11/16/2012 03:10 PM, Alexey Klimov wrote:

+static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp
*vp)
+{
+   unsigned int ip_rev = camif-variant-ip_revision;
+   unsigned long flags;
+
+   if (camif-sensor.sd == NULL || vp-out_fmt == NULL)
+   return -EINVAL;
+
+   spin_lock_irqsave(camif-slock, flags);
+
+   if (ip_rev == S3C244X_CAMIF_IP_REV)
+   camif_hw_clear_fifo_overflow(vp);
+   camif_hw_set_camera_bus(camif);
+   camif_hw_set_source_format(camif);
+   camif_hw_set_camera_crop(camif);
+   camif_hw_set_test_pattern(camif, camif-test_pattern-val);
+   if (ip_rev == S3C6410_CAMIF_IP_REV)
+   camif_hw_set_input_path(vp);
+   camif_cfg_video_path(vp);
+   vp-state= ~ST_VP_CONFIG;
+
+   spin_unlock_irqrestore(camif-slock, flags);
+   return 0;
+}
+
+/*
+ * Initialize the video path, only up from the scaler stage. The camera
+ * input interface set up is skipped. This is useful to enable one of
the
+ * video paths when the other is already running.
+ */
+static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp
*vp)
+{
+   unsigned int ip_rev = camif-variant-ip_revision;
+   unsigned long flags;
+
+   if (vp-out_fmt == NULL)
+   return -EINVAL;
+
+   spin_lock_irqsave(camif-slock, flags);
+   camif_prepare_dma_offset(vp);
+   if (ip_rev == S3C244X_CAMIF_IP_REV)
+   camif_hw_clear_fifo_overflow(vp);
+   camif_cfg_video_path(vp);
+   if (ip_rev == S3C6410_CAMIF_IP_REV)
+   camif_hw_set_effect(vp, false);
+   vp-state= ~ST_VP_CONFIG;
+
+   spin_unlock_irqrestore(camif-slock, flags);
+   return 0;
+}

...

+/*
+ * Reinitialize the driver so it is ready to start streaming again.
+ * Return any buffers to vb2, perform CAMIF software reset and
+ * turn off streaming at the data pipeline (sensor) if required.
+ */
+static int camif_reinitialize(struct camif_vp *vp)
+{
+   struct camif_dev *camif = vp-camif;
+   struct camif_buffer *buf;
+   unsigned long flags;
+   bool streaming;
+
+   spin_lock_irqsave(camif-slock, flags);
+   streaming = vp-state  ST_VP_SENSOR_STREAMING;
+
+   vp-state= ~(ST_VP_PENDING | ST_VP_RUNNING | ST_VP_OFF |
+  ST_VP_ABORTING | ST_VP_STREAMING |
+  ST_VP_SENSOR_STREAMING | ST_VP_LASTIRQ);
+
+   /* Release unused buffers */
+   while (!list_empty(vp-pending_buf_q)) {
+   buf = camif_pending_queue_pop(vp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   while (!list_empty(vp-active_buf_q)) {
+   buf = camif_active_queue_pop(vp);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+
+   spin_unlock_irqrestore(camif-slock, flags);
+
+   if (!streaming)
+   return 0;
+
+   return sensor_set_streaming(camif, 0);
+}

...

+static int start_streaming(struct vb2_queue *vq, unsigned int count)
+{
+   struct camif_vp *vp = vb2_get_drv_priv(vq);
+   struct camif_dev *camif = vp-camif;
+   unsigned long flags;
+   int ret;
+
+   /*
+* We assume the codec capture path is always activated
+* first, before the preview path starts streaming.
+* This is required to avoid internal FIFO overflow and
+* a need for CAMIF software reset.
+*/
+   spin_lock_irqsave(camif-slock, flags);


Here.



+
+   if (camif-stream_count == 0) {
+   camif_hw_reset(camif);
+   spin_unlock_irqrestore(camif-slock, flags);
+   ret = s3c_camif_hw_init(camif, vp);
+   } else {
+   spin_unlock_irqrestore(camif-slock, flags);
+   ret = s3c_camif_hw_vp_init(camif, vp);
+   }
+
+   if (ret  0) {
+   camif_reinitialize(vp);
+   return ret;
+   }
+
+   spin_lock_irqsave(camif-slock, flags);


Could you please check this function? Is it ok that you have double
spin_lock_irqsave()? I don't know may be it's okay. Also when you call
camif_reinitialize() you didn't call spin_unlock_irqrestore() before and
inside camif_reinitialize() you will also call spin_lock_irqsave()..


Certainly with nested spinlock locking this code would have been useless.
I suppose this is what you mean by double spin_lock_irqsave(). Since
it is known to work there must be spin_unlock_irqrestore() somewhere,
before the second spin_lock_irqsave() above. Just look around with more
focus ;)

Nevertheless, it looks locking can be removed from functions
s3c_camif_hw_init() and s3c_camif_vp_init(), those are called only from
one place, where in addition the spinlock is already held. I'm going
to squash following patch into that one:

8--
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c 
b/drivers/media/platform/s3c-camif/camif-capture.c

index c2ecdcc..6401fdb 100644
---