Re: em28xx: Hauppauge HVR 900 on 3.18.0-rc3

2014-11-06 Thread Malcolm Priestley

On 06/11/14 06:51, Michal B wrote:

Hi,

analog TV on Hauppauge HVR 900 [2040:6500] - audio works correctly but
video stops after few samples, audio continues after video stop,

H Michal

Yep, pretty much the same for all 3.18 and rc3

One of my systems freezes the other no video.

All the drivers appear to be doing the same.

3.17.2 is fine.

It appears to be a video overlay problem, only start to panic if at rc6

Regards


Malcolm



tested:

mplayer tv:// -tv
norm=PAL-BG:freq=687.5:input=0:device=/dev/video0:alsa:amode=1:adevice=hw.2,0:audiorate=48000:forceaudio:immediatemode=0
-hardframedrop -ao alsa -vo x11

mplayer output:
MPlayer svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv://.
TV file format detected.
Selected driver: v4l2
  name: Video 4 Linux 2 input
  author: Martin Olschewski olschew...@zpr.uni-koeln.de
  comment: first try, more to come ;-)
Selected device: Hauppauge WinTV HVR 900
  Tuner cap:
  Tuner rxs:
  Capabilities:  video capture  VBI capture device  tuner  audio
read/write  streaming
  supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR;
4 = NTSC-443; 5 = PAL; 6 = PAL-BG; 7 = PAL-H; 8 = PAL-I; 9 = PAL-DK;
10 = PAL-M; 11 = PAL-N; 12 = PAL-Nc; 13 = PAL-60; 14 = SECAM; 15 =
SECAM-B; 16 = SECAM-G; 17 = SECAM-H; 18 = SECAM-DK; 19 = SECAM-L; 20 =
SECAM-Lc;
  inputs: 0 = Television; 1 = Composite1; 2 = S-Video;
  Current input: 0
  Current format: YUYV
v4l2: current audio mode is : STEREO
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
==
Opening video decoder: [raw] RAW Uncompressed Video
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0x13c7d40] BICUBIC scaler, from yuyv422 to bgra using MMX2
VO: [x11] 720x576 = 720x576 BGRA
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==
==
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000-192000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
A:   3.1 V:   1.6 A-V:  1.447 ct:  0.165  92/ 92  0%  8% 28.8% 50 0



 Your system is too SLOW to play this!  


Possible reasons, problems, workarounds:
- Most common: broken/buggy _audio_ driver
   - Try -ao sdl or use the OSS emulation of ALSA.
   - Experiment with different values for -autosync, 30 is a good start.
- Slow video output
   - Try a different -vo driver (-vo help for a list) or try -framedrop!
- Slow CPU
   - Don't try to play a big DVD/DivX on a slow CPU! Try some of the lavdopts,
 e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.
- Broken file
   - Try various combinations of -nobps -ni -forceidx -mc 0.
- Slow media (NFS/SMB mounts, DVD, VCD etc)
   - Try -cache 8192.
- Are you using -cache to play a non-interleaved AVI file?
   - Try -nocache.
Read DOCS/HTML/en/video.html for tuning/speedup tips.
If none of this helps you, read DOCS/HTML/en/bugreports.html.

A:  11.7 V:   5.1 A-V:  6.636 ct:  0.250 308/308  0%  2% 12.9% 266 0
v4l2: 310 frames successfully processed, 0 frames dropped.


kernel output:
[  427.441405] usb 3-13.5.5: new high-speed USB device number 9 using xhci_hcd
[  427.534116] usb 3-13.5.5: New USB device found, idVendor=2040, idProduct=6500
[  427.534126] usb 3-13.5.5: New USB device strings: Mfr=0, Product=1,
SerialNumber=2
[  427.534131] usb 3-13.5.5: Product: WinTV HVR-900
[  427.534136] usb 3-13.5.5: SerialNumber: 4026875858
[  427.586621] media: Linux media interface: v0.10
[  427.625926] Linux video capture interface: v2.00
[  427.669943] em28xx: New device  WinTV HVR-900 @ 480 Mbps
(2040:6500, interface 0, class 0)
[  427.669945] em28xx: Video interface 0 found: isoc
[  427.669946] em28xx: DVB interface 0 found: isoc
[  427.669973] em28xx: chip ID is em2882/3
[  427.838493] em2882/3 #0: EEPROM ID = 1a eb 67 95, EEPROM hash = 0x43a734dd
[  427.838499] em2882/3 #0: EEPROM info:
[  427.838503] em2882/3 #0: AC97 audio (5 sample rates)
[  427.838506] em2882/3 #0: 500mA max power
[  427.838510] em2882/3 #0: Table at offset 0x24, strings=0x1e82,
0x186a, 0x
[  427.838515] em2882/3 #0: Identified as Hauppauge WinTV HVR 900 (card=10)
[  427.840708] tveeprom 7-0050: 

Hello

2014-11-06 Thread mohdafattah1964...@hotmail.com


Did you receive my email?
--
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: v4l2-ctl bug(?) printing ctrl payload array

2014-11-06 Thread Hans Verkuil
On 11/05/14 20:52, Andrey Utkin wrote:
 More on the same topic.
 I believe there's another bug on displaying of payload.
 Let's say we have the same [45][45] array, and this is what is posted to it:
 uint16_t buf[45 * 45] = {0, };
 buf[0] = 1;
 buf[1] = 2;
 buf[45] = 3;
 buf[45 * 45 - 1] = 0xff;
 
 What is shown by v4l2-ctl you can see here:
 https://dl.dropboxusercontent.com/u/43104344/v4l2-ctl_payload_bug.png
 

I'll look at this Friday or Monday.

I want to add some test array controls to the vivid driver as well to make
it easier to test such controls, so that will be a good test case.

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


[PATCH v2 04/10] [media] i2c: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definitions to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definitions in i2c drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/i2c/adv7170.c   | 16 +++
 drivers/media/i2c/adv7175.c   | 16 +++
 drivers/media/i2c/adv7180.c   |  6 +--
 drivers/media/i2c/adv7183.c   |  6 +--
 drivers/media/i2c/adv7604.c   | 72 +++
 drivers/media/i2c/adv7842.c   |  6 +--
 drivers/media/i2c/ak881x.c|  8 ++--
 drivers/media/i2c/cx25840/cx25840-core.c  |  2 +-
 drivers/media/i2c/m5mols/m5mols_core.c|  6 +--
 drivers/media/i2c/ml86v7667.c |  6 +--
 drivers/media/i2c/mt9m032.c   |  6 +--
 drivers/media/i2c/mt9p031.c   |  8 ++--
 drivers/media/i2c/mt9t001.c   |  8 ++--
 drivers/media/i2c/mt9v011.c   |  6 +--
 drivers/media/i2c/mt9v032.c   | 12 +++---
 drivers/media/i2c/noon010pc30.c   | 12 +++---
 drivers/media/i2c/ov7670.c| 16 +++
 drivers/media/i2c/ov9650.c| 10 ++---
 drivers/media/i2c/s5c73m3/s5c73m3.h   |  6 +--
 drivers/media/i2c/s5k4ecgx.c  |  4 +-
 drivers/media/i2c/s5k5baf.c   | 14 +++---
 drivers/media/i2c/s5k6a3.c|  2 +-
 drivers/media/i2c/s5k6aa.c|  8 ++--
 drivers/media/i2c/saa6752hs.c |  6 +--
 drivers/media/i2c/saa7115.c   |  2 +-
 drivers/media/i2c/saa717x.c   |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c| 32 +++---
 drivers/media/i2c/soc_camera/imx074.c |  8 ++--
 drivers/media/i2c/soc_camera/mt9m001.c| 14 +++---
 drivers/media/i2c/soc_camera/mt9m111.c| 70 +++---
 drivers/media/i2c/soc_camera/mt9t031.c| 10 ++---
 drivers/media/i2c/soc_camera/mt9t112.c| 22 +-
 drivers/media/i2c/soc_camera/mt9v022.c| 26 +--
 drivers/media/i2c/soc_camera/ov2640.c | 54 +++
 drivers/media/i2c/soc_camera/ov5642.c |  8 ++--
 drivers/media/i2c/soc_camera/ov6650.c | 58 -
 drivers/media/i2c/soc_camera/ov772x.c | 20 -
 drivers/media/i2c/soc_camera/ov9640.c | 40 -
 drivers/media/i2c/soc_camera/ov9740.c | 12 +++---
 drivers/media/i2c/soc_camera/rj54n1cb0c.c | 54 +++
 drivers/media/i2c/soc_camera/tw9910.c | 10 ++---
 drivers/media/i2c/sr030pc30.c | 14 +++---
 drivers/media/i2c/tvp514x.c   | 12 +++---
 drivers/media/i2c/tvp5150.c   |  6 +--
 drivers/media/i2c/tvp7002.c   | 10 ++---
 drivers/media/i2c/vs6624.c| 18 
 46 files changed, 382 insertions(+), 382 deletions(-)

diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c
index 04bb297..0f6c852 100644
--- a/drivers/media/i2c/adv7170.c
+++ b/drivers/media/i2c/adv7170.c
@@ -63,9 +63,9 @@ static inline struct adv7170 *to_adv7170(struct v4l2_subdev 
*sd)
 
 static char *inputs[] = { pass_through, play_back };
 
-static enum v4l2_mbus_pixelcode adv7170_codes[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_UYVY8_1X16,
+static enum media_bus_format adv7170_codes[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_1X16,
 };
 
 /* --- */
@@ -263,7 +263,7 @@ static int adv7170_s_routing(struct v4l2_subdev *sd,
 }
 
 static int adv7170_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-   enum v4l2_mbus_pixelcode *code)
+   enum media_bus_format *code)
 {
if (index = ARRAY_SIZE(adv7170_codes))
return -EINVAL;
@@ -278,9 +278,9 @@ static int adv7170_g_fmt(struct v4l2_subdev *sd,
u8 val = adv7170_read(sd, 0x7);
 
if ((val  0x40) == (1  6))
-   mf-code = V4L2_MBUS_FMT_UYVY8_1X16;
+   mf-code = MEDIA_BUS_FMT_UYVY8_1X16;
else
-   mf-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   mf-code = MEDIA_BUS_FMT_UYVY8_2X8;
 
mf-colorspace  = V4L2_COLORSPACE_SMPTE170M;
mf-width   = 0;
@@ -297,11 +297,11 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
int ret;
 
switch (mf-code) {
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
val = ~0x40;
break;
 
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
val |= 0x40;
break;
 
diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c
index b88f3b3..3a7c461 100644
--- a/drivers/media/i2c/adv7175.c
+++ b/drivers/media/i2c/adv7175.c
@@ -60,9 

[PATCH v2 07/10] [media] usb: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all usb drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++--
 drivers/media/usb/em28xx/em28xx-camera.c  | 2 +-
 drivers/media/usb/go7007/go7007-v4l2.c| 2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c   | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 459bb0e..95653ba 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1878,7 +1878,7 @@ static int cx231xx_s_video_encoding(struct 
cx2341x_handler *cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(dev-sd_cx25840, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index 3b3ada6..989d527 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -967,7 +967,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-height = f-fmt.pix.height;
dev-format = fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
 
@@ -1012,7 +1012,7 @@ static int vidioc_s_std(struct file *file, void *priv, 
v4l2_std_id norm)
   resolution (since a standard change effects things like the number
   of lines in VACT, etc) */
memset(mbus_fmt, 0, sizeof(mbus_fmt));
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = dev-width;
mbus_fmt.height = dev-height;
call_all(dev, video, s_mbus_fmt, mbus_fmt);
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
b/drivers/media/usb/em28xx/em28xx-camera.c
index 6d2ea9a..38cf6c8 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -430,7 +430,7 @@ int em28xx_init_camera(struct em28xx *dev)
break;
}
 
-   fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
+   fmt.code = MEDIA_BUS_FMT_YUYV8_2X8;
fmt.width = 640;
fmt.height = 480;
v4l2_subdev_call(subdev, video, s_mbus_fmt, fmt);
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c 
b/drivers/media/usb/go7007/go7007-v4l2.c
index ec799b4..d6bf982 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -252,7 +252,7 @@ static int set_capture_size(struct go7007 *go, struct 
v4l2_format *fmt, int try)
if (go-board_info-sensor_flags  GO7007_SENSOR_SCALING) {
struct v4l2_mbus_framefmt mbus_fmt;
 
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
mbus_fmt.width = fmt ? fmt-fmt.pix.width : width;
mbus_fmt.height = height;
go-encoder_h_halve = 0;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 9623b62..2fd9b5e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2966,7 +2966,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
memset(fmt, 0, sizeof(fmt));
fmt.width = hdw-res_hor_val;
fmt.height = hdw-res_ver_val;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
pvr2_trace(PVR2_TRACE_CHIPS, subdev v4l2 set_size(%dx%d),
   fmt.width, fmt.height);
v4l2_device_call_all(hdw-v4l2_dev, 0, video, s_mbus_fmt, 
fmt);
-- 
1.9.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 08/10] staging: media: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all media drivers residing in staging.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  18 ++--
 .../staging/media/davinci_vpfe/dm365_ipipe_hw.c|  26 +++---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 100 ++---
 drivers/staging/media/davinci_vpfe/dm365_isif.c|  90 +--
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  96 ++--
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  18 ++--
 drivers/staging/media/omap4iss/iss_csi2.c  |  62 ++---
 drivers/staging/media/omap4iss/iss_ipipe.c |  16 ++--
 drivers/staging/media/omap4iss/iss_ipipeif.c   |  28 +++---
 drivers/staging/media/omap4iss/iss_resizer.c   |  26 +++---
 drivers/staging/media/omap4iss/iss_video.c |  78 
 drivers/staging/media/omap4iss/iss_video.h |  10 +--
 12 files changed, 284 insertions(+), 284 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index bdc7f00..704fa20 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -37,15 +37,15 @@
 
 /* ipipe input format's */
 static const unsigned int ipipe_input_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
-   V4L2_MBUS_FMT_SGRBG12_1X12,
-   V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
-   V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
+   MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
 };
 
 /* ipipe output format's */
 static const unsigned int ipipe_output_fmts[] = {
-   V4L2_MBUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_UYVY8_2X8,
 };
 
 static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
@@ -1457,7 +1457,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use SBGGR10 as default */
if (i = ARRAY_SIZE(ipipe_input_fmts))
-   fmt-code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   fmt-code = MEDIA_BUS_FMT_SGRBG12_1X12;
} else if (pad == IPIPE_PAD_SOURCE) {
for (i = 0; i  ARRAY_SIZE(ipipe_output_fmts); i++)
if (fmt-code == ipipe_output_fmts[i])
@@ -1465,7 +1465,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
 
/* If not found, use UYVY as default */
if (i = ARRAY_SIZE(ipipe_output_fmts))
-   fmt-code = V4L2_MBUS_FMT_UYVY8_2X8;
+   fmt-code = MEDIA_BUS_FMT_UYVY8_2X8;
}
 
fmt-width = clamp_t(u32, fmt-width, MIN_OUT_HEIGHT, max_out_width);
@@ -1642,7 +1642,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SINK;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
+   format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
@@ -1650,7 +1650,7 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
memset(format, 0, sizeof(format));
format.pad = IPIPE_PAD_SOURCE;
format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
-   format.format.code = V4L2_MBUS_FMT_UYVY8_2X8;
+   format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
ipipe_set_format(sd, fh, format);
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index b2daf5e..4a0895b2 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -196,12 +196,12 @@ ipipe_setup_resizer(void *__iomem rsz_base, struct 
resizer_params *params)
rsz_set_rsz_regs(rsz_base, RSZ_B, params);
 }
 
-static u32 ipipe_get_color_pat(enum v4l2_mbus_pixelcode pix)
+static u32 ipipe_get_color_pat(enum media_bus_format pix)
 {
switch (pix) {
-   case V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG12_1X12:
+   case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG12_1X12:
return ipipe_sgrbg_pattern;
 
default:
@@ -211,23 +211,23 @@ static u32 

[PATCH v2 05/10] [media] pci: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Replace all references to the old definition in pci drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/media/pci/cx18/cx18-av-core.c   | 2 +-
 drivers/media/pci/cx18/cx18-controls.c  | 2 +-
 drivers/media/pci/cx18/cx18-ioctl.c | 2 +-
 drivers/media/pci/cx23885/cx23885-video.c   | 2 +-
 drivers/media/pci/ivtv/ivtv-controls.c  | 2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c | 2 +-
 drivers/media/pci/saa7134/saa7134-empress.c | 4 ++--
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-av-core.c 
b/drivers/media/pci/cx18/cx18-av-core.c
index 2d3afe0..4c6ce21 100644
--- a/drivers/media/pci/cx18/cx18-av-core.c
+++ b/drivers/media/pci/cx18/cx18-av-core.c
@@ -952,7 +952,7 @@ static int cx18_av_s_mbus_fmt(struct v4l2_subdev *sd, 
struct v4l2_mbus_framefmt
int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
int is_50Hz = !(state-std  V4L2_STD_525_60);
 
-   if (fmt-code != V4L2_MBUS_FMT_FIXED)
+   if (fmt-code != MEDIA_BUS_FMT_FIXED)
return -EINVAL;
 
fmt-field = V4L2_FIELD_INTERLACED;
diff --git a/drivers/media/pci/cx18/cx18-controls.c 
b/drivers/media/pci/cx18/cx18-controls.c
index 282a3d2..4aeb7c6 100644
--- a/drivers/media/pci/cx18/cx18-controls.c
+++ b/drivers/media/pci/cx18/cx18-controls.c
@@ -98,7 +98,7 @@ static int cx18_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index 6f2b590..71963db 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -294,7 +294,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
 
mbus_fmt.width = cx-cxhdl.width = w;
mbus_fmt.height = cx-cxhdl.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx-sd_av, video, s_mbus_fmt, mbus_fmt);
return cx18_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f9..091f5db 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -608,7 +608,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void 
*priv,
dev-field  = f-fmt.pix.field;
dprintk(2, %s() width=%d height=%d field=%d\n, __func__,
dev-width, dev-height, dev-field);
-   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, V4L2_MBUS_FMT_FIXED);
+   v4l2_fill_mbus_format(mbus_fmt, f-fmt.pix, MEDIA_BUS_FMT_FIXED);
call_all(dev, video, s_mbus_fmt, mbus_fmt);
v4l2_fill_pix_format(f-fmt.pix, mbus_fmt);
/* s_mbus_fmt overwrites f-fmt.pix.field, restore it */
diff --git a/drivers/media/pci/ivtv/ivtv-controls.c 
b/drivers/media/pci/ivtv/ivtv-controls.c
index 2b0ab26..ccf548c 100644
--- a/drivers/media/pci/ivtv/ivtv-controls.c
+++ b/drivers/media/pci/ivtv/ivtv-controls.c
@@ -69,7 +69,7 @@ static int ivtv_s_video_encoding(struct cx2341x_handler 
*cxhdl, u32 val)
/* fix videodecoder resolution */
fmt.width = cxhdl-width / (is_mpeg1 ? 2 : 1);
fmt.height = cxhdl-height;
-   fmt.code = V4L2_MBUS_FMT_FIXED;
+   fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, fmt);
return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3e0cb77..4d8ee18 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -595,7 +595,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, 
struct v4l2_format *f
fmt-fmt.pix.width /= 2;
mbus_fmt.width = fmt-fmt.pix.width;
mbus_fmt.height = h;
-   mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
+   mbus_fmt.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(itv-sd_video, video, s_mbus_fmt, mbus_fmt);
return ivtv_g_fmt_vid_cap(file, fh, fmt);
 }
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c 
b/drivers/media/pci/saa7134/saa7134-empress.c
index e4ea85f..8b3bb78 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -140,7 +140,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void 
*priv,
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_mbus_framefmt mbus_fmt;
 
-   v4l2_fill_mbus_format(mbus_fmt, 

[PATCH v2 00/10] [media] Make mediabus format subsystem neutral

2014-11-06 Thread Boris Brezillon
Hello,

This patch series prepares the use of media bus formats outside of
the V4L2 subsytem (my final goal is to use it in the Atmel HLCDC DRM
driver where I have to configure my DPI/RGB bus according to the
connected display).

The series first defines a new enum with a neutral name (media_bus_format),
and then replace all references to the old enum and its values within the
kernel.

Best Regards,

Boris

Changes since v1:
- drop patches deprecating v4l2_mbus_pixelcode for user-space users
- put V4L2 legacy format definitions into media-bus-format.h

Boris Brezillon (10):
  [media] Move mediabus format definition to a more standard place
  [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values
  [media] Make use of the new media_bus_format definitions
  [media] i2c: Make use of media_bus_format enum
  [media] pci: Make use of media_bus_format enum
  [media] platform: Make use of media_bus_format enum
  [media] usb: Make use of media_bus_format enum
  staging: media: Make use of media_bus_format enum
  gpu: ipu-v3: Make use of media_bus_format enum
  [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the
kernel

 Documentation/DocBook/media/Makefile   |   2 +-
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   6 +-
 arch/arm/mach-davinci/dm365.c  |   6 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/gpu/ipu-v3/ipu-csi.c   |  66 ++---
 drivers/media/i2c/adv7170.c|  16 +-
 drivers/media/i2c/adv7175.c|  16 +-
 drivers/media/i2c/adv7180.c|   6 +-
 drivers/media/i2c/adv7183.c|   6 +-
 drivers/media/i2c/adv7604.c|  72 ++---
 drivers/media/i2c/adv7842.c|   6 +-
 drivers/media/i2c/ak881x.c |   8 +-
 drivers/media/i2c/cx25840/cx25840-core.c   |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c |   6 +-
 drivers/media/i2c/ml86v7667.c  |   6 +-
 drivers/media/i2c/mt9m032.c|   6 +-
 drivers/media/i2c/mt9p031.c|   8 +-
 drivers/media/i2c/mt9t001.c|   8 +-
 drivers/media/i2c/mt9v011.c|   6 +-
 drivers/media/i2c/mt9v032.c|  12 +-
 drivers/media/i2c/noon010pc30.c|  12 +-
 drivers/media/i2c/ov7670.c |  16 +-
 drivers/media/i2c/ov9650.c |  10 +-
 drivers/media/i2c/s5c73m3/s5c73m3.h|   6 +-
 drivers/media/i2c/s5k4ecgx.c   |   4 +-
 drivers/media/i2c/s5k5baf.c|  14 +-
 drivers/media/i2c/s5k6a3.c |   2 +-
 drivers/media/i2c/s5k6aa.c |   8 +-
 drivers/media/i2c/saa6752hs.c  |   6 +-
 drivers/media/i2c/saa7115.c|   2 +-
 drivers/media/i2c/saa717x.c|   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c |  32 +--
 drivers/media/i2c/soc_camera/imx074.c  |   8 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  14 +-
 drivers/media/i2c/soc_camera/mt9m111.c |  70 ++---
 drivers/media/i2c/soc_camera/mt9t031.c |  10 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  22 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  26 +-
 drivers/media/i2c/soc_camera/ov2640.c  |  54 ++--
 drivers/media/i2c/soc_camera/ov5642.c  |   8 +-
 drivers/media/i2c/soc_camera/ov6650.c  |  58 ++--
 drivers/media/i2c/soc_camera/ov772x.c  |  20 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  40 +--
 drivers/media/i2c/soc_camera/ov9740.c  |  12 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  54 ++--
 drivers/media/i2c/soc_camera/tw9910.c  |  10 +-
 drivers/media/i2c/sr030pc30.c  |  14 +-
 drivers/media/i2c/tvp514x.c|  12 +-
 drivers/media/i2c/tvp5150.c|   6 +-
 drivers/media/i2c/tvp7002.c|  10 +-
 drivers/media/i2c/vs6624.c |  18 +-
 drivers/media/pci/cx18/cx18-av-core.c  |   2 +-
 drivers/media/pci/cx18/cx18-controls.c |   2 +-
 drivers/media/pci/cx18/cx18-ioctl.c|   2 +-
 drivers/media/pci/cx23885/cx23885-video.c  |   2 +-
 drivers/media/pci/ivtv/ivtv-controls.c |   2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c|   2 +-
 

[PATCH v2 06/10] [media] platform: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in all platform drivers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/video4linux/soc-camera.txt   |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c|   4 +-
 arch/arm/mach-davinci/dm355.c  |   6 +-
 arch/arm/mach-davinci/dm365.c  |   6 +-
 arch/arm/mach-shmobile/board-mackerel.c|   2 +-
 arch/sh/boards/mach-ap325rxa/setup.c   |   2 +-
 drivers/media/platform/blackfin/bfin_capture.c |  14 +--
 drivers/media/platform/davinci/vpbe.c  |   2 +-
 drivers/media/platform/davinci/vpfe_capture.c  |   4 +-
 drivers/media/platform/exynos-gsc/gsc-core.c   |   8 +-
 drivers/media/platform/exynos-gsc/gsc-core.h   |   2 +-
 drivers/media/platform/exynos4-is/fimc-capture.c   |   2 +-
 drivers/media/platform/exynos4-is/fimc-core.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-core.h  |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp.c   |  16 +--
 drivers/media/platform/exynos4-is/fimc-lite-reg.c  |  26 ++---
 drivers/media/platform/exynos4-is/fimc-lite.c  |  14 +--
 drivers/media/platform/exynos4-is/fimc-reg.c   |  14 +--
 drivers/media/platform/exynos4-is/mipi-csis.c  |  14 +--
 drivers/media/platform/marvell-ccic/mcam-core.c|  22 ++--
 drivers/media/platform/marvell-ccic/mcam-core.h|   2 +-
 drivers/media/platform/omap3isp/ispccdc.c  | 112 ++---
 drivers/media/platform/omap3isp/ispccp2.c  |  18 ++--
 drivers/media/platform/omap3isp/ispcsi2.c  |  42 
 drivers/media/platform/omap3isp/isppreview.c   |  58 +--
 drivers/media/platform/omap3isp/ispresizer.c   |  18 ++--
 drivers/media/platform/omap3isp/ispvideo.c |  94 -
 drivers/media/platform/omap3isp/ispvideo.h |  10 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |  10 +-
 drivers/media/platform/s3c-camif/camif-regs.c  |   8 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c   |   2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c|   2 +-
 drivers/media/platform/sh_vou.c|   8 +-
 drivers/media/platform/soc_camera/atmel-isi.c  |  22 ++--
 drivers/media/platform/soc_camera/mx2_camera.c |  24 ++---
 drivers/media/platform/soc_camera/mx3_camera.c |   6 +-
 drivers/media/platform/soc_camera/omap1_camera.c   |  36 +++
 drivers/media/platform/soc_camera/pxa_camera.c |  16 +--
 drivers/media/platform/soc_camera/rcar_vin.c   |  14 +--
 .../platform/soc_camera/sh_mobile_ceu_camera.c |  20 ++--
 drivers/media/platform/soc_camera/sh_mobile_csi2.c |  38 +++
 drivers/media/platform/soc_camera/soc_camera.c |   2 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |  78 +++---
 drivers/media/platform/via-camera.c|   8 +-
 drivers/media/platform/vsp1/vsp1_bru.c |  14 +--
 drivers/media/platform/vsp1/vsp1_hsit.c|  12 +--
 drivers/media/platform/vsp1/vsp1_lif.c |  10 +-
 drivers/media/platform/vsp1/vsp1_lut.c |  14 +--
 drivers/media/platform/vsp1/vsp1_rwpf.c|  10 +-
 drivers/media/platform/vsp1/vsp1_sru.c |  12 +--
 drivers/media/platform/vsp1/vsp1_uds.c |  10 +-
 drivers/media/platform/vsp1/vsp1_video.c   |  42 
 include/media/davinci/vpbe.h   |   2 +-
 include/media/davinci/vpbe_venc.h  |   4 +-
 include/media/exynos-fimc.h|   2 +-
 include/media/soc_camera.h |   2 +-
 include/media/soc_mediabus.h   |   6 +-
 59 files changed, 485 insertions(+), 485 deletions(-)

diff --git a/Documentation/video4linux/soc-camera.txt 
b/Documentation/video4linux/soc-camera.txt
index daa9e2a..84f41cf 100644
--- a/Documentation/video4linux/soc-camera.txt
+++ b/Documentation/video4linux/soc-camera.txt
@@ -151,7 +151,7 @@ they are transferred over a media bus. Soc-camera provides 
support to
 conveniently manage these formats. A table of standard transformations is
 maintained by soc-camera core, which describes, what FOURCC pixel format will
 be obtained, if a media-bus pixel format is stored in memory according to
-certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
+certain rules. E.g. if MEDIA_BUS_FMT_YUYV8_2X8 data is sampled with 8 bits per
 sample and stored in memory in the little-endian order with no gaps between
 bytes, data in memory will represent the V4L2_PIX_FMT_YUYV FOURCC format. These
 standard transformations will be used by 

[PATCH v2 10/10] [media] v4l: Forbid usage of V4L2_MBUS_FMT definitions inside the kernel

2014-11-06 Thread Boris Brezillon
Place v4l2_mbus_pixelcode in a #ifndef __KERNEL__ section so that kernel
users don't have access to these definitions.

We have to keep this definition for user-space users even though they're
encouraged to move to the new media_bus_format enum.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 include/uapi/linux/media-bus-format.h | 5 +
 include/uapi/linux/v4l2-mediabus.h| 2 ++
 2 files changed, 7 insertions(+)

diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
index 251a902..d7f9ea2 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -31,9 +31,14 @@
  * new pixel codes.
  */
 
+#ifdef __KERNEL__
+#define MEDIA_BUS_FMT_ENTRY(name, val) MEDIA_BUS_FMT_ ## name = val
+#else
+/* Keep V4L2_MBUS_FMT for backwards compatibility */
 #define MEDIA_BUS_FMT_ENTRY(name, val) \
MEDIA_BUS_FMT_ ## name = val,   \
V4L2_MBUS_FMT_ ## name = val
+#endif
 
 enum media_bus_format {
MEDIA_BUS_FMT_ENTRY(FIXED, 0x0001),
diff --git a/include/uapi/linux/v4l2-mediabus.h 
b/include/uapi/linux/v4l2-mediabus.h
index d30526c..8759002 100644
--- a/include/uapi/linux/v4l2-mediabus.h
+++ b/include/uapi/linux/v4l2-mediabus.h
@@ -15,7 +15,9 @@
 #include linux/videodev2.h
 #include linux/media-bus-format.h
 
+#ifndef __KERNEL__
 #define v4l2_mbus_pixelcode media_bus_format
+#endif
 
 /**
  * struct v4l2_mbus_framefmt - frame format on the media bus
-- 
1.9.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/10] gpu: ipu-v3: Make use of media_bus_format enum

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Reference new definitions in the ipu-v3 driver.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/gpu/ipu-v3/ipu-csi.c | 66 ++--
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index d6f56471..752cdd2 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -227,83 +227,83 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, 
u32 pixel_clk,
 static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 {
switch (mbus_code) {
-   case V4L2_MBUS_FMT_BGR565_2X8_BE:
-   case V4L2_MBUS_FMT_BGR565_2X8_LE:
-   case V4L2_MBUS_FMT_RGB565_2X8_BE:
-   case V4L2_MBUS_FMT_RGB565_2X8_LE:
+   case MEDIA_BUS_FMT_BGR565_2X8_BE:
+   case MEDIA_BUS_FMT_BGR565_2X8_LE:
+   case MEDIA_BUS_FMT_RGB565_2X8_BE:
+   case MEDIA_BUS_FMT_RGB565_2X8_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
cfg-mipi_dt = MIPI_DT_RGB565;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB444;
cfg-mipi_dt = MIPI_DT_RGB444;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_RGB555;
cfg-mipi_dt = MIPI_DT_RGB555;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_2X8:
+   case MEDIA_BUS_FMT_UYVY8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_YUYV8_2X8:
+   case MEDIA_BUS_FMT_YUYV8_2X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_UYVY8_1X16:
+   case MEDIA_BUS_FMT_UYVY8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_YUYV8_1X16:
+   case MEDIA_BUS_FMT_YUYV8_1X16:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_YUYV;
cfg-mipi_dt = MIPI_DT_YUV422;
cfg-data_width = IPU_CSI_DATA_WIDTH_16;
break;
-   case V4L2_MBUS_FMT_SBGGR8_1X8:
-   case V4L2_MBUS_FMT_SGBRG8_1X8:
-   case V4L2_MBUS_FMT_SGRBG8_1X8:
-   case V4L2_MBUS_FMT_SRGGB8_1X8:
+   case MEDIA_BUS_FMT_SBGGR8_1X8:
+   case MEDIA_BUS_FMT_SGBRG8_1X8:
+   case MEDIA_BUS_FMT_SGRBG8_1X8:
+   case MEDIA_BUS_FMT_SRGGB8_1X8:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW8;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
-   case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+   case MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE:
+   case MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE:
cfg-data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
cfg-mipi_dt = MIPI_DT_RAW10;
cfg-data_width = IPU_CSI_DATA_WIDTH_8;
break;
-   case V4L2_MBUS_FMT_SBGGR10_1X10:
-   case V4L2_MBUS_FMT_SGBRG10_1X10:
-   case V4L2_MBUS_FMT_SGRBG10_1X10:
-   case V4L2_MBUS_FMT_SRGGB10_1X10:
+   case MEDIA_BUS_FMT_SBGGR10_1X10:
+   case MEDIA_BUS_FMT_SGBRG10_1X10:
+   case MEDIA_BUS_FMT_SGRBG10_1X10:
+   case MEDIA_BUS_FMT_SRGGB10_1X10:
cfg-data_fmt = 

[PATCH v2 03/10] [media] Make use of the new media_bus_format definitions

2014-11-06 Thread Boris Brezillon
Replace references to the v4l2_mbus_pixelcode enum with the new
media_bus_format enum in all common headers.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 include/media/v4l2-mediabus.h| 2 +-
 include/media/v4l2-subdev.h  | 2 +-
 include/uapi/linux/v4l2-subdev.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 395c4a9..4915621 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -98,7 +98,7 @@ static inline void v4l2_fill_pix_format(struct 
v4l2_pix_format *pix_fmt,
 
 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
   const struct v4l2_pix_format *pix_fmt,
-  enum v4l2_mbus_pixelcode code)
+  enum media_bus_format code)
 {
mbus_fmt-width = pix_fmt-width;
mbus_fmt-height = pix_fmt-height;
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d746572..9af5932 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -341,7 +341,7 @@ struct v4l2_subdev_video_ops {
int (*query_dv_timings)(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings);
int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
-enum v4l2_mbus_pixelcode *code);
+enum media_bus_format *code);
int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
 struct v4l2_frmsizeenum *fsize);
int (*g_mbus_fmt)(struct v4l2_subdev *sd,
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a619cdd..7f44f04 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -68,7 +68,7 @@ struct v4l2_subdev_crop {
  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  */
 struct v4l2_subdev_mbus_code_enum {
__u32 pad;
@@ -81,7 +81,7 @@ struct v4l2_subdev_mbus_code_enum {
  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
  * @pad: pad number, as reported by the media API
  * @index: format index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  */
 struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -109,7 +109,7 @@ struct v4l2_subdev_frame_interval {
  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
  * @pad: pad number, as reported by the media API
  * @index: frame interval index during enumeration
- * @code: format code (from enum v4l2_mbus_pixelcode)
+ * @code: format code (from enum media_bus_format)
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
-- 
1.9.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 01/10] [media] Move mediabus format definition to a more standard place

2014-11-06 Thread Boris Brezillon
Rename mediabus formats and move the enum into a separate header file so
that it can be used by DRM/KMS subsystem without any reference to the V4L2
subsystem.

Old v4l2_mbus_pixelcode now points to media_bus_format.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de
---
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/media-bus-format.h | 131 ++
 include/uapi/linux/v4l2-mediabus.h| 114 +
 3 files changed, 134 insertions(+), 112 deletions(-)
 create mode 100644 include/uapi/linux/media-bus-format.h

diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e..b2c23f8 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -414,6 +414,7 @@ header-y += veth.h
 header-y += vfio.h
 header-y += vhost.h
 header-y += videodev2.h
+header-y += media-bus-format.h
 header-y += virtio_9p.h
 header-y += virtio_balloon.h
 header-y += virtio_blk.h
diff --git a/include/uapi/linux/media-bus-format.h 
b/include/uapi/linux/media-bus-format.h
new file mode 100644
index 000..251a902
--- /dev/null
+++ b/include/uapi/linux/media-bus-format.h
@@ -0,0 +1,131 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski g.liakhovet...@gmx.de
+ *
+ * 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.
+ */
+
+#ifndef __LINUX_MEDIA_BUS_FORMAT_H
+#define __LINUX_MEDIA_BUS_FORMAT_H
+
+/*
+ * These bus formats uniquely identify data formats on the data bus. Format 0
+ * is reserved, MEDIA_BUS_FMT_FIXED shall be used by host-client pairs, where
+ * the data format is fixed. Additionally, 2X8 means that one pixel is
+ * transferred in two 8-bit samples, BE or LE specify in which order those
+ * samples are transferred over the bus: LE means that the least significant
+ * bits are transferred first, BE means that the most significant bits are
+ * transferred first, and PADHI and PADLO define which bits - low or high,
+ * in the incomplete high byte, are filled with padding bits.
+ *
+ * The bus formats are grouped by type, bus_width, bits per component, samples
+ * per pixel and order of subsamples. Numerical values are sorted using generic
+ * numerical sort order (8 thus comes before 10).
+ *
+ * As their value can't change when a new bus format is inserted in the
+ * enumeration, the bus formats are explicitly given a numerical value. The 
next
+ * free values for each category are listed below, update them when inserting
+ * new pixel codes.
+ */
+
+#define MEDIA_BUS_FMT_ENTRY(name, val) \
+   MEDIA_BUS_FMT_ ## name = val,   \
+   V4L2_MBUS_FMT_ ## name = val
+
+enum media_bus_format {
+   MEDIA_BUS_FMT_ENTRY(FIXED, 0x0001),
+
+   /* RGB - next is 0x100e */
+   MEDIA_BUS_FMT_ENTRY(RGB444_2X8_PADHI_BE, 0x1001),
+   MEDIA_BUS_FMT_ENTRY(RGB444_2X8_PADHI_LE, 0x1002),
+   MEDIA_BUS_FMT_ENTRY(RGB555_2X8_PADHI_BE, 0x1003),
+   MEDIA_BUS_FMT_ENTRY(RGB555_2X8_PADHI_LE, 0x1004),
+   MEDIA_BUS_FMT_ENTRY(BGR565_2X8_BE, 0x1005),
+   MEDIA_BUS_FMT_ENTRY(BGR565_2X8_LE, 0x1006),
+   MEDIA_BUS_FMT_ENTRY(RGB565_2X8_BE, 0x1007),
+   MEDIA_BUS_FMT_ENTRY(RGB565_2X8_LE, 0x1008),
+   MEDIA_BUS_FMT_ENTRY(RGB666_1X18, 0x1009),
+   MEDIA_BUS_FMT_ENTRY(RGB888_1X24, 0x100a),
+   MEDIA_BUS_FMT_ENTRY(RGB888_2X12_BE, 0x100b),
+   MEDIA_BUS_FMT_ENTRY(RGB888_2X12_LE, 0x100c),
+   MEDIA_BUS_FMT_ENTRY(ARGB_1X32, 0x100d),
+
+   /* YUV (including grey) - next is 0x2024 */
+   MEDIA_BUS_FMT_ENTRY(Y8_1X8, 0x2001),
+   MEDIA_BUS_FMT_ENTRY(UV8_1X8, 0x2015),
+   MEDIA_BUS_FMT_ENTRY(UYVY8_1_5X8, 0x2002),
+   MEDIA_BUS_FMT_ENTRY(VYUY8_1_5X8, 0x2003),
+   MEDIA_BUS_FMT_ENTRY(YUYV8_1_5X8, 0x2004),
+   MEDIA_BUS_FMT_ENTRY(YVYU8_1_5X8, 0x2005),
+   MEDIA_BUS_FMT_ENTRY(UYVY8_2X8, 0x2006),
+   MEDIA_BUS_FMT_ENTRY(VYUY8_2X8, 0x2007),
+   MEDIA_BUS_FMT_ENTRY(YUYV8_2X8, 0x2008),
+   MEDIA_BUS_FMT_ENTRY(YVYU8_2X8, 0x2009),
+   MEDIA_BUS_FMT_ENTRY(Y10_1X10, 0x200a),
+   MEDIA_BUS_FMT_ENTRY(UYVY10_2X10, 0x2018),
+   MEDIA_BUS_FMT_ENTRY(VYUY10_2X10, 0x2019),
+   MEDIA_BUS_FMT_ENTRY(YUYV10_2X10, 0x200b),
+   MEDIA_BUS_FMT_ENTRY(YVYU10_2X10, 0x200c),
+   MEDIA_BUS_FMT_ENTRY(Y12_1X12, 0x2013),
+   MEDIA_BUS_FMT_ENTRY(UYVY8_1X16, 0x200f),
+   MEDIA_BUS_FMT_ENTRY(VYUY8_1X16, 0x2010),
+   MEDIA_BUS_FMT_ENTRY(YUYV8_1X16, 0x2011),
+   MEDIA_BUS_FMT_ENTRY(YVYU8_1X16, 0x2012),
+   MEDIA_BUS_FMT_ENTRY(YDYUYDYV8_1X16, 0x2014),
+   MEDIA_BUS_FMT_ENTRY(UYVY10_1X20, 0x201a),
+   MEDIA_BUS_FMT_ENTRY(VYUY10_1X20, 0x201b),
+   MEDIA_BUS_FMT_ENTRY(YUYV10_1X20, 0x200d),
+   MEDIA_BUS_FMT_ENTRY(YVYU10_1X20, 0x200e),
+   MEDIA_BUS_FMT_ENTRY(YUV10_1X30, 0x2016),
+   

[PATCH v2 02/10] [media] v4l: Update subdev-formats doc with new MEDIA_BUS_FMT values

2014-11-06 Thread Boris Brezillon
In order to have subsytem agnostic media bus format definitions we've
moved media bus definition to include/uapi/linux/media-bus-format.h and
prefixed enum values with MEDIA_BUS_FMT instead of V4L2_MBUS_FMT.

Update the v4l documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/DocBook/media/Makefile   |   2 +-
 Documentation/DocBook/media/v4l/subdev-formats.xml | 308 ++---
 2 files changed, 155 insertions(+), 155 deletions(-)

diff --git a/Documentation/DocBook/media/Makefile 
b/Documentation/DocBook/media/Makefile
index 8bf7c61..181b7f4 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -86,7 +86,7 @@ ENUMS = \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/dvb/net.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/dvb/video.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media.h) \
-   $(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-mediabus.h) \
+   $(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/media-bus-format.h) \
$(shell perl -ne 'print $$1  if /^enum\s+([^\s]+)\s+/' 
$(srctree)/include/uapi/linux/v4l2-subdev.h)
 
 STRUCTS = \
diff --git a/Documentation/DocBook/media/v4l/subdev-formats.xml 
b/Documentation/DocBook/media/v4l/subdev-formats.xml
index b2d5a03..18730b9 100644
--- a/Documentation/DocBook/media/v4l/subdev-formats.xml
+++ b/Documentation/DocBook/media/v4l/subdev-formats.xml
@@ -86,7 +86,7 @@
   green and 5-bit blue values padded on the high bit, transferred as 2 
8-bit
   samples per pixel with the most significant bits (padding, red and half 
of
   the green value) transferred first will be named
-  constantV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/constant.
+  constantMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/constant.
   /para
 
   paraThe following tables list existing packed RGB formats./para
@@ -176,8 +176,8 @@
/row
  /thead
  tbody valign=top
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_BE/entry
  entry0x1001/entry
  entry/entry
  dash-ent-24;
@@ -204,8 +204,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB444-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB444_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB444-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB444_2X8_PADHI_LE/entry
  entry0x1002/entry
  entry/entry
  dash-ent-24;
@@ -232,8 +232,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-BE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_BE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-BE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_BE/entry
  entry0x1003/entry
  entry/entry
  dash-ent-24;
@@ -260,8 +260,8 @@
  entrybsubscript1/subscript/entry
  entrybsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB555-2X8-PADHI-LE
- entryV4L2_MBUS_FMT_RGB555_2X8_PADHI_LE/entry
+   row id=MEDIA-BUS-FMT-RGB555-2X8-PADHI-LE
+ entryMEDIA_BUS_FMT_RGB555_2X8_PADHI_LE/entry
  entry0x1004/entry
  entry/entry
  dash-ent-24;
@@ -288,8 +288,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-BE
- entryV4L2_MBUS_FMT_BGR565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-BE
+ entryMEDIA_BUS_FMT_BGR565_2X8_BE/entry
  entry0x1005/entry
  entry/entry
  dash-ent-24;
@@ -316,8 +316,8 @@
  entryrsubscript1/subscript/entry
  entryrsubscript0/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-BGR565-2X8-LE
- entryV4L2_MBUS_FMT_BGR565_2X8_LE/entry
+   row id=MEDIA-BUS-FMT-BGR565-2X8-LE
+ entryMEDIA_BUS_FMT_BGR565_2X8_LE/entry
  entry0x1006/entry
  entry/entry
  dash-ent-24;
@@ -344,8 +344,8 @@
  entrygsubscript4/subscript/entry
  entrygsubscript3/subscript/entry
/row
-   row id=V4L2-MBUS-FMT-RGB565-2X8-BE
- entryV4L2_MBUS_FMT_RGB565_2X8_BE/entry
+   row id=MEDIA-BUS-FMT-RGB565-2X8-BE
+ 

[v4l-utils RFC v3 02/11] mediactl: Separate entity and pad parsing

2014-11-06 Thread Jacek Anaszewski
From: Sakari Ailus sakari.ai...@linux.intel.com

Sometimes it's useful to be able to parse the entity independent of the pad.
Separate entity parsing into media_parse_entity().

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 utils/media-ctl/libmediactl.c |   28 
 utils/media-ctl/mediactl.h|   14 ++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 795aaad..b549a90 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -779,10 +779,10 @@ int media_device_add_entity(struct media_device *media,
return 0;
 }
 
-struct media_pad *media_parse_pad(struct media_device *media,
- const char *p, char **endp)
+struct media_entity *media_parse_entity(struct media_device *media,
+   const char *p, char **endp)
 {
-   unsigned int entity_id, pad;
+   unsigned int entity_id;
struct media_entity *entity;
char *end;
 
@@ -819,7 +819,27 @@ struct media_pad *media_parse_pad(struct media_device 
*media,
return NULL;
}
}
-   for (; isspace(*end); ++end);
+   for (p = end; isspace(*p); ++p);
+
+   *endp = (char *)p;
+
+   return entity;
+}
+
+struct media_pad *media_parse_pad(struct media_device *media,
+ const char *p, char **endp)
+{
+   unsigned int pad;
+   struct media_entity *entity;
+   char *end;
+
+   if (endp == NULL)
+   endp = end;
+
+   entity = media_parse_entity(media, p, end);
+   if (!entity)
+   return NULL;
+   *endp = end;
 
if (*end != ':') {
media_dbg(media, Expected ':'\n, *end);
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index e358242..5246978 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -368,6 +368,20 @@ int media_setup_link(struct media_device *media,
 int media_reset_links(struct media_device *media);
 
 /**
+ * @brief Parse string to an entity on the media device.
+ * @param media - media device.
+ * @param p - input string
+ * @param endp - pointer to string where parsing ended
+ *
+ * Parse NULL terminated string describing an entity and return its
+ * struct media_entity instance.
+ *
+ * @return Pointer to struct media_entity on success, NULL on failure.
+ */
+struct media_entity *media_parse_entity(struct media_device *media,
+   const char *p, char **endp);
+
+/**
  * @brief Parse string to a pad on the media device.
  * @param media - media device.
  * @param p - input string
-- 
1.7.9.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


[v4l-utils RFC v3 00/11] Add a plugin for the Exynos4 camera

2014-11-06 Thread Jacek Anaszewski
This is a third version of the patch series adding a plugin for the 
Exynos4 camera.

Temporarily the plugin doesn't link against libmediactl, but
has its sources compiled in. Currently libmediactl.la is built
after the plugins and this will have to be resolved somehow.


Changes from v2:


- switched to using mediatext library for parsing
  the media device configuration
- extended libmediactl
- switched to using libmediactl


Changes from v1:


- removed redundant mbus code negotiation
- split the parser, media device helpers and ioctl wrappers
  to the separate modules
- added mechanism for querying extended controls
- applied various fixes and modifications

The plugin was tested on latest media-tree.git master with patches for
exynos4-is that fix failing open when a sensor sub-device is not
linked [1] [2] [3].

The plugin expects a configuration file:
/var/lib/libv4l/exynos4_capture_conf

Exemplary configuration file:

==

link-conf s5p-mipi-csis.0:1 - FIMC.0:0 [1]
ctrl-to-subdev-conf 0x0098091f - fimc.0.capture
ctrl-to-subdev-conf 0x00980902 - S5C73M3
ctrl-to-subdev-conf 0x00980922 - fimc.0.capture
ctrl-to-subdev-conf 0x009a0914 - S5C73M3

==

With this settings the plugin can be tested on the exynos4412-trats2 board
using following gstreamer pipeline:

gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=960,height=720 ! 
fbdevsink

In order to avoid fbdevsink element failure the fix [4]
for exynos-drm driver is required.

Thanks,
Jacek Anaszewski

[1] https://patchwork.linuxtv.org/patch/26366/
[2] https://patchwork.linuxtv.org/patch/26367/
[3] https://patchwork.linuxtv.org/patch/26368/
[4] http://www.spinics.net/lists/dri-devel/msg66494.html

Jacek Anaszewski (10):
  mediactl: Introduce ctrl_to_subdev configuration
  mediatext: Add library
  mediactl: Add media device graph helpers
  mediactl: Add media_device creation helpers
  mediactl: Add subdev_fmt property to the media_entity
  mediactl: Add VYUY8_2X8 media bus format
  mediactl: Add support for media device pipelines
  mediactl: Add media device ioctl API
  mediactl: Close only pipeline sub-devices
  Add a libv4l plugin for Exynos4 camera

Sakari Ailus (1):
  mediactl: Separate entity and pad parsing

 configure.ac  |1 +
 lib/Makefile.am   |5 +-
 lib/libv4l-exynos4-camera/Makefile.am |7 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c |  599 +
 libmediatext.pc.in|   10 +
 utils/media-ctl/Makefile.am   |   12 +-
 utils/media-ctl/libmediactl.c |  489 -
 utils/media-ctl/libmediatext.pc.in|   10 +
 utils/media-ctl/libv4l2media_ioctl.c  |  342 
 utils/media-ctl/libv4l2media_ioctl.h  |   47 ++
 utils/media-ctl/libv4l2subdev.c   |   66 +++
 utils/media-ctl/mediactl-priv.h   |   17 +
 utils/media-ctl/mediactl.h|  282 ++
 utils/media-ctl/mediatext-test.c  |   66 +++
 utils/media-ctl/mediatext.c   |  303 +++
 utils/media-ctl/mediatext.h   |   52 ++
 utils/media-ctl/v4l2subdev.h  |   27 +
 17 files changed, 2324 insertions(+), 11 deletions(-)
 create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
 create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
 create mode 100644 libmediatext.pc.in
 create mode 100644 utils/media-ctl/libmediatext.pc.in
 create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
 create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
 create mode 100644 utils/media-ctl/mediatext-test.c
 create mode 100644 utils/media-ctl/mediatext.c
 create mode 100644 utils/media-ctl/mediatext.h

-- 
1.7.9.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


[v4l-utils RFC v3 07/11] mediactl: Add VYUY8_2X8 media bus format

2014-11-06 Thread Jacek Anaszewski
The VYUY8_2X8 media bus format is the only one supported
by the S5C73M3 camera sensor, that is a part of the media
device on the Exynos4412-trats2 board.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libv4l2subdev.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 449565c..0c6aaef 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -705,6 +705,7 @@ static struct {
{ YUYV, V4L2_MBUS_FMT_YUYV8_1X16 },
{ YUYV1_5X8, V4L2_MBUS_FMT_YUYV8_1_5X8 },
{ YUYV2X8, V4L2_MBUS_FMT_YUYV8_2X8 },
+   { VYUY8_2X8, V4L2_MBUS_FMT_VYUY8_2X8 },
{ UYVY, V4L2_MBUS_FMT_UYVY8_1X16 },
{ UYVY1_5X8, V4L2_MBUS_FMT_UYVY8_1_5X8 },
{ UYVY2X8, V4L2_MBUS_FMT_UYVY8_2X8 },
-- 
1.7.9.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


[v4l-utils RFC v3 06/11] mediactl: Add subdev_fmt property to the media_entity

2014-11-06 Thread Jacek Anaszewski
Add subdev_fmt field to the structure media_entity.
Added is also API for setting the media_entity
format and comparing two subdev formats.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libmediactl.c   |6 ++
 utils/media-ctl/libv4l2subdev.c |   34 ++
 utils/media-ctl/mediactl-priv.h |3 +++
 utils/media-ctl/mediactl.h  |   12 
 utils/media-ctl/v4l2subdev.h|   12 
 5 files changed, 67 insertions(+)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 10f0491..27e7329 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -1260,3 +1260,9 @@ int media_entity_get_fd(struct media_entity *entity)
 {
return entity-fd;
 }
+
+void media_entity_set_subdev_fmt(struct media_entity *entity,
+   struct v4l2_subdev_format *fmt)
+{
+   entity-subdev_fmt = *fmt;
+}
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 99ac6b2..449565c 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -786,3 +786,37 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device 
*media,
entity-info.name);
return 0;
 }
+
+int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1,
+   struct v4l2_mbus_framefmt *fmt2)
+{
+   if (fmt1 == NULL || fmt2 == NULL)
+   return 0;
+
+   if (fmt1-width != fmt2-width) {
+   printf(width mismatch\n);
+   return 0;
+   }
+
+   if (fmt1-height != fmt2-height) {
+   printf(height mismatch\n);
+   return 0;
+   }
+
+   if (fmt1-code != fmt2-code) {
+   printf(mbus code mismatch\n);
+   return 0;
+   }
+
+   if (fmt1-field != fmt2-field) {
+   printf(field mismatch\n);
+   return 0;
+   }
+
+   if (fmt1-colorspace != fmt2-colorspace) {
+   printf(colorspace mismatch\n);
+   return 0;
+   }
+
+   return 1;
+}
diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h
index b9e9b20..b2c466b 100644
--- a/utils/media-ctl/mediactl-priv.h
+++ b/utils/media-ctl/mediactl-priv.h
@@ -23,6 +23,7 @@
 #define __MEDIA_PRIV_H__
 
 #include linux/media.h
+#include linux/v4l2-subdev.h
 
 #include mediactl.h
 
@@ -34,6 +35,8 @@ struct media_entity {
unsigned int max_links;
unsigned int num_links;
 
+   struct v4l2_subdev_format subdev_fmt;
+
char devname[32];
int fd;
 };
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 0dc7f95..d28b0a8 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -42,6 +42,7 @@ struct media_pad {
 
 struct media_device;
 struct media_entity;
+struct v4l2_subdev_format;
 
 /**
  * @brief Create a new media device.
@@ -611,4 +612,15 @@ int media_entity_get_sink_pad_index(struct media_entity 
*entity);
  */
 int media_entity_get_fd(struct media_entity *entity);
 
+/**
+ * @brief Set sub-device format
+ * @param entity - media entity
+ * @param fmt - pointer to the sub-device format structure
+ *
+ * This function sets the format of the sub-device related
+ * to this entity.
+ */
+void media_entity_set_subdev_fmt(struct media_entity *entity,
+   struct v4l2_subdev_format *fmt);
+
 #endif
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 3bc0412..2c9d507 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -270,4 +270,16 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device 
*media,
struct media_entity *entity,
__u32 ctrl_id);
 
+/**
+ * @brief Compare mbus formats
+ * @param fmt1 - 1st mbus format to compare
+ * @param fmt2 - 2nd mbus format to compare
+ *
+ * Check whether two mbus formats are compatible.
+ *
+ * @return 1 if formats are compatible, 0 otherwise
+ */
+int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1,
+   struct v4l2_mbus_framefmt *fmt2);
+
 #endif
-- 
1.7.9.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


[v4l-utils RFC v3 05/11] mediactl: Add media_device creation helpers

2014-11-06 Thread Jacek Anaszewski
Add helper functions that allow for easy instantiation
of media_device object basing on whether the media device
contains video device with given node name.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libmediactl.c |   75 +
 utils/media-ctl/mediactl.h|   29 
 2 files changed, 104 insertions(+)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 5b43aff..10f0491 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -855,6 +855,43 @@ struct media_device *media_device_new(const char *devnode)
return media;
 }
 
+struct media_device *media_device_new_by_entity_devname(char *entity_devname)
+{
+   struct media_device *media;
+   char media_devname[32];
+   int i, ret;
+
+   if (entity_devname == NULL)
+   return NULL;
+
+   /* query all available media devices */
+   for (i = 0;; ++i) {
+   sprintf(media_devname, /dev/media%d, i);
+
+   media = media_device_new(media_devname);
+   if (media == NULL)
+   return NULL;
+
+   ret = media_device_enumerate(media);
+   if (ret  0) {
+   media_dbg(media, Failed to enumerate %s (%d)\n, 
media_devname, ret);
+   goto err_dev_enum;
+   }
+
+   /* Check if the media device contains entity with 
entity_devname */
+   if (media_get_entity_by_devname(media, entity_devname, 
strlen(entity_devname)))
+   return media;
+
+   if (media)
+   media_device_unref(media);
+   }
+
+err_dev_enum:
+   if (media)
+   media_device_unref(media);
+   return NULL;
+}
+
 struct media_device *media_device_new_emulated(struct media_device_info *info)
 {
struct media_device *media;
@@ -897,6 +934,44 @@ void media_device_unref(struct media_device *media)
free(media);
 }
 
+int media_get_devname_by_fd(int fd, char *node_name)
+{
+   struct udev *udev;
+   struct media_entity tmp_entity;
+   struct stat stat;
+   int ret;
+
+   if (node_name == NULL)
+   return -EINVAL;
+
+   ret = fstat(fd, stat);
+   if (ret  0)
+   return -EINVAL;
+
+   tmp_entity.info.v4l.major = MAJOR(stat.st_rdev);
+   tmp_entity.info.v4l.minor = MINOR(stat.st_rdev);
+
+   ret = media_udev_open(udev);
+   if (ret  0)
+   printf(Can't get udev context\n);
+
+   /* Try to get the device name via udev */
+   ret = media_get_devname_udev(udev, tmp_entity);
+   if (!ret)
+   goto out;
+
+   ret = media_get_devname_sysfs(tmp_entity);
+   if (ret  0)
+   goto err_get_devname;
+
+out:
+   strcpy(node_name, tmp_entity.devname);
+err_get_devname:
+   media_udev_close(udev);
+   return ret;
+}
+
+
 int media_device_add_entity(struct media_device *media,
const struct media_entity_desc *desc,
const char *devnode)
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 8341c50..0dc7f95 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -77,6 +77,23 @@ struct media_device *media_device_new(const char *devnode);
 struct media_device *media_device_new_emulated(struct media_device_info *info);
 
 /**
+ * @brief Create a new media device if it comprises entity with entity_devname
+ * @param entity_devname - device node name of the entity to be matched
+ *
+ * Query all media devices available in the system to find the one comprising
+ * the entity with device node name equal to entity_devname. If the media
+ * device is matched then its instance is created and initialized with
+ * enumerated entities and links. The returned device can be accessed.
+ *
+ * Media devices are reference-counted, see media_device_ref() and
+ * media_device_unref() for more information.
+ *
+ * @return A pointer to the new media device or NULL if video_devname cannot
+ * be matched or memory cannot be allocated.
+ */
+struct media_device *media_device_new_by_entity_devname(char *video_devname);
+
+/**
  * @brief Take a reference to the device.
  * @param media - device instance.
  *
@@ -242,6 +259,18 @@ const char *media_entity_get_devname(struct media_entity 
*entity);
 const char *media_entity_get_name(struct media_entity *entity);
 
 /**
+ * @brief Get the device node name by its file descriptor
+ * @param fd - file descriptor of a device
+ * @param node_name - output device node name string
+ *
+ * This function returns the full path and name to the device node 
corresponding
+ * to the given file descriptor.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int media_get_devname_by_fd(int fd, char *node_name);
+
+/**
  * 

[v4l-utils RFC v3 11/11] Add a libv4l plugin for Exynos4 camera

2014-11-06 Thread Jacek Anaszewski
The plugin provides support for the media device on Exynos4 SoC.
It performs single plane - multi plane API conversion,
video pipeline linking and takes care of automatic data format
negotiation for the whole pipeline, after intercepting
VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 configure.ac  |1 +
 lib/Makefile.am   |5 +-
 lib/libv4l-exynos4-camera/Makefile.am |7 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c |  599 +
 4 files changed, 610 insertions(+), 2 deletions(-)
 create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
 create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c

diff --git a/configure.ac b/configure.ac
index c9b0524..ae653b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AC_CONFIG_FILES([Makefile
lib/libdvbv5/Makefile
lib/libv4l2rds/Makefile
lib/libv4l-mplane/Makefile
+   lib/libv4l-exynos4-camera/Makefile
 
utils/Makefile
utils/libv4l2util/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3a0e19c..29455ab 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -3,9 +3,10 @@ SUBDIRS = \
libv4l2 \
libv4l1 \
libv4l2rds \
-   libv4l-mplane
+   libv4l-mplane \
+   libv4l-exynos4-camera
 
 if LINUX_OS
 SUBDIRS += \
libdvbv5
-endif
\ No newline at end of file
+endif
diff --git a/lib/libv4l-exynos4-camera/Makefile.am 
b/lib/libv4l-exynos4-camera/Makefile.am
new file mode 100644
index 000..23c60c6
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/Makefile.am
@@ -0,0 +1,7 @@
+if WITH_V4L_PLUGINS
+libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la
+endif
+
+libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c 
../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c 
../../utils/media-ctl/libv4l2media_ioctl.c ../../utils/media-ctl/mediatext.c
+libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99
+libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared 
-export-dynamic -lpthread
diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c 
b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
new file mode 100644
index 000..02b5a7d
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
@@ -0,0 +1,599 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski j.anaszew...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ */
+
+#include config.h
+#include errno.h
+#include stdint.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include linux/types.h
+
+#include ../../utils/media-ctl/libv4l2media_ioctl.h
+#include ../../utils/media-ctl/mediactl.h
+#include ../../utils/media-ctl/mediatext.h
+#include ../../utils/media-ctl/v4l2subdev.h
+#include libv4l-plugin.h
+
+struct media_device;
+struct media_entity;
+
+/*
+ * struct exynos4_camera_plugin - libv4l exynos4 camera plugin
+ * @media: media device comprising the vid_fd related video device
+ */
+struct exynos4_camera_plugin {
+   struct media_device *media;
+};
+
+#ifdef DEBUG
+#define V4L2_EXYNOS4_DBG(format, ARG...)\
+   printf([%s:%d] [%s]  format  \n, __FILE__, __LINE__, __func__, 
##ARG)
+#else
+#define V4L2_EXYNOS4_DBG(format, ARG...)
+#endif
+
+#define V4L2_EXYNOS4_ERR(format, ARG...)\
+   fprintf(stderr, Libv4l Exynos4 camera plugin: format \n, ##ARG)
+
+#define V4L2_EXYNOS4_LOG(format, ARG...)\
+   fprintf(stdout, Libv4l Exynos4 camera plugin: format \n, ##ARG)
+
+#if HAVE_VISIBILITY
+#define PLUGIN_PUBLIC __attribute__ ((visibility(default)))
+#else
+#define PLUGIN_PUBLIC
+#endif
+
+#define SIMPLE_CONVERT_IOCTL(fd, cmd, arg, __struc) ({  \
+   int __ret;  \
+   struct __struc *req = arg;  \
+   uint32_t type = req-type;  \
+   req-type = convert_type(type); \
+   __ret = SYS_IOCTL(fd, cmd, arg);\
+   req-type = type;   \
+   __ret;  \
+   })
+
+#define EXYNOS4_FIMC_DRV   exynos4-fimc
+#define EXYNOS4_FIMC_LITE_DRV  exynos-fimc-lit
+#define EXYNOS4_FIMC_IS_ISP_DRVexynos4-fimc-is
+#define ENTITY_CAPTURE_SEGMENT 

[v4l-utils RFC v3 01/11] mediactl: Introduce ctrl_to_subdev configuration

2014-11-06 Thread Jacek Anaszewski
Add an infrastructure for a ctrl_to_subdev configuration
data. The ctrl_to_subdev config entry is designed for
conveying information about the target sub-device
in the media device pipeline for a v4l2 control related
ioctl calls.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libmediactl.c   |   26 ++
 utils/media-ctl/libv4l2subdev.c |   31 +++
 utils/media-ctl/mediactl-priv.h |8 
 utils/media-ctl/mediactl.h  |   16 
 utils/media-ctl/v4l2subdev.h|   15 +++
 5 files changed, 96 insertions(+)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index ec360bd..795aaad 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -647,12 +647,20 @@ static struct media_device *__media_device_new(void)
if (media == NULL)
return NULL;
 
+   media-ctrl_to_subdev = malloc(sizeof(*media-ctrl_to_subdev));
+   if (!media-ctrl_to_subdev)
+   goto err_cts_alloc;
+
media-fd = -1;
media-refcount = 1;
 
media_debug_set_handler(media, NULL, NULL);
 
return media;
+
+err_cts_alloc:
+   free(media);
+   return NULL;
 }
 
 struct media_device *media_device_new(const char *devnode)
@@ -710,6 +718,7 @@ void media_device_unref(struct media_device *media)
 
free(media-entities);
free(media-devnode);
+   free(media-ctrl_to_subdev);
free(media);
 }
 
@@ -955,3 +964,20 @@ int media_parse_setup_links(struct media_device *media, 
const char *p)
 
return *end ? -EINVAL : 0;
 }
+
+/* 
-
+ * Configuration access
+ */
+
+struct media_entity *media_config_get_entity_by_cid(struct media_device *media,
+   int cid)
+{
+   int i;
+
+   for (i = 0; i  media-ctrl_to_subdev_count; ++i) {
+   if (media-ctrl_to_subdev[i].ctrl_id == cid)
+   return media-ctrl_to_subdev[i].entity;
+   }
+
+return NULL;
+}
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 8015330..99ac6b2 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -755,3 +755,34 @@ enum v4l2_mbus_pixelcode 
v4l2_subdev_string_to_pixelcode(const char *string,
 
return mbus_formats[i].code;
 }
+
+int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
+  struct media_entity *entity,
+  __u32 ctrl_id)
+{
+   struct v4l2_query_ext_ctrl queryctrl;
+   int ret;
+
+   ret = v4l2_subdev_open(entity);
+   if (ret  0)
+   return ret;
+
+   /* Iterate through control ids */
+
+   queryctrl.id = ctrl_id;
+
+   ret = ioctl(entity-fd, VIDIOC_QUERY_EXT_CTRL, queryctrl);
+   if (!ret) {
+   media_dbg(media, Validated control \%s\ (0x%8.8x) on entity 
%s\n,
+   queryctrl.name,
+   ctrl_id,
+   
entity-info.name);
+   return 1;
+   }
+
+   media_dbg(media, Control (0x%8.8x) not supported on entity %s\n,
+   queryctrl.name,
+   ctrl_id,
+   entity-info.name);
+   return 0;
+}
diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h
index a0d3a55..b9e9b20 100644
--- a/utils/media-ctl/mediactl-priv.h
+++ b/utils/media-ctl/mediactl-priv.h
@@ -47,6 +47,9 @@ struct media_device {
struct media_entity *entities;
unsigned int entities_count;
 
+   struct media_v4l2_ctrl_to_subdev *ctrl_to_subdev;
+   unsigned int ctrl_to_subdev_count;
+
void (*debug_handler)(void *, ...);
void *debug_priv;
 
@@ -58,6 +61,11 @@ struct media_device {
} def;
 };
 
+struct media_v4l2_ctrl_to_subdev {
+   __u32 ctrl_id;
+   struct media_entity *entity;
+};
+
 #define media_dbg(media, ...) \
(media)-debug_handler((media)-debug_priv, __VA_ARGS__)
 
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 77ac182..e358242 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -420,4 +420,20 @@ int media_parse_setup_link(struct media_device *media,
  */
 int media_parse_setup_links(struct media_device *media, const char *p);
 
+/**
+ * @brief Find target sub-device for the control
+ * @param media - media device.
+ * @param cid - v4l2 control identifier
+ *
+ * Check if there was a target sub-device defined
+ * for the control through a ctrl-to-subdev-conf 

[v4l-utils RFC v3 03/11] mediatext: Add library

2014-11-06 Thread Jacek Anaszewski
libmediatext is a helper library for converting configurations (Media
controller links, V4L2 controls and V4L2 sub-device media bus formats and
selections) from text-based form into IOCTLs.

libmediatext depends on libv4l2subdev and libmediactl.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
Signed-off-by: Teemu Tuominen teemu.tuomi...@intel.com
Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
---
 libmediatext.pc.in |   10 ++
 utils/media-ctl/Makefile.am|   10 +-
 utils/media-ctl/libmediatext.pc.in |   10 ++
 utils/media-ctl/mediatext-test.c   |   66 
 utils/media-ctl/mediatext.c|  303 
 utils/media-ctl/mediatext.h|   52 +++
 6 files changed, 449 insertions(+), 2 deletions(-)
 create mode 100644 libmediatext.pc.in
 create mode 100644 utils/media-ctl/libmediatext.pc.in
 create mode 100644 utils/media-ctl/mediatext-test.c
 create mode 100644 utils/media-ctl/mediatext.c
 create mode 100644 utils/media-ctl/mediatext.h

diff --git a/libmediatext.pc.in b/libmediatext.pc.in
new file mode 100644
index 000..6aa6353
--- /dev/null
+++ b/libmediatext.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libmediatext
+Description: Media controller and V4L2 text-based configuration library
+Version: @PACKAGE_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lmediatext
diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am
index a3931fb..3e883e0 100644
--- a/utils/media-ctl/Makefile.am
+++ b/utils/media-ctl/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la
+noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la
 
 libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h
 libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
@@ -9,9 +9,15 @@ libv4l2subdev_la_LIBADD = libmediactl.la
 libv4l2subdev_la_CFLAGS = -static
 libv4l2subdev_la_LDFLAGS = -static
 
+libmediatext_la_SOURCES = mediatext.c
+libmediatext_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
+libmediatext_la_LDFLAGS = -static $(LIBUDEV_LIBS)
+
 mediactl_includedir=$(includedir)/mediactl
 noinst_HEADERS = mediactl.h v4l2subdev.h
 
-bin_PROGRAMS = media-ctl
+bin_PROGRAMS = media-ctl mediatext-test
 media_ctl_SOURCES = media-ctl.c options.c options.h tools.h
 media_ctl_LDADD = libmediactl.la libv4l2subdev.la
+mediatext_test_SOURCES = mediatext-test.c
+mediatext_test_LDADD = libmediatext.la libmediactl.la libv4l2subdev.la
diff --git a/utils/media-ctl/libmediatext.pc.in 
b/utils/media-ctl/libmediatext.pc.in
new file mode 100644
index 000..6aa6353
--- /dev/null
+++ b/utils/media-ctl/libmediatext.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libmediatext
+Description: Media controller and V4L2 text-based configuration library
+Version: @PACKAGE_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lmediatext
diff --git a/utils/media-ctl/mediatext-test.c b/utils/media-ctl/mediatext-test.c
new file mode 100644
index 000..29ed38b
--- /dev/null
+++ b/utils/media-ctl/mediatext-test.c
@@ -0,0 +1,66 @@
+/*
+ * libmediatext test program
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Contact: Sakari Ailus sakari.ai...@linux.intel.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include string.h
+
+#include mediactl.h
+#include mediatext.h
+
+int main(int argc, char *argv[])
+{
+   struct media_device *device;
+   int rval;
+
+   if (argc != 3) {
+   fprintf(stderr, usage: %s media device string\n\n, 
argv[0]);
+   fprintf(stderr, \tstring := [ v4l2-ctrl |�v4l2-mbus | 
link-reset | link-conf]\n\n);
+   fprintf(stderr, \tv4l2-ctrl := \entity\ ctrl_type ctrl_id 
ctrl_value\n);
+   fprintf(stderr, \tctrl_type := [ int | int64 | bitmask ]\n);
+   fprintf(stderr, \tctrl_value := [ %%d | %%PRId64 | 
bitmask_value ]\n);
+   fprintf(stderr, \tbitmask_value := bbinary_number\n\n);
+   fprintf(stderr, \tv4l2-mbus := \n);
+   fprintf(stderr, \tlink-conf := \entity\:pad - 
\entity\:pad[link-flags]\n);
+   fprintf(stderr, \tctrl-to-subdev-conf := ctrl_id - 
\entity\\n);
+   return 

[v4l-utils RFC v3 08/11] mediactl: Add support for media device pipelines

2014-11-06 Thread Jacek Anaszewski
Add infrastructure for linking media entities,
discovering pipelines of media entities and
opening/closing all sub-devices in the pipeline
at one go.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libmediactl.c   |  166 +++
 utils/media-ctl/mediactl-priv.h |6 ++
 utils/media-ctl/mediactl.h  |   79 +++
 3 files changed, 251 insertions(+)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 27e7329..75021e7 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -1253,9 +1253,165 @@ struct media_entity 
*media_config_get_entity_by_cid(struct media_device *media,
 }
 
 /* 
-
+ * Pipeline operations
+ */
+
+int media_discover_pipeline_by_entity(struct media_device *media,
+ struct media_entity *entity)
+{
+   struct media_entity *pipe_head = NULL;
+   struct media_pad *sink_pads, sink_pad, *src_pad;
+   struct media_link *link;
+   int num_sink_pads, ret;
+   struct media_pad *prev_link_src_pad = NULL;
+
+   if (entity == NULL)
+   return -EINVAL;
+
+   for (;;) {
+   if (pipe_head == NULL) {
+   pipe_head = entity;
+   } else {
+   entity-next = pipe_head;
+   pipe_head = entity;
+   }
+
+   entity-pipe_src_pad = prev_link_src_pad;
+
+   ret = media_get_busy_pads_by_entity(media, entity,
+   MEDIA_PAD_FL_SINK,
+   sink_pads,
+   num_sink_pads);
+   if (ret  0)
+   return ret;
+
+   /* check if pipeline source entity has been reached */
+   if (num_sink_pads  2) {
+   media_dbg(media, Unexpected number of busy sink pads 
(%d)\n, num_sink_pads);
+   goto err_check_sink_pads;
+   } else if (num_sink_pads == 2) {
+   /* Allow two active pads only in case of S5C73M3-OIF 
entity */
+   if (strcmp(entity-info.name, S5C73M3-OIF)) {
+   media_dbg(media, Ambiguous media device 
topology: two busy sink pads);
+   goto err_check_sink_pads;
+   }
+   /*
+* Two active links are allowed betwen S5C73M3-OIF and 
S5C73M3 entities.
+* In such a case a route through pad 0 has to be 
selected.
+*/
+   ret = media_get_pad_by_index(sink_pads, num_sink_pads,
+   0, sink_pad);
+   if (ret  0)
+   goto err_check_sink_pads;
+   } else if (num_sink_pads == 1) {
+   sink_pad = sink_pads[0];
+   } else {
+   break;
+   }
+   if (num_sink_pads  0)
+   free(sink_pads);
+
+   ret = media_get_link_by_sink_pad(media, sink_pad, link);
+
+   prev_link_src_pad = link-source;
+   entity-pipe_sink_pad = link-sink;
+
+   src_pad = media_entity_remote_source(link-sink);
+   if (!src_pad)
+   return -EINVAL;
+
+   entity = src_pad-entity;
+   }
+
+   media-pipeline = pipe_head;
+
+   return 0;
+
+err_check_sink_pads:
+   free(sink_pads);
+   return -EINVAL;
+}
+
+int media_has_pipeline_entity(struct media_entity *pipeline, char *entity_name)
+{
+   if (pipeline == NULL || entity_name == NULL)
+   return -EINVAL;
+
+   while (pipeline) {
+   if (!strcmp(pipeline-info.name, entity_name))
+   return 1;
+   pipeline = pipeline-next;
+   }
+
+   return 0;
+}
+
+int media_open_pipeline_subdevs(struct media_device *media)
+{
+   struct media_entity *entity = media-pipeline;
+
+   if (entity == NULL)
+   return 0;
+
+   while (entity-next) {
+   media_dbg(media, Opening sub-device: %s\n, entity-devname);
+   entity-fd = open(entity-devname, O_RDWR);
+
+   if (entity-fd  0) {
+   media_dbg(media, Could not open device %s, 
entity-devname);
+   goto err_open_subdev;
+   }
+
+   entity = entity-next;
+   }
+
+   return 0;
+
+err_open_subdev:
+   media_close_pipeline_subdevs(media);
+
+   return -EINVAL;
+}
+
+void media_close_pipeline_subdevs(struct media_device *media)
+{
+   struct media_entity *entity 

[v4l-utils RFC v3 04/11] mediactl: Add media device graph helpers

2014-11-06 Thread Jacek Anaszewski
Add new graph helpers useful for video pipeline discovering.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libmediactl.c |  184 +
 utils/media-ctl/mediactl.h|  132 +
 2 files changed, 316 insertions(+)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index b549a90..5b43aff 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -35,6 +35,7 @@
 #include unistd.h
 
 #include linux/media.h
+#include linux/kdev_t.h
 #include linux/videodev2.h
 
 #include mediactl.h
@@ -45,6 +46,7 @@
  * Graph access
  */
 
+
 struct media_pad *media_entity_remote_source(struct media_pad *pad)
 {
unsigned int i;
@@ -87,6 +89,28 @@ struct media_entity *media_get_entity_by_name(struct 
media_device *media,
return NULL;
 }
 
+struct media_entity *media_get_entity_by_devname(struct media_device *media,
+ const char *devname, size_t 
length)
+{
+   unsigned int i;
+
+   /* A match is impossible if the entity devname is longer than the 
maximum
+* size we can get from the kernel.
+*/
+   if (length = FIELD_SIZEOF(struct media_entity, devname))
+   return NULL;
+
+   for (i = 0; i  media-entities_count; ++i) {
+   struct media_entity *entity = media-entities[i];
+
+   if (strncmp(entity-devname, devname, length) == 0 
+   entity-devname[length] == '\0')
+   return entity;
+   }
+
+   return NULL;
+}
+
 struct media_entity *media_get_entity_by_id(struct media_device *media,
__u32 id)
 {
@@ -145,6 +169,11 @@ const char *media_entity_get_devname(struct media_entity 
*entity)
return entity-devname[0] ? entity-devname : NULL;
 }
 
+const char *media_entity_get_name(struct media_entity *entity)
+{
+   return entity-info.name ? entity-info.name : NULL;
+}
+
 struct media_entity *media_get_default_entity(struct media_device *media,
  unsigned int type)
 {
@@ -177,6 +206,152 @@ const struct media_entity_desc 
*media_entity_get_info(struct media_entity *entit
return entity-info;
 }
 
+int media_get_link_by_sink_pad(struct media_device *media,
+   struct media_pad *pad,
+   struct media_link **link)
+{
+   struct media_link *cur_link = NULL;
+   int i, j;
+
+   if (pad == NULL || link == NULL)
+   return -EINVAL;
+
+   for (i = 0; i  media-entities_count; ++i) {
+   for (j = 0; j  media-entities[i].num_links; ++j) {
+   cur_link = media-entities[i].links[j];
+   if ((cur_link-flags  MEDIA_LNK_FL_ENABLED) 
+   /* check if cur_link's sink entity matches the pad 
parent entity */
+   (cur_link-sink-entity-info.id == 
pad-entity-info.id) 
+   /* check if cur_link's sink pad id matches */
+   (cur_link-sink-index == pad-index)) {
+   *link = cur_link;
+   return 0;
+   }
+   }
+   }
+
+   return -EINVAL;
+}
+
+int media_get_link_by_source_pad(struct media_entity *entity,
+   struct media_pad *pad,
+   struct media_link **link)
+{
+   int i;
+
+   if (entity == NULL || pad == NULL || link == NULL)
+   return -EINVAL;
+
+   for (i = 0; i  entity-num_links; ++i) {
+   if ((entity-links[i].flags  MEDIA_LNK_FL_ENABLED) 
+   (entity-links[i].source-index == pad-index)) {
+   *link = entity-links[i];
+   return 0;
+   }
+   }
+
+   return -EINVAL;
+}
+
+int media_get_pads_by_entity(struct media_entity *entity, unsigned int type,
+   struct media_pad **pads, int *num_pads)
+{
+   struct media_pad *entity_pads;
+   int cnt_pads, i;
+
+   if (entity == NULL || pads == NULL || num_pads == NULL)
+   return -EINVAL;
+
+   entity_pads = malloc(sizeof(*entity_pads));
+   cnt_pads = 0;
+
+   for (i = 0; i  entity-info.pads; ++i) {
+   if (entity-pads[i].flags  type) {
+   entity_pads = realloc(entity_pads, (i + 1) *
+ sizeof(*entity_pads));
+   entity_pads[cnt_pads++] = entity-pads[i];
+   }
+   }
+
+   if (cnt_pads == 0)
+   free(entity_pads);
+
+   *pads = entity_pads;
+   *num_pads = cnt_pads;
+
+   return 0;
+}
+
+int media_get_busy_pads_by_entity(struct media_device *media,
+ 

[v4l-utils RFC v3 09/11] mediactl: Add media device ioctl API

2014-11-06 Thread Jacek Anaszewski
Ioctls executed on complex media devices need special
handling. E.g. S_FMT requires negotiation for the whole
pipeline of sub-devices. On the other hand some ioctls
need to be targeted for specific sub-devices. The API
being introduced address such requirements.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/Makefile.am  |2 +-
 utils/media-ctl/libv4l2media_ioctl.c |  342 ++
 utils/media-ctl/libv4l2media_ioctl.h |   47 +
 3 files changed, 390 insertions(+), 1 deletion(-)
 create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
 create mode 100644 utils/media-ctl/libv4l2media_ioctl.h

diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am
index 3e883e0..7f18624 100644
--- a/utils/media-ctl/Makefile.am
+++ b/utils/media-ctl/Makefile.am
@@ -1,6 +1,6 @@
 noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la
 
-libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h
+libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libv4l2media_ioctl.c 
libv4l2media_ioctl.h
 libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
 libmediactl_la_LDFLAGS = -static $(LIBUDEV_LIBS)
 
diff --git a/utils/media-ctl/libv4l2media_ioctl.c 
b/utils/media-ctl/libv4l2media_ioctl.c
new file mode 100644
index 000..c2c5972
--- /dev/null
+++ b/utils/media-ctl/libv4l2media_ioctl.c
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski j.anaszew...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ */
+
+#include errno.h
+#include linux/videodev2.h
+#include sys/ioctl.h
+
+#include libv4l2media_ioctl.h
+#include mediactl.h
+
+int media_ioctl_set_fmt(struct media_device *media,
+   struct v4l2_format *fmt)
+{
+   struct v4l2_subdev_format sd_fmt = { 0 };
+   struct media_entity *pipeline = media-pipeline;
+   int ret;
+
+   while (pipeline) {
+   sd_fmt = pipeline-subdev_fmt;
+   sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+   ret = SYS_IOCTL(pipeline-fd, VIDIOC_SUBDEV_S_FMT,
+   sd_fmt);
+   if (ret  0)
+   return ret;
+
+   pipeline = pipeline-next;
+
+   /* Last entity in the pipeline is not a sub-device */
+   if (pipeline-next == NULL)
+   break;
+   }
+
+   ret = SYS_IOCTL(pipeline-fd, VIDIOC_S_FMT, fmt);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
+int media_ioctl_ctrl(struct media_device *media, int request,
+   struct v4l2_control *arg)
+{
+   struct media_entity *pipeline = media-pipeline, *entity;
+   struct v4l2_control ctrl = *arg;
+   struct v4l2_queryctrl queryctrl;
+   int ret = -EINVAL;
+
+   /*
+* The control has to be reset to the default value
+* on all of the pipeline entities, prior setting a new
+* value. This is required in cases when the control config
+* is changed between subsequent calls to VIDIOC_S_CTRL,
+* to avoid the situation when a control is set on more
+* than one sub-device.
+*/
+   if (request == VIDIOC_S_CTRL) {
+   while (pipeline) {
+   queryctrl.id = ctrl.id;
+
+   ret = SYS_IOCTL(pipeline-fd, VIDIOC_QUERYCTRL,
+   queryctrl);
+   if (ret  0) {
+   pipeline = pipeline-next;
+   continue;
+   }
+
+   ctrl.value = queryctrl.default_value;
+   ret = SYS_IOCTL(pipeline-fd, VIDIOC_S_CTRL, ctrl);
+   if (ret  0)
+   return -EINVAL;
+
+   pipeline = pipeline-next;
+   }
+
+   ctrl.value = arg-value;
+   }
+
+   entity = media_config_get_entity_by_cid(media, ctrl.id);
+   if (entity) {
+   ret = SYS_IOCTL(entity-fd, request, ctrl);
+   media_dbg(media, Ioctl result for user control 0x%8.8x on %s: 
%d\n,
+   ctrl.id, entity-info.name, ret);
+   goto exit;
+   }
+
+   media_dbg(media, No config for control id 0x%8.8x\n, ctrl.id);
+
+   

[v4l-utils RFC v3 10/11] mediactl: Close only pipeline sub-devices

2014-11-06 Thread Jacek Anaszewski
The function media_device_new_by_entity_devname queries
media devices available in the system for containment
if given media entity. If a verification is negative
the media_device is released with media_device_unref.
In the previous approach media_device_unref was closing
all media entities it contained, which was undesirable
behavior as there might exist other initialized plugins
which had opened the same media_device and initialized
a pipeline. With this patch only the sub-devices that
belong to the pipeline of current media_device instance
will be closed.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 utils/media-ctl/libmediactl.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 75021e7..fe38270 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -919,13 +919,13 @@ void media_device_unref(struct media_device *media)
if (media-refcount  0)
return;
 
+   media_close_pipeline_subdevs(media);
+
for (i = 0; i  media-entities_count; ++i) {
struct media_entity *entity = media-entities[i];
 
free(entity-pads);
free(entity-links);
-   if (entity-fd != -1)
-   close(entity-fd);
}
 
free(media-entities);
-- 
1.7.9.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


Re: v4l2-ctl bug(?) printing ctrl payload array

2014-11-06 Thread Hans Verkuil
On 11/06/14 10:31, Hans Verkuil wrote:
 On 11/05/14 20:52, Andrey Utkin wrote:
 More on the same topic.
 I believe there's another bug on displaying of payload.
 Let's say we have the same [45][45] array, and this is what is posted to it:
 uint16_t buf[45 * 45] = {0, };
 buf[0] = 1;
 buf[1] = 2;
 buf[45] = 3;
 buf[45 * 45 - 1] = 0xff;

 What is shown by v4l2-ctl you can see here:
 https://dl.dropboxusercontent.com/u/43104344/v4l2-ctl_payload_bug.png

 
 I'll look at this Friday or Monday.
 
 I want to add some test array controls to the vivid driver as well to make
 it easier to test such controls, so that will be a good test case.

OK, I had some time and I made several fixes. Please pull from v4l-utils.git
and verify that it is now working correctly.

Thanks for reporting this!

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


[PATCH] vivid: add test array controls

2014-11-06 Thread Hans Verkuil
Add array controls to test support for such controls. There is one
array with just one element, one 8x16 matrix control and one 4 dimensional
2x3x4x5 control.

This makes it possible to experiment with such controls without requiring
hard-to-get hardware.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com

diff --git a/drivers/media/platform/vivid/vivid-ctrls.c 
b/drivers/media/platform/vivid/vivid-ctrls.c
index d5cbf00..d584773 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -40,6 +40,9 @@
 #define VIVID_CID_STRING   (VIVID_CID_CUSTOM_BASE + 5)
 #define VIVID_CID_BITMASK  (VIVID_CID_CUSTOM_BASE + 6)
 #define VIVID_CID_INTMENU  (VIVID_CID_CUSTOM_BASE + 7)
+#define VIVID_CID_U32_ARRAY(VIVID_CID_CUSTOM_BASE + 8)
+#define VIVID_CID_U16_MATRIX   (VIVID_CID_CUSTOM_BASE + 9)
+#define VIVID_CID_U8_4D_ARRAY  (VIVID_CID_CUSTOM_BASE + 10)
 
 #define VIVID_CID_VIVID_BASE   (0x00f0 | 0xf000)
 #define VIVID_CID_VIVID_CLASS  (0x00f0 | 1)
@@ -163,6 +166,42 @@ static const struct v4l2_ctrl_config vivid_ctrl_int64 = {
.step = 1,
 };
 
+static const struct v4l2_ctrl_config vivid_ctrl_u32_array = {
+   .ops = vivid_user_gen_ctrl_ops,
+   .id = VIVID_CID_U32_ARRAY,
+   .name = U32 1 Element Array,
+   .type = V4L2_CTRL_TYPE_U32,
+   .def = 0x18,
+   .min = 0x10,
+   .max = 0x2,
+   .step = 1,
+   .dims = { 1 },
+};
+
+static const struct v4l2_ctrl_config vivid_ctrl_u16_matrix = {
+   .ops = vivid_user_gen_ctrl_ops,
+   .id = VIVID_CID_U16_MATRIX,
+   .name = U16 8x16 Matrix,
+   .type = V4L2_CTRL_TYPE_U16,
+   .def = 0x18,
+   .min = 0x10,
+   .max = 0x2000,
+   .step = 1,
+   .dims = { 8, 16 },
+};
+
+static const struct v4l2_ctrl_config vivid_ctrl_u8_4d_array = {
+   .ops = vivid_user_gen_ctrl_ops,
+   .id = VIVID_CID_U8_4D_ARRAY,
+   .name = U8 2x3x4x5 Array,
+   .type = V4L2_CTRL_TYPE_U8,
+   .def = 0x18,
+   .min = 0x10,
+   .max = 0x20,
+   .step = 1,
+   .dims = { 2, 3, 4, 5 },
+};
+
 static const char * const vivid_ctrl_menu_strings[] = {
Menu Item 0 (Skipped),
Menu Item 1,
@@ -1222,6 +1261,9 @@ int vivid_create_controls(struct vivid_dev *dev, bool 
show_ccs_cap,
dev-string = v4l2_ctrl_new_custom(hdl_user_gen, vivid_ctrl_string, 
NULL);
dev-bitmask = v4l2_ctrl_new_custom(hdl_user_gen, vivid_ctrl_bitmask, 
NULL);
dev-int_menu = v4l2_ctrl_new_custom(hdl_user_gen, 
vivid_ctrl_int_menu, NULL);
+   v4l2_ctrl_new_custom(hdl_user_gen, vivid_ctrl_u32_array, NULL);
+   v4l2_ctrl_new_custom(hdl_user_gen, vivid_ctrl_u16_matrix, NULL);
+   v4l2_ctrl_new_custom(hdl_user_gen, vivid_ctrl_u8_4d_array, NULL);
 
if (dev-has_vid_cap) {
/* Image Processing Controls */
--
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: [v4l-utils RFC v3 01/11] mediactl: Introduce ctrl_to_subdev configuration

2014-11-06 Thread Sakari Ailus
Hi Jacek,

Thanks for the update!

A few comments below.

On Thu, Nov 06, 2014 at 11:11:32AM +0100, Jacek Anaszewski wrote:
 Add an infrastructure for a ctrl_to_subdev configuration
 data. The ctrl_to_subdev config entry is designed for
 conveying information about the target sub-device
 in the media device pipeline for a v4l2 control related
 ioctl calls.
 
 Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
 Acked-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  utils/media-ctl/libmediactl.c   |   26 ++
  utils/media-ctl/libv4l2subdev.c |   31 +++
  utils/media-ctl/mediactl-priv.h |8 
  utils/media-ctl/mediactl.h  |   16 
  utils/media-ctl/v4l2subdev.h|   15 +++
  5 files changed, 96 insertions(+)
 
 diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
 index ec360bd..795aaad 100644
 --- a/utils/media-ctl/libmediactl.c
 +++ b/utils/media-ctl/libmediactl.c
 @@ -647,12 +647,20 @@ static struct media_device *__media_device_new(void)
   if (media == NULL)
   return NULL;
  
 + media-ctrl_to_subdev = malloc(sizeof(*media-ctrl_to_subdev));
 + if (!media-ctrl_to_subdev)
 + goto err_cts_alloc;
 +
   media-fd = -1;
   media-refcount = 1;
  
   media_debug_set_handler(media, NULL, NULL);
  
   return media;
 +
 +err_cts_alloc:
 + free(media);
 + return NULL;
  }
  
  struct media_device *media_device_new(const char *devnode)
 @@ -710,6 +718,7 @@ void media_device_unref(struct media_device *media)
  
   free(media-entities);
   free(media-devnode);
 + free(media-ctrl_to_subdev);
   free(media);
  }
  
 @@ -955,3 +964,20 @@ int media_parse_setup_links(struct media_device *media, 
 const char *p)
  
   return *end ? -EINVAL : 0;
  }
 +
 +/* 
 -
 + * Configuration access
 + */
 +
 +struct media_entity *media_config_get_entity_by_cid(struct media_device 
 *media,
 + int cid)
 +{
 + int i;
 +
 + for (i = 0; i  media-ctrl_to_subdev_count; ++i) {
 + if (media-ctrl_to_subdev[i].ctrl_id == cid)
 + return media-ctrl_to_subdev[i].entity;
 + }
 +
 +return NULL;
 +}
 diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
 index 8015330..99ac6b2 100644
 --- a/utils/media-ctl/libv4l2subdev.c
 +++ b/utils/media-ctl/libv4l2subdev.c
 @@ -755,3 +755,34 @@ enum v4l2_mbus_pixelcode 
 v4l2_subdev_string_to_pixelcode(const char *string,
  
   return mbus_formats[i].code;
  }
 +
 +int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
 +struct media_entity *entity,
 +__u32 ctrl_id)
 +{
 + struct v4l2_query_ext_ctrl queryctrl;
 + int ret;
 +
 + ret = v4l2_subdev_open(entity);
 + if (ret  0)
 + return ret;
 +
 + /* Iterate through control ids */
 +
 + queryctrl.id = ctrl_id;
 +
 + ret = ioctl(entity-fd, VIDIOC_QUERY_EXT_CTRL, queryctrl);
 + if (!ret) {
 + media_dbg(media, Validated control \%s\ (0x%8.8x) on entity 
 %s\n,
 + queryctrl.name,

Could you align the line start to right of the opening parenthesis?

 + ctrl_id,
 + 
 entity-info.name);
 + return 1;
 + }
 +
 + media_dbg(media, Control (0x%8.8x) not supported on entity %s\n,
 + queryctrl.name,
 + ctrl_id,
 + entity-info.name);
 + return 0;
 +}
 diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h
 index a0d3a55..b9e9b20 100644
 --- a/utils/media-ctl/mediactl-priv.h
 +++ b/utils/media-ctl/mediactl-priv.h
 @@ -47,6 +47,9 @@ struct media_device {
   struct media_entity *entities;
   unsigned int entities_count;
  
 + struct media_v4l2_ctrl_to_subdev *ctrl_to_subdev;
 + unsigned int ctrl_to_subdev_count;

The media device shouldn't have information related to subsystems that use
it.

Instead of making this specific to controls, could you instead add a V4L2
(sub-device) specific pointer to each media entity? Controls information
could be stored there.

I think we're going to need other information there as well.

 +
   void (*debug_handler)(void *, ...);
   void *debug_priv;
  
 @@ -58,6 +61,11 @@ struct media_device {
   } def;
  };
  
 +struct media_v4l2_ctrl_to_subdev {
 + __u32 ctrl_id;
 + struct media_entity *entity;
 +};
 +
  #define media_dbg(media, ...) \
   (media)-debug_handler((media)-debug_priv, __VA_ARGS__)
  
 diff --git 

Re: staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_*

2014-11-06 Thread Sean Young
On Fri, Oct 31, 2014 at 05:35:41PM +0300, Dan Carpenter wrote:
 On Fri, Oct 31, 2014 at 04:26:45PM +0200, Aya Mahfouz wrote:
  On Fri, Oct 31, 2014 at 04:06:00PM +0300, Dan Carpenter wrote:
   drivers/staging/media/lirc/lirc_zilog.c
 1333  /* Close the IR device */
 1334  static int close(struct inode *node, struct file *filep)
 1335  {
 1336  /* find our IR struct */
 1337  struct IR *ir = filep-private_data;
 1338  
 1339  if (ir == NULL) {
   ^^
 1340  dev_err(ir-l.dev, close: no private_data 
   attached to the file!\n);
   ^
   
   I suggest you just delete the error message.  Can ir actually be NULL
   here anyway?
  
  
  Since I'm a newbie and this is not my code, I prefer to use pr_err().
 
 This driver doesn't belong to anyone.  Go ahead and take ownership.  The
 message is fairly worthless and no one will miss it.

Speaking of ownership, what this driver really needs is to be ported to 
rc-core. In order to do this it'll need to be able to send raw IR rather
key codes; I've been peering at the firmware but it neither looks like
zilog z8 opcodes nor space/pulse information.

Does anyone have any contacts at Hauppauge who could help with this?

Thanks,

Sean
--
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: Issues with Empia + saa7115

2014-11-06 Thread Rafael Coutinho
Found out, the problem that dd was not getting any data was due
BeagleBoneBlack usb dma configuration on kernel:
config_musb_pio_only
This should be true to  Disable DMA (always use PIO).

Now I can debug if the problem is the saa711x driver version.

2014-11-03 10:03 GMT-02:00 Rafael Coutinho rafael.couti...@phiinnovations.com:
 I have tried now with a newer kernel (3.14) and I can't even get an
 stream from /dev/video0. The file is always empty.

 Here is the dmesg of it:
 http://pastebin.com/pm720UnR

 It is correctly identifying the device, however it cannot grab any
 bytes from the dd command as below:
 dd if=/dev/video0 of=ImageOut.raw bs=10065748 count=1

 Any tips on how to investigate it further?

 2014-10-29 18:13 GMT-02:00 Rafael Coutinho 
 rafael.couti...@phiinnovations.com:
 Ok, just to be sure, I have others capture boards like  Silan SC8113,
 that's only on newer kernels? If so I'll backport it.

 2014-10-29 17:08 GMT-02:00 Mauro Carvalho Chehab m.che...@samsung.com:
 Em Wed, 29 Oct 2014 16:34:09 -0200
 Rafael Coutinho rafael.couti...@phiinnovations.com escreveu:

 Hi all,

 I'm having trouble to make an SAA7115 (Actually it's the generic
 GM7113 version) video capture board to work on a beagle board running
 Android (4.0.3).
 For some reason I cannot capture any image, it always output a green image 
 file.
 The kernel is Linux-3.2.0

 Support for GM7113 were added only on a recent version.

 So, you need to get a newer driver. So, you'll need to either upgrade
 the Kernel, use either Linux backports or media-build to get a newer
 driver set or do the manual work of backporting saa7115 and the bridge
 driver changes for gm7113 for it to work.

 Regards,
 Mauro


 My current approach is the simplest I have found so far, to avoid any
 issues with other sw layers. I'm forcing a 'dd' from the /dev/video
 device.

 dd if=/dev/video0 of=ImageOut.raw bs=10065748 count=1

 And then I open the raw image file converting it on an image editor.

 In my ubuntu PC (kernel 3.13.0) it works fine. however on the Beagle
 Bone with android it fails to get an image.

 I have now tried with a Linux (angstron) on beagle bone with 3.8
 kernel and this time is even worse, the 'dd' command does not result
 on any byte written on the output file.

 The v4l2-ctl works fine on the 3 environments. I can even set values
 as standard, input etc...

 I have attached the dmesg of the environments here:

 * Android - dmesg http://pastebin.com/AFdB9N9c

 * Linux Angstron - dmesg http://pastebin.com/s3S3iCph
 * Linux Angstron - lsmod http://pastebin.com/vh89TBKQ

 * Desktop PC - dmesg http://pastebin.com/HXzHwnUJ

 I have one restriction on the kernel of android due the HAL drivers
 for BBB. So changing kernel is not a choice.

 Anyone could give me some tips on where to look for other issues or debug 
 it?

 Thanks in advance




 --
 Regards,
 Coutinho
 www.phiinnovations.com



 --
 Regards,
 Coutinho
 www.phiinnovations.com



-- 
Regards,
Coutinho
www.phiinnovations.com
--
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] media: davinci: vpbe: missing clk_put

2014-11-06 Thread Sudip Mukherjee
we are getting struct clk using clk_get before calling
clk_prepare_enable. but if clk_prepare_enable fails, then we are
jumping to fail_mutex_unlock where we are just unlocking the mutex,
but we are not freeing the clock source.
this patch just adds a call to clk_put before jumping to
fail_mutex_unlock.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/media/platform/davinci/vpbe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 49d2de0..e5df991 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -625,6 +625,7 @@ static int vpbe_initialize(struct device *dev, struct 
vpbe_device *vpbe_dev)
}
if (clk_prepare_enable(vpbe_dev-dac_clk)) {
ret =  -ENODEV;
+   clk_put(vpbe_dev-dac_clk);
goto fail_mutex_unlock;
}
}
-- 
1.8.1.2

--
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: staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_*

2014-11-06 Thread Mauro Carvalho Chehab
Hi Sean,

Em Thu, 06 Nov 2014 12:46:29 +
Sean Young s...@mess.org escreveu:

 On Fri, Oct 31, 2014 at 05:35:41PM +0300, Dan Carpenter wrote:
  On Fri, Oct 31, 2014 at 04:26:45PM +0200, Aya Mahfouz wrote:
   On Fri, Oct 31, 2014 at 04:06:00PM +0300, Dan Carpenter wrote:
drivers/staging/media/lirc/lirc_zilog.c
  1333  /* Close the IR device */
  1334  static int close(struct inode *node, struct file *filep)
  1335  {
  1336  /* find our IR struct */
  1337  struct IR *ir = filep-private_data;
  1338  
  1339  if (ir == NULL) {
^^
  1340  dev_err(ir-l.dev, close: no private_data 
attached to the file!\n);
^

I suggest you just delete the error message.  Can ir actually be NULL
here anyway?
   
   
   Since I'm a newbie and this is not my code, I prefer to use pr_err().
  
  This driver doesn't belong to anyone.  Go ahead and take ownership.  The
  message is fairly worthless and no one will miss it.
 
 Speaking of ownership, what this driver really needs is to be ported to 
 rc-core. In order to do this it'll need to be able to send raw IR rather
 key codes; I've been peering at the firmware but it neither looks like
 zilog z8 opcodes nor space/pulse information.

Actually, I think that all features provided by this driver were already
migrated into the ir-kbd-i2c (drivers/media/i2c/ir-kbd-i2c.c) driver.

Andy and Jarod worked on this conversion, but we decided, on that time,
to keep lirc_zilog for a while (can't remember why).

Andy/Jarod,

What's the status of the ir-kbd-i2c with regards to Zilog z8 support?

 Does anyone have any contacts at Hauppauge who could help with this?

Probably, it won't be easy to get someone there that worked on it,
as this device is too old.

Anyway, if are there anything still pending, I may be able to get
some contacts at the vendor.

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: staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_*

2014-11-06 Thread Sean Young
On Thu, Nov 06, 2014 at 11:05:49AM -0200, Mauro Carvalho Chehab wrote:
 Hi Sean,
 
 Em Thu, 06 Nov 2014 12:46:29 +
 Sean Young s...@mess.org escreveu:
 
  On Fri, Oct 31, 2014 at 05:35:41PM +0300, Dan Carpenter wrote:
   On Fri, Oct 31, 2014 at 04:26:45PM +0200, Aya Mahfouz wrote:
On Fri, Oct 31, 2014 at 04:06:00PM +0300, Dan Carpenter wrote:
 drivers/staging/media/lirc/lirc_zilog.c
   1333  /* Close the IR device */
   1334  static int close(struct inode *node, struct file *filep)
   1335  {
   1336  /* find our IR struct */
   1337  struct IR *ir = filep-private_data;
   1338  
   1339  if (ir == NULL) {
 ^^
   1340  dev_err(ir-l.dev, close: no private_data 
 attached to the file!\n);
 ^
 
 I suggest you just delete the error message.  Can ir actually be 
 NULL
 here anyway?


Since I'm a newbie and this is not my code, I prefer to use pr_err().
   
   This driver doesn't belong to anyone.  Go ahead and take ownership.  The
   message is fairly worthless and no one will miss it.
  
  Speaking of ownership, what this driver really needs is to be ported to 
  rc-core. In order to do this it'll need to be able to send raw IR rather
  key codes; I've been peering at the firmware but it neither looks like
  zilog z8 opcodes nor space/pulse information.
 
 Actually, I think that all features provided by this driver were already
 migrated into the ir-kbd-i2c (drivers/media/i2c/ir-kbd-i2c.c) driver.

All the features for the IR receiver are implemented (very nicely) in
ir-kbd-i2c (the ir_rx_z8f0811_haup and ir_rx_z8f0811_hdpvr i2c drivers).

However the IR emitter (i2c driver ir_tx_z8f0811_haup and 
ir_tx_z8f0811_hdpvr) are not implemented there. I wanted to port the 
IR emitter but the driver can only send specific rc5 (IIRC) keycodes, not
raw IR. So I cannot port it.

 Andy and Jarod worked on this conversion, but we decided, on that time,
 to keep lirc_zilog for a while (can't remember why).
 
 Andy/Jarod,
 
 What's the status of the ir-kbd-i2c with regards to Zilog z8 support?

Transmitter side.

  Does anyone have any contacts at Hauppauge who could help with this?
 
 Probably, it won't be easy to get someone there that worked on it,
 as this device is too old.
 
 Anyway, if are there anything still pending, I may be able to get
 some contacts at the vendor.

That would be great, I have hardware and I'm happy to re-write the
driver.

Thanks

Sean
--
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: staging: media: lirc: lirc_zilog.c: replace custom print macros with dev_* and pr_*

2014-11-06 Thread Andy Walls
On November 6, 2014 8:54:28 AM EST, Andy Walls awalls.c...@gmail.com wrote:
On November 6, 2014 8:21:13 AM EST, Sean Young s...@mess.org wrote:
On Thu, Nov 06, 2014 at 11:05:49AM -0200, Mauro Carvalho Chehab wrote:
 Hi Sean,
 
 Em Thu, 06 Nov 2014 12:46:29 +
 Sean Young s...@mess.org escreveu:
 
  On Fri, Oct 31, 2014 at 05:35:41PM +0300, Dan Carpenter wrote:
   On Fri, Oct 31, 2014 at 04:26:45PM +0200, Aya Mahfouz wrote:
On Fri, Oct 31, 2014 at 04:06:00PM +0300, Dan Carpenter wrote:
 drivers/staging/media/lirc/lirc_zilog.c
   1333  /* Close the IR device */
   1334  static int close(struct inode *node, struct file
*filep)
   1335  {
   1336  /* find our IR struct */
   1337  struct IR *ir = filep-private_data;
   1338  
   1339  if (ir == NULL) {
 ^^
   1340  dev_err(ir-l.dev, close: no
private_data attached to the file!\n);
 ^
 
 I suggest you just delete the error message.  Can ir
actually be NULL
 here anyway?


Since I'm a newbie and this is not my code, I prefer to use
pr_err().
   
   This driver doesn't belong to anyone.  Go ahead and take
ownership.  The
   message is fairly worthless and no one will miss it.
  
  Speaking of ownership, what this driver really needs is to be
ported to 
  rc-core. In order to do this it'll need to be able to send raw IR
rather
  key codes; I've been peering at the firmware but it neither looks
like
  zilog z8 opcodes nor space/pulse information.
 
 Actually, I think that all features provided by this driver were
already
 migrated into the ir-kbd-i2c (drivers/media/i2c/ir-kbd-i2c.c)
driver.

All the features for the IR receiver are implemented (very nicely) in
ir-kbd-i2c (the ir_rx_z8f0811_haup and ir_rx_z8f0811_hdpvr i2c
drivers).

However the IR emitter (i2c driver ir_tx_z8f0811_haup and 
ir_tx_z8f0811_hdpvr) are not implemented there. I wanted to port the 
IR emitter but the driver can only send specific rc5 (IIRC) keycodes,
not
raw IR. So I cannot port it.

 Andy and Jarod worked on this conversion, but we decided, on that
time,
 to keep lirc_zilog for a while (can't remember why).
 
 Andy/Jarod,
 
 What's the status of the ir-kbd-i2c with regards to Zilog z8
support?

Transmitter side.

  Does anyone have any contacts at Hauppauge who could help with
this?
 
 Probably, it won't be easy to get someone there that worked on it,
 as this device is too old.
 
 Anyway, if are there anything still pending, I may be able to get
 some contacts at the vendor.

That would be great, I have hardware and I'm happy to re-write the
driver.

Thanks

Sean
--
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

Sean,

Ir-kbd-i2c was never intended for Tx.

You can transmit *short* arbitrary pulse-space streams with the zilog
chip, by feeding it a parameter block that has the pulse timing
information and then subsequently has been obfuscated.  The firmware
file that LIRC uses in userspace is full of predefined versions of
these things for RC5 and NEC IIRC.  This LIRC firmware file also holds
the (de)obfuscation key.

I've got a bunch of old notes on this stuff from essentially reverse
engineering the firmware in the Z8.  IANAL, but to me, its use in
developing in-kernel stuff could be dubious.

Regards,
Andy

Resending as plain text for mailing list.
--
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/4] [media] solo6x10: free vb2 buffers on stop_streaming

2014-11-06 Thread Dan Carpenter
On Wed, Oct 29, 2014 at 08:03:51PM +0400, Andrey Utkin wrote:
 This fixes warning from drivers/media/v4l2-core/videobuf2-core.c:2144
 

On my kernel that line is:

q-start_streaming_called = 0;

This changelog is useless.

regards,
dan carpenter

--
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: em28xx: Hauppauge HVR 900 on 3.18.0-rc3

2014-11-06 Thread Michal B
Well ... i'm having same issues also on 3.17.x and 3.4.x, i can run
analog tv only on 3.2 ( debian wheezy's stable)


2014-11-06 9:20 GMT+01:00 Michal B developer...@gmail.com:
 Well ... i'm having same issues also on 3.17.x and 3.4.x, i can run analog
 tv only on 3.2 ( debian wheezy's stable)

 Dňa 6.11.2014 9:09 používateľ Malcolm Priestley tvbox...@gmail.com
 napísal:

 On 06/11/14 06:51, Michal B wrote:

 Hi,

 analog TV on Hauppauge HVR 900 [2040:6500] - audio works correctly but
 video stops after few samples, audio continues after video stop,

 H Michal

 Yep, pretty much the same for all 3.18 and rc3

 One of my systems freezes the other no video.

 All the drivers appear to be doing the same.

 3.17.2 is fine.

 It appears to be a video overlay problem, only start to panic if at rc6

 Regards


 Malcolm


 tested:

 mplayer tv:// -tv

 norm=PAL-BG:freq=687.5:input=0:device=/dev/video0:alsa:amode=1:adevice=hw.2,0:audiorate=48000:forceaudio:immediatemode=0
 -hardframedrop -ao alsa -vo x11

 mplayer output:
 MPlayer svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer
 Team
 mplayer: could not connect to socket
 mplayer: No such file or directory
 Failed to open LIRC support. You will not be able to use your remote
 control.

 Playing tv://.
 TV file format detected.
 Selected driver: v4l2
   name: Video 4 Linux 2 input
   author: Martin Olschewski olschew...@zpr.uni-koeln.de
   comment: first try, more to come ;-)
 Selected device: Hauppauge WinTV HVR 900
   Tuner cap:
   Tuner rxs:
   Capabilities:  video capture  VBI capture device  tuner  audio
 read/write  streaming
   supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR;
 4 = NTSC-443; 5 = PAL; 6 = PAL-BG; 7 = PAL-H; 8 = PAL-I; 9 = PAL-DK;
 10 = PAL-M; 11 = PAL-N; 12 = PAL-Nc; 13 = PAL-60; 14 = SECAM; 15 =
 SECAM-B; 16 = SECAM-G; 17 = SECAM-H; 18 = SECAM-DK; 19 = SECAM-L; 20 =
 SECAM-Lc;
   inputs: 0 = Television; 1 = Composite1; 2 = S-Video;
   Current input: 0
   Current format: YUYV
 v4l2: current audio mode is : STEREO
 v4l2: ioctl set format failed: Invalid argument
 v4l2: ioctl set format failed: Invalid argument
 v4l2: ioctl set format failed: Invalid argument

 ==
 Opening video decoder: [raw] RAW Uncompressed Video
 Could not find matching colorspace - retrying with -vf scale...
 Opening video filter: [scale]
 Movie-Aspect is undefined - no prescaling applied.
 [swscaler @ 0x13c7d40] BICUBIC scaler, from yuyv422 to bgra using MMX2
 VO: [x11] 720x576 = 720x576 BGRA
 Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)

 ==

 ==
 Opening audio decoder: [pcm] Uncompressed PCM audio decoder
 AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000-192000)
 Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)

 ==
 AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
 Starting playback...
 A:   3.1 V:   1.6 A-V:  1.447 ct:  0.165  92/ 92  0%  8% 28.8% 50 0


 
  Your system is too SLOW to play this!  
 

 Possible reasons, problems, workarounds:
 - Most common: broken/buggy _audio_ driver
- Try -ao sdl or use the OSS emulation of ALSA.
- Experiment with different values for -autosync, 30 is a good start.
 - Slow video output
- Try a different -vo driver (-vo help for a list) or try -framedrop!
 - Slow CPU
- Don't try to play a big DVD/DivX on a slow CPU! Try some of the
 lavdopts,
  e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.
 - Broken file
- Try various combinations of -nobps -ni -forceidx -mc 0.
 - Slow media (NFS/SMB mounts, DVD, VCD etc)
- Try -cache 8192.
 - Are you using -cache to play a non-interleaved AVI file?
- Try -nocache.
 Read DOCS/HTML/en/video.html for tuning/speedup tips.
 If none of this helps you, read DOCS/HTML/en/bugreports.html.

 A:  11.7 V:   5.1 A-V:  6.636 ct:  0.250 308/308  0%  2% 12.9% 266 0
 v4l2: 310 frames successfully processed, 0 frames dropped.


 kernel output:
 [  427.441405] usb 3-13.5.5: new high-speed USB device number 9 using
 xhci_hcd
 [  427.534116] usb 3-13.5.5: New USB device found, idVendor=2040,
 idProduct=6500
 [  427.534126] usb 3-13.5.5: New USB device strings: Mfr=0, Product=1,
 SerialNumber=2
 [  427.534131] usb 3-13.5.5: Product: WinTV HVR-900
 [  427.534136] usb 3-13.5.5: SerialNumber: 4026875858
 [  427.586621] media: Linux media interface: v0.10
 [  427.625926] Linux video capture interface: v2.00
 [  427.669943] em28xx: New device  WinTV HVR-900 @ 480 Mbps
 (2040:6500, interface 0, class 0)
 [  427.669945] em28xx: Video interface 0 found: isoc
 [  427.669946] em28xx: DVB interface 0 

Re: [PATCH 1/3] cx23885: add DVBSky S950 support

2014-11-06 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Wed, 5 Nov 2014, Nibble Max wrote:


DVBSky S950 dvb-s/s2 PCIe card:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2PCIe bridge: cx23885
3rc: cx23885 integrated.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/pci/cx23885/cx23885-cards.c | 20 
drivers/media/pci/cx23885/cx23885-dvb.c   |  9 ++---
drivers/media/pci/cx23885/cx23885-input.c |  3 +++
drivers/media/pci/cx23885/cx23885.h   |  1 +
4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 9c7e8ac..4b9cb07 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -692,6 +692,10 @@ struct cx23885_board cx23885_boards[] = {
.name   = Technotrend TT-budget CT2-4500 CI,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_S950] = {
+   .name   = DVBSky S950,
+   .portb  = CX23885_MPEG_DVB,
+   },
};
const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);

@@ -963,6 +967,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x13c2,
.subdevice = 0x3013,
.card  = CX23885_BOARD_TT_CT2_4500_CI,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0950,
+   .card  = CX23885_BOARD_DVBSKY_S950,
},
};
const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1597,6 +1605,13 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)

/* enable irq */
cx_write(GPIO_ISM, 0x); /* INTERRUPTS active low */
+   break;
+   case CX23885_BOARD_DVBSKY_S950:
+   cx23885_gpio_enable(dev, GPIO_2, 1);
+   cx23885_gpio_clear(dev, GPIO_2);
+   msleep(100);
+   cx23885_gpio_set(dev, GPIO_2);
+   break;
}
}

@@ -1681,6 +1696,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1731,6 +1747,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1782,6 +1799,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
@@ -1888,6 +1906,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
ts1-gen_ctrl_val  = 0x5; /* Parallel */
ts1-ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts1-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
@@ -2009,6 +2028,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
dev-sd_cx25840 = v4l2_i2c_new_subdev(dev-v4l2_dev,
dev-i2c_bus[2].i2c_adap,
cx25840, 0x88  1, NULL);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index 9da5cf3..3410ab8 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1672,6 +1672,7 @@ static int dvb_register(struct cx23885_tsport *port)
}
break;
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_S950:
i2c_bus = dev-i2c_bus[0];
i2c_bus2 = dev-i2c_bus[1];
switch (port-nr) {
@@ -1922,7 +1923,8 @@ static int dvb_register(struct cx23885_tsport *port)
memcpy(port-frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
break;
}
-   case CX23885_BOARD_DVBSKY_T9580: {
+   case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_S950: {
u8 eeprom[256]; /* 24C02 i2c eeprom */

if (port-nr  2)
@@ 

Re: [PATCH 2/3] cx23885: add DVBSky S952 support

2014-11-06 Thread Olli Salonen

Looks good to me. Only missing T982 support now?

Reviewed-by: Olli Salonen olli.salo...@iki.fi

-olli

On Wed, 5 Nov 2014, Nibble Max wrote:


DVBSky S952 dvb-s/s2 dual PCIe card:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2PCIe bridge: CX23885(port b: parallel mode, port c: serial mode)
3rc: cx23885 integrated.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/pci/cx23885/cx23885-cards.c | 22 +++
drivers/media/pci/cx23885/cx23885-dvb.c   | 99 ++-
drivers/media/pci/cx23885/cx23885-input.c |  3 +
drivers/media/pci/cx23885/cx23885.h   |  1 +
4 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 4b9cb07..4bad27d 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -696,6 +696,11 @@ struct cx23885_board cx23885_boards[] = {
.name   = DVBSky S950,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_S952] = {
+   .name   = DVBSky S952,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
};
const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);

@@ -971,6 +976,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x4254,
.subdevice = 0x0950,
.card  = CX23885_BOARD_DVBSKY_S950,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0952,
+   .card  = CX23885_BOARD_DVBSKY_S952,
},
};
const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1566,6 +1575,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
mdelay(60);
break;
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_S952:
/* enable GPIO3-18 pins */
cx_write(MC417_CTL, 0x0037);
cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
@@ -1697,6 +1707,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1748,6 +1759,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1800,6 +1812,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
@@ -1962,6 +1975,14 @@ void cx23885_card_setup(struct cx23885_dev *dev)
ts2-ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts2-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
break;
+   case CX23885_BOARD_DVBSKY_S952:
+   ts1-gen_ctrl_val  = 0x5; /* Parallel */
+   ts1-ts_clk_en_val = 0x1; /* Enable TS_CLK */
+   ts1-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+   ts2-gen_ctrl_val  = 0xe; /* Serial bus */
+   ts2-ts_clk_en_val = 0x1; /* Enable TS_CLK */
+   ts2-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+   break;
case CX23885_BOARD_HAUPPAUGE_HVR1250:
case CX23885_BOARD_HAUPPAUGE_HVR1500:
case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
@@ -2029,6 +2050,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
dev-sd_cx25840 = v4l2_i2c_new_subdev(dev-v4l2_dev,
dev-i2c_bus[2].i2c_adap,
cx25840, 0x88  1, NULL);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index 3410ab8..2457b64 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -617,6 +617,32 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
return 0;
}

+static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage)
+{
+   struct cx23885_tsport *port = fe-dvb-priv;
+   struct 

[PATCH 1/1] smiapp: Only some selection targets are settable

2014-11-06 Thread Sakari Ailus
Setting a non-settable selection target caused BUG() to be called. The check
for valid selections only takes the selection target into account, but does
not tell whether it may be set, or only get. Fix the issue by simply
returning an error to the user.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
---
 drivers/media/i2c/smiapp/smiapp-core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index bcc5866..506bfde 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2259,7 +2259,7 @@ static int smiapp_set_selection(struct v4l2_subdev 
*subdev,
ret = smiapp_set_compose(subdev, fh, sel);
break;
default:
-   BUG();
+   ret = -EINVAL;
}
 
mutex_unlock(sensor-mutex);
-- 
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


[PATCH v2 1/4] [media] solo6x10: clean up properly in stop_streaming

2014-11-06 Thread Andrey Utkin
This fixes warning from drivers/media/v4l2-core/videobuf2-core.c,
WARN_ON(atomic_read(q-owned_by_drv_count)).

Signed-off-by: Andrey Utkin andrey.krieger.ut...@gmail.com
---
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c 
b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
index 28023f9..6cd6a25 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
@@ -781,9 +781,19 @@ static int solo_enc_start_streaming(struct vb2_queue *q, 
unsigned int count)
 static void solo_enc_stop_streaming(struct vb2_queue *q)
 {
struct solo_enc_dev *solo_enc = vb2_get_drv_priv(q);
+   unsigned long flags;
 
+   spin_lock_irqsave(solo_enc-av_lock, flags);
solo_enc_off(solo_enc);
-   INIT_LIST_HEAD(solo_enc-vidq_active);
+   while (!list_empty(solo_enc-vidq_active)) {
+   struct solo_vb2_buf *buf = list_entry(
+   solo_enc-vidq_active.next,
+   struct solo_vb2_buf, list);
+
+   list_del(buf-list);
+   vb2_buffer_done(buf-vb, VB2_BUF_STATE_ERROR);
+   }
+   spin_unlock_irqrestore(solo_enc-av_lock, flags);
solo_ring_stop(solo_enc-solo_dev);
 }
 
-- 
1.8.5.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


Re: SPI interface camera sensor driver for soc_camera framework

2014-11-06 Thread Guennadi Liakhovetski
Hi Kassey,

On Mon, 27 Oct 2014, Kassey wrote:

 hi, Dmitri:
 is there any sample driver for SPI interface camera sensor driver
 base don soc_camera framework, other than the i2c interface ?

Currently there are no SPI drivers, used with the soc-camera framework. 
There is however an example of a non-I2C subdevice driver in soc-camera: 
the soc_camera_platform.c driver. You'll see handling of non-I2C 
subdevices in soc_camera_probe() in soc_camera.c. However, that driver 
hasn't been used since a long time and might well be broken by now. Also, 
many newer code paths in soc-camera core unfortunately began to assume, 
that I2C is the only way to access subdevices. So, I suspect fixes might 
be needed when adding support for SPI subdevices.

Thanks
Guennadi
--
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: soc-camera and focuser vcm devices

2014-11-06 Thread Guennadi Liakhovetski
On Tue, 4 Nov 2014, Andrew Chew wrote:

 Hello, Guennadi
 
 I was wondering if you can provide some advice as to how focuser vcm 
 devices would fit into the soc-camera framework.  We have a raw sensor 
 (an IMX219) with an AD5823 VCM (it's just a simple I2C device) to 
 provide variable focus.
 
 I currently have the sensor and camera host driver instantiated via 
 device tree, following the guidelines in 
 Documentation/devicetree/bindings/media/video-interfaces.txt, by using 
 the of_graph stuff, and that all works fine.  However, I'm not sure what 
 the proper way is to associate a focuser with that particular image 
 pipeline, and I couldn't find any examples to draw from.

As discussed in an earlier thread [1], in principle soc-camera has support 
for attaching multiple subdevices to a camera-host (camera DMA engine) 
driver. In [2] you can see how I initially implemented DT for soc-camera, 
which also supported multiple subdevices. Beware, very old code. Some more 
comments are in [3].

Thanks
Guennadi

[1] http://www.spinics.net/lists/linux-sh/msg31436.html - see comment, 
following Hm, I think, this isn't quite correct.

[2] http://marc.info/?l=linux-shm=134875489304837w=1

[3] https://www.mail-archive.com/linux-media@vger.kernel.org/msg70514.html

 
 Any help/guidance would be appreciated!
 ---
 This email message is for the sole use of the intended recipient(s) and may 
 contain
 confidential information.  Any unauthorized review, use, disclosure or 
 distribution
 is prohibited.  If you are not the intended recipient, please contact the 
 sender by
 reply email and destroy all copies of the original message.
 ---
 
--
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: soc-camera and focuser vcm devices

2014-11-06 Thread Andrew Chew
 On Tue, 4 Nov 2014, Andrew Chew wrote:
 
  Hello, Guennadi
 
  I was wondering if you can provide some advice as to how focuser vcm
  devices would fit into the soc-camera framework.  We have a raw sensor
  (an IMX219) with an AD5823 VCM (it's just a simple I2C device) to
  provide variable focus.
 
  I currently have the sensor and camera host driver instantiated via
  device tree, following the guidelines in
  Documentation/devicetree/bindings/media/video-interfaces.txt, by using
  the of_graph stuff, and that all works fine.  However, I'm not sure
  what the proper way is to associate a focuser with that particular
  image pipeline, and I couldn't find any examples to draw from.
 
 As discussed in an earlier thread [1], in principle soc-camera has support for
 attaching multiple subdevices to a camera-host (camera DMA engine) driver.
 In [2] you can see how I initially implemented DT for soc-camera, which also
 supported multiple subdevices. Beware, very old code. Some more
 comments are in [3].
 
 Thanks
 Guennadi
 
 [1] http://www.spinics.net/lists/linux-sh/msg31436.html - see comment,
 following Hm, I think, this isn't quite correct.
 
 [2] http://marc.info/?l=linux-shm=134875489304837w=1
 
 [3] https://www.mail-archive.com/linux-
 me...@vger.kernel.org/msg70514.html

I think I get it, but just to clarify...currently, I'm going with the patch in 
[1], and I currently have multiple subdevs (sensors) hooked up and working with 
my soc-camera host driver.  [2] was an alternate implementation, right? (as in, 
I don't need it).

So I understand that I can just hook up the focuser and flash subdevs to the 
camera host via device tree, in the same exact way of using the of_graph stuff 
to hook up the sensor subdev.  My question is, is it then left up to the camera 
host driver to make sense of which subdevs do what?  Or should/will there be a 
common mechanism to bind ports on a camera host to a sensor, focuser, and flash 
under a common group which makes up an image pipeline?
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
--
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


cron job: media_tree daily build: OK

2014-11-06 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  7 04:00:15 CET 2014
git branch: test
git hash:   4895cc47a072dcb32d3300d0a46a251a8c6db5f1
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-35-gc1c3f96
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:3.17-2.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16-i686: OK
linux-3.17-i686: OK
linux-3.18-rc1-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16-x86_64: OK
linux-3.17-x86_64: OK
linux-3.18-rc1-x86_64: OK
apps: OK
spec-git: OK

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 Media Infrastructure API 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


[GIT PULL FOR v3.19] uvcvideo changes

2014-11-06 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 4895cc47a072dcb32d3300d0a46a251a8c6db5f1:

  [media] s5p-mfc: fix sparse error (2014-11-05 08:29:27 -0200)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git remotes/media/uvc/next

for you to fetch changes up to a1bee5f9f606f89ff30171658a82bf532cca7f3d:

  uvcvideo: Return all buffers to vb2 at stream stop and start failure 
(2014-11-07 08:13:21 +0200)

The v4l2: get/set prio using video_dev prio structure patch hasn't been 
acked yet. I'm leaving now for two weeks of holidays and I would like to avoid 
missing the merge window, so I'd appreciate if someone (Hans ? :-)) could 
review it in my absence and ack the pull request. If it needs to be delayed 
for some reason, could the first two patches (from Philipp and Takashi) still 
get in ?


Laurent Pinchart (10):
  v4l2: get/set prio using video_dev prio structure
  uvcvideo: Move to video_ioctl2
  uvcvideo: Set buffer field to V4L2_FIELD_NONE
  uvcvideo: Separate video and queue enable/disable operations
  uvcvideo: Add function to convert from queue to stream
  uvcvideo: Implement vb2 queue start and stop stream operations
  uvcvideo: Don't stop the stream twice at file handle release
  uvcvideo: Rename uvc_alloc_buffers to uvc_request_buffers
  uvcvideo: Rename and split uvc_queue_enable to uvc_queue_stream(on|off)
  uvcvideo: Return all buffers to vb2 at stream stop and start failure

Philipp Zabel (1):
  uvcvideo: Add quirk to force the Oculus DK2 IR tracker to grayscale

Takashi Iwai (1):
  uvcvideo: Fix destruction order in uvc_delete()

 drivers/media/usb/uvc/uvc_driver.c   |   51 ++-
 drivers/media/usb/uvc/uvc_queue.c|  161 ---
 drivers/media/usb/uvc/uvc_v4l2.c | 1009 +++--
 drivers/media/usb/uvc/uvc_video.c|   23 +-
 drivers/media/usb/uvc/uvcvideo.h |   12 +-
 drivers/media/v4l2-core/v4l2-ioctl.c |4 +-
 6 files changed, 705 insertions(+), 555 deletions(-)

-- 
Regards,

Laurent Pinchart

--
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 1/4] [media] solo6x10: clean up properly in stop_streaming

2014-11-06 Thread Dan Carpenter
On Fri, Nov 07, 2014 at 01:06:18AM +0400, Andrey Utkin wrote:
 This fixes warning from drivers/media/v4l2-core/videobuf2-core.c,
 WARN_ON(atomic_read(q-owned_by_drv_count)).
 

Thanks!

regards,
dan carpenter


--
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: Re: [PATCH 2/3] cx23885: add DVBSky S952 support

2014-11-06 Thread Nibble Max
On 2014-11-07 04:31:01, Olli Salonen wrote:
Looks good to me. Only missing T982 support now?

Reviewed-by: Olli Salonen olli.salo...@iki.fi

-olli


Thanks for review. 
Yes, it is only missing T982 for cx23885 bridge driver.

BR,
Max

On Wed, 5 Nov 2014, Nibble Max wrote:

 DVBSky S952 dvb-s/s2 dual PCIe card:
 1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
 2PCIe bridge: CX23885(port b: parallel mode, port c: serial mode)
 3rc: cx23885 integrated.

 Signed-off-by: Nibble Max nibble@gmail.com
 ---
 drivers/media/pci/cx23885/cx23885-cards.c | 22 +++
 drivers/media/pci/cx23885/cx23885-dvb.c   | 99 
 ++-
 drivers/media/pci/cx23885/cx23885-input.c |  3 +
 drivers/media/pci/cx23885/cx23885.h   |  1 +
 4 files changed, 124 insertions(+), 1 deletion(-)

 diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
 b/drivers/media/pci/cx23885/cx23885-cards.c
 index 4b9cb07..4bad27d 100644
 --- a/drivers/media/pci/cx23885/cx23885-cards.c
 +++ b/drivers/media/pci/cx23885/cx23885-cards.c
 @@ -696,6 +696,11 @@ struct cx23885_board cx23885_boards[] = {
  .name   = DVBSky S950,
  .portb  = CX23885_MPEG_DVB,
  },
 +[CX23885_BOARD_DVBSKY_S952] = {
 +.name   = DVBSky S952,
 +.portb  = CX23885_MPEG_DVB,
 +.portc  = CX23885_MPEG_DVB,
 +},
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);

 @@ -971,6 +976,10 @@ struct cx23885_subid cx23885_subids[] = {
  .subvendor = 0x4254,
  .subdevice = 0x0950,
  .card  = CX23885_BOARD_DVBSKY_S950,
 +}, {
 +.subvendor = 0x4254,
 +.subdevice = 0x0952,
 +.card  = CX23885_BOARD_DVBSKY_S952,
  },
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
 @@ -1566,6 +1575,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
  mdelay(60);
  break;
  case CX23885_BOARD_DVBSKY_T9580:
 +case CX23885_BOARD_DVBSKY_S952:
  /* enable GPIO3-18 pins */
  cx_write(MC417_CTL, 0x0037);
  cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
 @@ -1697,6 +1707,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
  case CX23885_BOARD_DVBSKY_S950C:
  case CX23885_BOARD_TT_CT2_4500_CI:
  case CX23885_BOARD_DVBSKY_S950:
 +case CX23885_BOARD_DVBSKY_S952:
  if (!enable_885_ir)
  break;
  dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
 @@ -1748,6 +1759,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
  case CX23885_BOARD_DVBSKY_S950C:
  case CX23885_BOARD_TT_CT2_4500_CI:
  case CX23885_BOARD_DVBSKY_S950:
 +case CX23885_BOARD_DVBSKY_S952:
  cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
  /* sd_ir is a duplicate pointer to the AV Core, just clear it */
  dev-sd_ir = NULL;
 @@ -1800,6 +1812,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
  case CX23885_BOARD_DVBSKY_S950C:
  case CX23885_BOARD_TT_CT2_4500_CI:
  case CX23885_BOARD_DVBSKY_S950:
 +case CX23885_BOARD_DVBSKY_S952:
  if (dev-sd_ir)
  cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
  break;
 @@ -1962,6 +1975,14 @@ void cx23885_card_setup(struct cx23885_dev *dev)
  ts2-ts_clk_en_val = 0x1; /* Enable TS_CLK */
  ts2-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  break;
 +case CX23885_BOARD_DVBSKY_S952:
 +ts1-gen_ctrl_val  = 0x5; /* Parallel */
 +ts1-ts_clk_en_val = 0x1; /* Enable TS_CLK */
 +ts1-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
 +ts2-gen_ctrl_val  = 0xe; /* Serial bus */
 +ts2-ts_clk_en_val = 0x1; /* Enable TS_CLK */
 +ts2-src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
 +break;
  case CX23885_BOARD_HAUPPAUGE_HVR1250:
  case CX23885_BOARD_HAUPPAUGE_HVR1500:
  case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
 @@ -2029,6 +2050,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
  case CX23885_BOARD_DVBSKY_S950C:
  case CX23885_BOARD_TT_CT2_4500_CI:
  case CX23885_BOARD_DVBSKY_S950:
 +case CX23885_BOARD_DVBSKY_S952:
  dev-sd_cx25840 = v4l2_i2c_new_subdev(dev-v4l2_dev,
  dev-i2c_bus[2].i2c_adap,
  cx25840, 0x88  1, NULL);
 diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
 b/drivers/media/pci/cx23885/cx23885-dvb.c
 index 3410ab8..2457b64 100644
 --- a/drivers/media/pci/cx23885/cx23885-dvb.c
 +++ b/drivers/media/pci/cx23885/cx23885-dvb.c
 @@ -617,6 +617,32 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
 *fe,
  return 0;
 }

 +static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
 +fe_sec_voltage_t voltage)
 +{
 +struct cx23885_tsport *port =