Re: si2168/dvbsky - blind-scan for DVB-T2 with PLP fails

2015-06-05 Thread Olli Salonen
Even easier way to activate dynamic debugging at module load time
(assuming your kernel has dynamic debugging enabled):

modprobe si2168 dyndbg==pmf

Cheers,
-olli

On 4 June 2015 at 21:28, Antti Palosaari cr...@iki.fi wrote:


 On 06/04/2015 08:36 PM, Hurda wrote:

 How can I enable debug-output to get the log-messages like

 http://git.linuxtv.org/cgit.cgi/media_tree.git/tree/drivers/media/dvb-frontends/si2168.c#n164
 ?


 Compile kernel with dynamic debugs. After that you could enable debugs:
 modprobe si2168; echo -n 'module si2168 =pft' 
 /sys/kernel/debug/dynamic_debug/control

 Antti



 Am 28.05.2015 07:26, schrieb Antti Palosaari:

 On 05/28/2015 01:27 AM, Hurda wrote:

 Hello.

 I think I came across a bug in either of the drivers si2168 and dvbsky
 regarding
 blind-scanning DVB-T2-frequencies.

 HW: Technotrend CT2-4400v2 (afaik based on or the same as DVBSky T330)
  demod: Si2168-B40
  tuner: Si2158-A20
 OS: Ubuntu 15.04 (kernel 3.19)

 In Austria, the DVB-T2-service SimpliTV is currently airing up to four
 muxes, next to one or two DVB-T-muxes.
 In my region, the frequencies are 490MHz, 546MHz, 690MHz, 714MHz for
 DVB-T2,
 and 498MHz for DVB-T.
 These numbers might be of interest when reading the logs.

 The peculiar aspect of these T2-muxes is that they're aired on PLP 1
 without
 there being a PLP 0. I think this is also the root of my problem.


 dvbv5-scan is working, but w_scan not?

 Could you hack si2168.c file and test?

 if (c-delivery_system == SYS_DVBT2) {
 /* select PLP */
 cmd.args[0] = 0x52;
 cmd.args[1] = c-stream_id  0xff;
 //cmd.args[2] = c-stream_id == NO_STREAM_ID_FILTER ? 0 : 1;
 cmd.args[2] = 0;
 cmd.wlen = 3;
 cmd.rlen = 1;
 ret = si2168_cmd_execute(client, cmd);
 if (ret)
 goto err;
 }

 Antti



 When doing a blind-scan using w_scan 20140727 on Ubuntu 15.04 (kernel
 3.19),
 w_scan does not find any of these four DVB-T2-muxes.
 It just finds the DVB-T-mux.

 Logs:
 media-tree_dmesg_lsusb.txt http://pastebin.com/0ixFPMSA
 media-tree_w_scan.txt http://pastebin.com/yyG3jSwj

 The found transponder:
 initial_v3_media_build_trunk.conf http://pastebin.com/LmFQavpy
 initial_v5.conf http://pastebin.com/Jx6kymVt

 I also tried a fresh checkout from git.linuxtv.org as of last weekend
 and the
 most recent w_scan version (20141122).

 As you can see, w_scan tries to tune(?) the DVB-T2-frequencies, but
 ultimately doesn't find anything on them.


 Then I tried the DVBSky-linux-driver[1]
 (media_build-bst-20150322.tar.gz)[2]
 from their site, which is using a binary called sit2 for this card.
 Using this driver, w_scan found all four DVB-T2-muxes and the DVB-T-mux.
 Additionally, it found the DVB-T2-muxes during the DVB-T-scan.

 Logs:
 media_build-bst_dmesg_lsusb.txt http://pastebin.com/vJeDMxtu
 media_build-bst_w_scan.txt http://pastebin.com/yhwAYjen

 Found transponders:
 initial_v3_bst.conf http://pastebin.com/ECKQvRWX
 initial_v5_bst.conf http://pastebin.com/CbhY6Hpz

 Of course, doing a channel-scan using dvbv5-scan on these transponders
 worked
 too:

 dvbv5_sit2.conf http://pastebin.com/3W52bbhv
 dvbv5_sit2.log http://pastebin.com/nc66PTkt

 Afterwards, I tried to do a channel-scan with the same initial
 tuning-file
 using the opensource-driver, which also worked:

 dvbv5_si2168.conf http://pastebin.com/A6FbqUL1
 dvbv5_si2168.log http://pastebin.com/ewyVPJR2

 This should verify that tuning PLP 1 without there being PLP 0 is not
 the issue.


 Additionally, if you compare the two channel-lists, you find interesting
 differences:

 The scan with si2168 has AUTO for MODULATION and INVERSION for
 DVB-T2-channels, and for CODE_RATE_LP and INVERSION for
 DVB-T-channels.

 The scan with sit2 has the respective values in the channel-list.

 The dvbv5-scan-logs also differ, as using sit2 also displays the signal
 quality
 during tuning.


 I know that there were changes regarding DVB-T2-scanning[3], but as the
 blog-
 article specifically mentions si2168 and w_scan to be fully
 dvbv5-compliant
 and good for using with DVB-T2, I thought you should know about this
 particular problem.


 In the attachment I've packed the previously linked logs, for archival
 reasons.


 Thank you for your attention.

 [1] http://www.dvbsky.net/Support_linux.html
 [2] http://www.dvbsky.net/download/linux/media_build-bst-150322.tar.gz
 [3] http://blog.palosaari.fi/2014/09/linux-dvb-t2-tuning-problems.html

 PS: Interesting comments regarding auto-detection for si2168:

 http://blog.palosaari.fi/2014/09/linux-dvb-t2-tuning-problems.html?showComment=1427233615765#c8591459871945922951



 http://blog.palosaari.fi/2014/09/linux-dvb-t2-tuning-problems.html?showComment=1427234034259#c6500661729983566638





 --
 http://palosaari.fi/
 --
 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
--
To unsubscribe from this 

[PATCH] v4l2-dv-timing: avoid rounding twice in gtf hblank calc

2015-06-05 Thread Prashant Laddha
Currently, in gtf hblank calculations, the rounding is used twice,
one at intermediate division and one at final state where hblank
is rounded to nearest multiple of twice cell granularity. This
error got introduced in commit d7ed5a3, where it missed combining
the rounding step. Correcting the same in this patch.

Cc: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Prashant Laddha prlad...@cisco.com
---
 drivers/media/v4l2-core/v4l2-dv-timings.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c 
b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 7e15749..0d849fc 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -586,20 +586,22 @@ bool v4l2_detect_gtf(unsigned frame_height,
 
num = ((image_width * GTF_D_C_PRIME * (u64)hfreq) -
  ((u64)image_width * GTF_D_M_PRIME * 1000));
-   den = hfreq * (100 - GTF_D_C_PRIME) + GTF_D_M_PRIME * 1000;
+   den = (hfreq * (100 - GTF_D_C_PRIME) + GTF_D_M_PRIME * 1000) *
+ (2 * GTF_CELL_GRAN);
h_blank = div_u64((num + (den  1)), den);
+   h_blank *= (2 * GTF_CELL_GRAN);
} else {
u64 num;
u32 den;
 
num = ((image_width * GTF_S_C_PRIME * (u64)hfreq) -
  ((u64)image_width * GTF_S_M_PRIME * 1000));
-   den = hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000;
+   den = (hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000) *
+ (2 * GTF_CELL_GRAN);
h_blank = div_u64((num + (den  1)), den);
+   h_blank *= (2 * GTF_CELL_GRAN);
}
 
-   h_blank = ((h_blank + GTF_CELL_GRAN) / (2 * GTF_CELL_GRAN)) *
- (2 * GTF_CELL_GRAN);
frame_width = image_width + h_blank;
 
pix_clk = (image_width + h_blank) * hfreq;
-- 
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 0/2] Reserved field handling fixes

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

VIDIOC_CREATE_BUFS didn't clear the reserved field in the kernel.

Update the documentation so that it is in sync with what v4l2-compliance
checks and what valgrind checks.

Hans Verkuil (2):
  v4l2-ioctl: clear the reserved field of v4l2_create_buffers
  DocBook media: correct description of reserved fields

 Documentation/DocBook/media/v4l/io.xml   | 12 ++--
 Documentation/DocBook/media/v4l/pixfmt.xml   |  8 
 Documentation/DocBook/media/v4l/vidioc-create-bufs.xml   |  3 ++-
 .../DocBook/media/v4l/vidioc-enum-frameintervals.xml |  3 ++-
 Documentation/DocBook/media/v4l/vidioc-enum-framesizes.xml   |  3 ++-
 Documentation/DocBook/media/v4l/vidioc-expbuf.xml|  3 ++-
 Documentation/DocBook/media/v4l/vidioc-g-selection.xml   |  2 +-
 Documentation/DocBook/media/v4l/vidioc-querybuf.xml  |  3 ++-
 Documentation/DocBook/media/v4l/vidioc-reqbufs.xml   |  4 ++--
 drivers/media/v4l2-core/v4l2-ioctl.c |  2 ++
 10 files changed, 25 insertions(+), 18 deletions(-)

-- 
2.1.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 1/2] v4l2-ioctl: clear the reserved field of v4l2_create_buffers

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This field was never cleared by the kernel making future extensions
hard to implement. Clear it now.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 368bc3a..8ffc89a 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1804,6 +1804,8 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops 
*ops,
if (ret)
return ret;
 
+   CLEAR_AFTER_FIELD(create, format);
+
v4l_sanitize_format(create-format);
 
ret = ops-vidioc_create_bufs(file, fh, create);
-- 
2.1.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 2/2] DocBook media: correct description of reserved fields

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Make sure that the documentation clearly states who is zeroing reserved
fields: drivers and/or applications.

This patch syncs the documentation with the checks that v4l2-compliance
and valgrind do.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 Documentation/DocBook/media/v4l/io.xml   | 12 ++--
 Documentation/DocBook/media/v4l/pixfmt.xml   |  8 
 Documentation/DocBook/media/v4l/vidioc-create-bufs.xml   |  3 ++-
 .../DocBook/media/v4l/vidioc-enum-frameintervals.xml |  3 ++-
 Documentation/DocBook/media/v4l/vidioc-enum-framesizes.xml   |  3 ++-
 Documentation/DocBook/media/v4l/vidioc-expbuf.xml|  3 ++-
 Documentation/DocBook/media/v4l/vidioc-g-selection.xml   |  2 +-
 Documentation/DocBook/media/v4l/vidioc-querybuf.xml  |  3 ++-
 Documentation/DocBook/media/v4l/vidioc-reqbufs.xml   |  4 ++--
 9 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index bfe6662..7bbc2a4 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -841,15 +841,15 @@ is the file descriptor associated with a DMABUF 
buffer./entry
entry__u32/entry
entrystructfieldreserved2/structfield/entry
entry/entry
-   entryA place holder for future extensions. Applications
-should set this to 0./entry
+   entryA place holder for future extensions. Drivers and 
applications
+must set this to 0./entry
  /row
  row
entry__u32/entry
entrystructfieldreserved/structfield/entry
entry/entry
-   entryA place holder for future extensions. Applications
-should set this to 0./entry
+   entryA place holder for future extensions. Drivers and 
applications
+must set this to 0./entry
  /row
/tbody
   /tgroup
@@ -930,8 +930,8 @@ should set this to 0./entry
entry__u32/entry
entrystructfieldreserved[11]/structfield/entry
entry/entry
-   entryReserved for future use. Should be zeroed by an
-   application./entry
+   entryReserved for future use. Should be zeroed by drivers and
+   applications./entry
  /row
/tbody
   /tgroup
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
b/Documentation/DocBook/media/v4l/pixfmt.xml
index 6c3d653..8d95172 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -190,8 +190,8 @@ see xref linkend=colorspaces /./entry
 row
   entry__u16/entry
   entrystructfieldreserved[6]/structfield/entry
-  entryReserved for future extensions. Should be zeroed by the
-   application./entry
+  entryReserved for future extensions. Should be zeroed by drivers 
and
+   applications./entry
 /row
   /tbody
 /tgroup
@@ -267,8 +267,8 @@ see xref linkend=colorspaces /./entry
 row
   entry__u8/entry
   entrystructfieldreserved[8]/structfield/entry
-  entryReserved for future extensions. Should be zeroed by the
-   application./entry
+  entryReserved for future extensions. Should be zeroed by drivers
+   and applications./entry
 /row
   /tbody
 /tgroup
diff --git a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml 
b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
index 9b700a5..8ffe74f 100644
--- a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
@@ -134,7 +134,8 @@ information./para
  row
entry__u32/entry
entrystructfieldreserved/structfield[8]/entry
-   entryA place holder for future extensions./entry
+   entryA place holder for future extensions. Drivers and 
applications
+must set the array to zero./entry
  /row
/tbody
   /tgroup
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-frameintervals.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-frameintervals.xml
index 5fd72c4..7c839ab 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-frameintervals.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-frameintervals.xml
@@ -217,7 +217,8 @@ enumerated./entry
entry__u32/entry
entrystructfieldreserved[2]/structfield/entry
entry/entry
-   entryReserved space for future use./entry
+   entryReserved space for future use. Must be zeroed by drivers and
+   applications./entry
  /row
/tbody
   /tgroup
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-framesizes.xml 
b/Documentation/DocBook/media/v4l/vidioc-enum-framesizes.xml
index a78454b..9ed68ac 100644
--- 

[PATCHv2] Improve Y16 color setup

2015-06-05 Thread Hans Verkuil
Currently the colors for the Y16 and Y16_BE pixelformats are in the range
0x-0xff00. So pure white (0x) is never created.

Improve this by making white really white. For other colors the lsb remains 0
so vivid can be used to detect endian problems.

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

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index b1147f2..1b94503 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -900,12 +900,19 @@ static void gen_twopix(struct tpg_data *tpg,
buf[0][offset] = r_y;
break;
case V4L2_PIX_FMT_Y16:
-   buf[0][offset] = 0;
+   /*
+* Ideally both bytes should be set to r_y, but then you won't
+* be able to detect endian problems. So keep it 0 except for
+* the corner case where r_y is 0xff so white really will be
+* white (0x).
+*/
+   buf[0][offset] = r_y == 0xff ? r_y : 0;
buf[0][offset+1] = r_y;
break;
case V4L2_PIX_FMT_Y16_BE:
+   /* See comment for V4L2_PIX_FMT_Y16 above */
buf[0][offset] = r_y;
-   buf[0][offset+1] = 0;
+   buf[0][offset+1] = r_y == 0xff ? r_y : 0;
break;
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_YUV420:
--
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] v4l2-dv-timings: support interlaced in v4l2_print_dv_timings

2015-06-05 Thread Hans Verkuil
The v4l2_print_dv_timings() didn't log the interlaced format correctly. The 
timings
for the bottom field weren't logged and the fields per second value was half of 
what
it should have been.

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

diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c 
b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 5792192..d303fdc 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -262,6 +262,8 @@ void v4l2_print_dv_timings(const char *dev_prefix, const 
char *prefix,
 
htot = V4L2_DV_BT_FRAME_WIDTH(bt);
vtot = V4L2_DV_BT_FRAME_HEIGHT(bt);
+   if (bt-interlaced)
+   vtot /= 2;
 
if (prefix == NULL)
prefix = ;
@@ -282,6 +284,11 @@ void v4l2_print_dv_timings(const char *dev_prefix, const 
char *prefix,
dev_prefix, bt-vfrontporch,
(bt-polarities  V4L2_DV_VSYNC_POS_POL) ? + : -,
bt-vsync, bt-vbackporch);
+   if (bt-interlaced)
+   pr_info(%s: vertical bottom field: fp = %u, %ssync = %u, bp = 
%u\n,
+   dev_prefix, bt-il_vfrontporch,
+   (bt-polarities  V4L2_DV_VSYNC_POS_POL) ? + : -,
+   bt-il_vsync, bt-il_vbackporch);
pr_info(%s: pixelclock: %llu\n, dev_prefix, bt-pixelclock);
pr_info(%s: flags (0x%x):%s%s%s%s%s\n, dev_prefix, bt-flags,
(bt-flags  V4L2_DV_FL_REDUCED_BLANKING) ?

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


[RFC PATCH] Support for reduced blanking version 2

2015-06-05 Thread Prashant Laddha
Current cvt timing calculation supports reduced blanking (RB) version 1.
This patch adds the support for RB version 2, which was missing.
 
Compared to RB version 1, RB version 2 differs on different parameters.
This difference is summarized in the document VESA Coordinated Video
Timings Standard Version 1.2, Page 24, Table 5-4: Delta between Original
Reduced Blank Timing and Reduced Blank Timing V2.

One of the key difference to note is related to vsync parameter. Normally
vsync pulse duration varies based on aspect ratio. v4l2_detect_cvt()
makes use of this fact and infers the apsect ratio from vsync. However,
in case of RB version 2, one cannot infer aspect ratio from vsync because
for RB version 2 standard uses fixed value of vsync = 8 irrespective of
aspect ratio. In fact, vsync = 8 is used to indicate the timings are based
RB version 2. As such RB version 2 allows for non standard aspect ratios and
it needs to be calculated from image height and width. 

Referring to input parameters available to v4l2_detect_cvt(), it does not
have infromation about width. It rather have information about height and
the function calculates width after it infers about aspect ratio from vsync.
For RB version 2, this needs to be changed, possibly, by supplying aspect
ratio to v4l2_detect_cvt(). (on the lines similar to that of detect_gtf())

I have not done any API change in this patch. This patch is rather limited
to changes in timing calculation for RB version 2. As of now, I have just
assumed a default value for aspect ratio at 16:9.

Please review the timing calculation part and share your comments. Also
share your suggestions, comments about if we should extend v4l2_detect_cvt()
api to include aspect ratio.

Regards,
Prashant

Prashant Laddha (1):
  v4l2-dv-timings: add support for reduced blanking v2

 drivers/media/v4l2-core/v4l2-dv-timings.c | 72 +++
 1 file changed, 54 insertions(+), 18 deletions(-)

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


[RFC PATCH] v4l2-dv-timings: add support for reduced blanking v2

2015-06-05 Thread Prashant Laddha
Added support for reduced blanking version 2 (RB v2) in cvt timings.
Standard specifies a fixed vsync pulse of 8 lines to indicate RB v2
timings. Vertical back porch is fixed at 6 lines and vertical front
porch is remainder of vertical blanking time.

For Rb v2, horizontal blanking is fixed at 80 pixels. Horizontal sync
is fixed at 32. All horizontal timing counts (active pixels, front,
back porches) can be specified upto a precision of 1.

To Do: Pass aspect ratio information to v4l2_detect_cvt()
RB v2 allows for non standard aspect ratios. In RB v2 vsync does not
indicate aspect ratio. In the absence of aspect ratio information,
v4l2_detect_cvt() cannot calculate image width from image height.

Cc: Hans Verkuil hans.verk...@cisco.com
Signed-off-by: Prashant Laddha prlad...@cisco.com
---
 drivers/media/v4l2-core/v4l2-dv-timings.c | 72 +++
 1 file changed, 54 insertions(+), 18 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c 
b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 0d849fc..4efc6f6 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -309,6 +309,7 @@ EXPORT_SYMBOL_GPL(v4l2_print_dv_timings);
  */
 
 #define CVT_PXL_CLK_GRAN   25  /* pixel clock granularity */
+#define CVT_PXL_CLK_GRAN_RB_V2 1000/* granularity for reduced blanking v2*/
 
 /* Normal blanking */
 #define CVT_MIN_V_BPORCH   7   /* lines */
@@ -328,10 +329,14 @@ EXPORT_SYMBOL_GPL(v4l2_print_dv_timings);
 /* Reduced Blanking */
 #define CVT_RB_MIN_V_BPORCH7   /* lines  */
 #define CVT_RB_V_FPORCH3   /* lines  */
-#define CVT_RB_MIN_V_BLANK   460 /* us */
+#define CVT_RB_MIN_V_BLANK   460   /* us */
 #define CVT_RB_H_SYNC 32   /* pixels */
-#define CVT_RB_H_BPORCH   80   /* pixels */
 #define CVT_RB_H_BLANK   160   /* pixels */
+/* Reduce blanking Version 2 */
+#define CVT_RB_V2_H_BLANK 80   /* pixels */
+#define CVT_RB_MIN_V_FPORCH3   /* lines  */
+#define CVT_RB_V2_MIN_V_FPORCH 1   /* lines  */
+#define CVT_RB_V_BPORCH6   /* lines  */
 
 /** v4l2_detect_cvt - detect if the given timings follow the CVT standard
  * @frame_height - the total height of the frame (including blanking) in lines.
@@ -356,9 +361,10 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned 
hfreq, unsigned vsync,
int  v_fp, v_bp, h_fp, h_bp, hsync;
int  frame_width, image_height, image_width;
bool reduced_blanking;
+   bool rb_v2 = false;
unsigned pix_clk;
 
-   if (vsync  4 || vsync  7)
+   if (vsync  4 || vsync  8)
return false;
 
if (polarities == V4L2_DV_VSYNC_POS_POL)
@@ -368,17 +374,32 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned 
hfreq, unsigned vsync,
else
return false;
 
+   if (reduced_blanking  vsync == 8)
+   rb_v2 = true;
+
+   if (!rb_v2  vsync  7)
+   return false;
+
if (hfreq == 0)
return false;
 
/* Vertical */
if (reduced_blanking) {
-   v_fp = CVT_RB_V_FPORCH;
-   v_bp = (CVT_RB_MIN_V_BLANK * hfreq) / 100 + 1;
-   v_bp -= vsync + v_fp;
-
-   if (v_bp  CVT_RB_MIN_V_BPORCH)
-   v_bp = CVT_RB_MIN_V_BPORCH;
+   if (rb_v2) {
+   v_bp = CVT_RB_V_BPORCH;
+   v_fp = (CVT_RB_MIN_V_BLANK * hfreq) / 100 + 1;
+   v_fp -= vsync + v_bp;
+
+   if (v_fp  CVT_RB_V2_MIN_V_FPORCH)
+   v_fp = CVT_RB_V2_MIN_V_FPORCH;
+   } else {
+   v_fp = CVT_RB_V_FPORCH;
+   v_bp = (CVT_RB_MIN_V_BLANK * hfreq) / 100 + 1;
+   v_bp -= vsync + v_fp;
+
+   if (v_bp  CVT_RB_MIN_V_BPORCH)
+   v_bp = CVT_RB_MIN_V_BPORCH;
+   }
} else {
v_fp = CVT_MIN_V_PORCH_RND;
v_bp = (CVT_MIN_VSYNC_BP * hfreq) / 100 + 1 - vsync;
@@ -415,22 +436,40 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned 
hfreq, unsigned vsync,
else
return false;
break;
+   case 8:
+   /* To Do:
+* For Reduced Blanking v2, vsync does not indicate aspect ratio and
+* hence can not be used to derive image width. In such a case, either
+* aspect ratio information or image width should be supplied to
+* v4l2_detect_cvt(). This would need API change. As of now assuming
+* 16:9 as default aspect ratio.
+* */
+   image_width = (image_height * 16) / 9;
+   break;
default:
return false;
}
 
-   image_width = image_width  ~7;
+   if (!rb_v2)
+   image_width = image_width  ~7;
 
/* 

Re: [PATCHv2] Improve Y16 color setup

2015-06-05 Thread Ricardo Ribalda Delgado
Reviewed-by: Ricardo Ribalda ricardo.riba...@gmail.com

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


Re: [PATCH v2 1/2] clk: change clk_ops' -round_rate() prototype

2015-06-05 Thread Jon Hunter

On 05/06/15 00:02, Paul Walmsley wrote:
 Hi folks
 
 just a brief comment on this one:
 
 On Thu, 30 Apr 2015, Boris Brezillon wrote:
 
 Clock rates are stored in an unsigned long field, but -round_rate()
 (which returns a rounded rate from a requested one) returns a long
 value (errors are reported using negative error codes), which can lead
 to long overflow if the clock rate exceed 2Ghz.

 Change -round_rate() prototype to return 0 or an error code, and pass the
 requested rate as a pointer so that it can be adjusted depending on
 hardware capabilities.
 
 ...
 
 diff --git a/Documentation/clk.txt b/Documentation/clk.txt
 index 0e4f90a..fca8b7a 100644
 --- a/Documentation/clk.txt
 +++ b/Documentation/clk.txt
 @@ -68,8 +68,8 @@ the operations defined in clk.h:
  int (*is_enabled)(struct clk_hw *hw);
  unsigned long   (*recalc_rate)(struct clk_hw *hw,
  unsigned long parent_rate);
 -long(*round_rate)(struct clk_hw *hw,
 -unsigned long rate,
 +int (*round_rate)(struct clk_hw *hw,
 +unsigned long *rate,
  unsigned long *parent_rate);
  long(*determine_rate)(struct clk_hw *hw,
  unsigned long rate,
 
 I'd suggest that we should probably go straight to 64-bit rates.  There 
 are already plenty of clock sources that can generate rates higher than 
 4GiHz.

An alternative would be to introduce to a frequency base the default
could be Hz (for backwards compatibility), but for CPUs we probably only
care about MHz (or may be kHz) and so 32-bits would still suffice. Even
if CPUs cared about Hz they could still use Hz, but in that case they
probably don't care about GHz. Obviously, we don't want to break DT
compatibility but may be the frequency base could be defined in DT and
if it is missing then Hz is assumed. Just a thought ...

Jon
--
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/2] clk: change clk_ops' -round_rate() prototype

2015-06-05 Thread Boris Brezillon
Hi Jon,

On Fri, 5 Jun 2015 09:46:09 +0100
Jon Hunter jonath...@nvidia.com wrote:

 
 On 05/06/15 00:02, Paul Walmsley wrote:
  Hi folks
  
  just a brief comment on this one:
  
  On Thu, 30 Apr 2015, Boris Brezillon wrote:
  
  Clock rates are stored in an unsigned long field, but -round_rate()
  (which returns a rounded rate from a requested one) returns a long
  value (errors are reported using negative error codes), which can lead
  to long overflow if the clock rate exceed 2Ghz.
 
  Change -round_rate() prototype to return 0 or an error code, and pass the
  requested rate as a pointer so that it can be adjusted depending on
  hardware capabilities.
  
  ...
  
  diff --git a/Documentation/clk.txt b/Documentation/clk.txt
  index 0e4f90a..fca8b7a 100644
  --- a/Documentation/clk.txt
  +++ b/Documentation/clk.txt
  @@ -68,8 +68,8 @@ the operations defined in clk.h:
 int (*is_enabled)(struct clk_hw *hw);
 unsigned long   (*recalc_rate)(struct clk_hw *hw,
 unsigned long parent_rate);
  -  long(*round_rate)(struct clk_hw *hw,
  -  unsigned long rate,
  +  int (*round_rate)(struct clk_hw *hw,
  +  unsigned long *rate,
 unsigned long *parent_rate);
 long(*determine_rate)(struct clk_hw *hw,
 unsigned long rate,
  
  I'd suggest that we should probably go straight to 64-bit rates.  There 
  are already plenty of clock sources that can generate rates higher than 
  4GiHz.
 
 An alternative would be to introduce to a frequency base the default
 could be Hz (for backwards compatibility), but for CPUs we probably only
 care about MHz (or may be kHz) and so 32-bits would still suffice. Even
 if CPUs cared about Hz they could still use Hz, but in that case they
 probably don't care about GHz. Obviously, we don't want to break DT
 compatibility but may be the frequency base could be defined in DT and
 if it is missing then Hz is assumed. Just a thought ...

Yes, but is it really worth the additional complexity. You'll have to
add the unit information anyway, so using an unsigned long for the
value and another field for the unit (an enum ?) is just like using a
64 bit integer.

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.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] vivid: don't use more than 1024 bytes of stack

2015-06-05 Thread Mauro Carvalho Chehab
Remove the following compilation warnings:

drivers/media/platform/vivid/vivid-tpg.c: In function 'tpg_gen_text':
drivers/media/platform/vivid/vivid-tpg.c:1562:1: warning: the frame 
size of 1308 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^

This seems to be due to some bad optimization done by gcc.

Moving the for() loop to happen inside the macro solves the
issue.

While here, fix CodingStyle at the switch().

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index b1147f2df26c..7a3ed580626a 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1492,12 +1492,10 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
else if (tpg-field == V4L2_FIELD_SEQ_TB || tpg-field == 
V4L2_FIELD_SEQ_BT)
div = 2;
 
-   for (p = 0; p  tpg-planes; p++) {
-   unsigned vdiv = tpg-vdownsampling[p];
-   unsigned hdiv = tpg-hdownsampling[p];
-
-   /* Print text */
-#define PRINTSTR(PIXTYPE) do { \
+   /* Print text */
+#define PRINTSTR(PIXTYPE) for (p = 0; p  tpg-planes; p++) {  \
+   unsigned vdiv = tpg-vdownsampling[p];  \
+   unsigned hdiv = tpg-hdownsampling[p];  \
PIXTYPE fg; \
PIXTYPE bg; \
memcpy(fg, tpg-textfg[p], sizeof(PIXTYPE));   \
@@ -1548,16 +1546,19 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
}   \
 } while (0)
 
-   switch (tpg-twopixelsize[p]) {
-   case 2:
-   PRINTSTR(u8); break;
-   case 4:
-   PRINTSTR(u16); break;
-   case 6:
-   PRINTSTR(x24); break;
-   case 8:
-   PRINTSTR(u32); break;
-   }
+   switch (tpg-twopixelsize[p]) {
+   case 2:
+   PRINTSTR(u8);
+   break;
+   case 4:
+   PRINTSTR(u16);
+   break;
+   case 6:
+   PRINTSTR(x24);
+   break;
+   case 8:
+   PRINTSTR(u32);
+   break;
}
 }
 
-- 
2.4.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: [ATTN 0/9] SDR transmitter API

2015-06-05 Thread Hans Verkuil
On 06/05/2015 12:25 PM, Antti Palosaari wrote:
 On 06/05/2015 12:50 PM, Hans Verkuil wrote:
 Hi Antti,

 FYI: don't use ATTN as prefix: patchwork doesn't pick that up as a patch,
 and if it doesn't appear there, then it is likely to be forgotten.

 Can you repost it with the correct prefix? It's so much easier to process
 for me if it ends up in patchwork...
 
 Which is correct prefix?

Just [PATCH] is enough.

 
 Earlier I used PATCH RFC, but then I saw that ATTN:
 [ANN] Report on the San Jose V4L/DVB mini-summit
 http://www.spinics.net/lists/linux-media/msg76281.html
 
 - Add 'ATTN' inside pull request subject line tp indicate that Mauro's 
 (or some other maintainer's) attention is required. Should be limited to 
 api changes, dependencies.
 
 OK, it speaks only pull request, but that was patchset having API changes...

ATTN is only for urgent pull requests for the current rc kernel, it doesn't
apply to patches.

[PATCH RFC] means that it is not yet ready to be merged, but just [PATCH] 
indicates
that it should be OK to merge (at least according to the submitter!).

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 08/10] sh-vou: let sh_vou_s_fmt_vid_out call sh_vou_try_fmt_vid_out

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This ensures that both do the same checks, and simplifies s_fmt_vid_out
a bit.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 86 +++--
 1 file changed, 40 insertions(+), 46 deletions(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 400efec..489d045 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -675,34 +675,19 @@ static void vou_adjust_output(struct sh_vou_geometry 
*geo, v4l2_std_id std)
 vou_scale_v_num[idx], vou_scale_v_den[idx], best);
 }
 
-static int sh_vou_s_fmt_vid_out(struct file *file, void *priv,
-   struct v4l2_format *fmt)
+static int sh_vou_try_fmt_vid_out(struct file *file, void *priv,
+ struct v4l2_format *fmt)
 {
struct sh_vou_device *vou_dev = video_drvdata(file);
struct v4l2_pix_format *pix = fmt-fmt.pix;
unsigned int img_height_max;
int pix_idx;
-   struct sh_vou_geometry geo;
-   struct v4l2_subdev_format format = {
-   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
-   /* Revisit: is this the correct code? */
-   .format.code = MEDIA_BUS_FMT_YUYV8_2X8,
-   .format.field = V4L2_FIELD_INTERLACED,
-   .format.colorspace = V4L2_COLORSPACE_SMPTE170M,
-   };
-   struct v4l2_mbus_framefmt *mbfmt = format.format;
-   int ret;
-
-   dev_dbg(vou_dev-v4l2_dev.dev, %s(): %ux%u - %ux%u\n, __func__,
-   vou_dev-rect.width, vou_dev-rect.height,
-   pix-width, pix-height);
 
-   if (pix-field == V4L2_FIELD_ANY)
-   pix-field = V4L2_FIELD_NONE;
+   dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
 
-   if (fmt-type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
-   pix-field != V4L2_FIELD_NONE)
-   return -EINVAL;
+   pix-field = V4L2_FIELD_INTERLACED;
+   pix-colorspace = V4L2_COLORSPACE_SMPTE170M;
+   pix-ycbcr_enc = pix-quantization = 0;
 
for (pix_idx = 0; pix_idx  ARRAY_SIZE(vou_fmt); pix_idx++)
if (vou_fmt[pix_idx].pfmt == pix-pixelformat)
@@ -716,9 +701,37 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void 
*priv,
else
img_height_max = 576;
 
-   /* Image width must be a multiple of 4 */
v4l_bound_align_image(pix-width, 0, VOU_MAX_IMAGE_WIDTH, 2,
  pix-height, 0, img_height_max, 1, 0);
+   pix-bytesperline = pix-width * 2;
+
+   return 0;
+}
+
+static int sh_vou_s_fmt_vid_out(struct file *file, void *priv,
+   struct v4l2_format *fmt)
+{
+   struct sh_vou_device *vou_dev = video_drvdata(file);
+   struct v4l2_pix_format *pix = fmt-fmt.pix;
+   unsigned int img_height_max;
+   struct sh_vou_geometry geo;
+   struct v4l2_subdev_format format = {
+   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+   /* Revisit: is this the correct code? */
+   .format.code = MEDIA_BUS_FMT_YUYV8_2X8,
+   .format.field = V4L2_FIELD_INTERLACED,
+   .format.colorspace = V4L2_COLORSPACE_SMPTE170M,
+   };
+   struct v4l2_mbus_framefmt *mbfmt = format.format;
+   int ret = sh_vou_try_fmt_vid_out(file, priv, fmt);
+   int pix_idx;
+
+   if (ret)
+   return ret;
+
+   for (pix_idx = 0; pix_idx  ARRAY_SIZE(vou_fmt); pix_idx++)
+   if (vou_fmt[pix_idx].pfmt == pix-pixelformat)
+   break;
 
geo.in_width = pix-width;
geo.in_height = pix-height;
@@ -737,6 +750,11 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void 
*priv,
dev_dbg(vou_dev-v4l2_dev.dev, %s(): %ux%u - %ux%u\n, __func__,
geo.output.width, geo.output.height, mbfmt-width, 
mbfmt-height);
 
+   if (vou_dev-std  V4L2_STD_525_60)
+   img_height_max = 480;
+   else
+   img_height_max = 576;
+
/* Sanity checks */
if ((unsigned)mbfmt-width  VOU_MAX_IMAGE_WIDTH ||
(unsigned)mbfmt-height  img_height_max ||
@@ -769,30 +787,6 @@ static int sh_vou_s_fmt_vid_out(struct file *file, void 
*priv,
return 0;
 }
 
-static int sh_vou_try_fmt_vid_out(struct file *file, void *priv,
- struct v4l2_format *fmt)
-{
-   struct sh_vou_device *vou_dev = video_drvdata(file);
-   struct v4l2_pix_format *pix = fmt-fmt.pix;
-   int i;
-
-   dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
-
-   fmt-type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-   pix-field = V4L2_FIELD_NONE;
-
-   v4l_bound_align_image(pix-width, 0, VOU_MAX_IMAGE_WIDTH, 1,
- pix-height, 0, VOU_MAX_IMAGE_HEIGHT, 1, 0);
-
-   for (i = 0; i  ARRAY_SIZE(vou_fmt); i++)
-   if (vou_fmt[i].pfmt == pix-pixelformat)
- 

[PATCH 07/10] sh-vou: add support for log_status

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Dump the VOU registers in log_status.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 7ed5a8b..400efec 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -951,6 +951,34 @@ static int sh_vou_g_std(struct file *file, void *priv, 
v4l2_std_id *std)
return 0;
 }
 
+static int sh_vou_log_status(struct file *file, void *priv)
+{
+   struct sh_vou_device *vou_dev = video_drvdata(file);
+
+   pr_info(PSELA:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUER));
+   pr_info(VOUER:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUER));
+   pr_info(VOUCR:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUCR));
+   pr_info(VOUSTR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSTR));
+   pr_info(VOUVCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUVCR));
+   pr_info(VOUISR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUISR));
+   pr_info(VOUBCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUBCR));
+   pr_info(VOUDPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDPR));
+   pr_info(VOUDSR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDSR));
+   pr_info(VOUVPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUVPR));
+   pr_info(VOUIR:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUIR));
+   pr_info(VOUSRR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSRR));
+   pr_info(VOUMSR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUMSR));
+   pr_info(VOUHIR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUHIR));
+   pr_info(VOUDFR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDFR));
+   pr_info(VOUAD1R: 0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAD1R));
+   pr_info(VOUAD2R: 0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAD2R));
+   pr_info(VOUAIR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAIR));
+   pr_info(VOUSWR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSWR));
+   pr_info(VOURCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOURCR));
+   pr_info(VOURPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOURPR));
+   return 0;
+}
+
 static int sh_vou_g_selection(struct file *file, void *fh,
  struct v4l2_selection *sel)
 {
@@ -1289,6 +1317,7 @@ static const struct v4l2_ioctl_ops sh_vou_ioctl_ops = {
.vidioc_g_std   = sh_vou_g_std,
.vidioc_g_selection = sh_vou_g_selection,
.vidioc_s_selection = sh_vou_s_selection,
+   .vidioc_log_status  = sh_vou_log_status,
 };
 
 static const struct v4l2_file_operations sh_vou_fops = {
-- 
2.1.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 09/10] sh-vou: fix bytesperline

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

The bytesperline values were wrong for planar formats where bytesperline is
the line length for the first plane.

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

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 489d045..d431cb1 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -135,6 +135,7 @@ struct sh_vou_fmt {
u32 pfmt;
char*desc;
unsigned char   bpp;
+   unsigned char   bpl;
unsigned char   rgb;
unsigned char   yf;
unsigned char   pkf;
@@ -145,6 +146,7 @@ static struct sh_vou_fmt vou_fmt[] = {
{
.pfmt   = V4L2_PIX_FMT_NV12,
.bpp= 12,
+   .bpl= 1,
.desc   = YVU420 planar,
.yf = 0,
.rgb= 0,
@@ -152,6 +154,7 @@ static struct sh_vou_fmt vou_fmt[] = {
{
.pfmt   = V4L2_PIX_FMT_NV16,
.bpp= 16,
+   .bpl= 1,
.desc   = YVYU planar,
.yf = 1,
.rgb= 0,
@@ -159,6 +162,7 @@ static struct sh_vou_fmt vou_fmt[] = {
{
.pfmt   = V4L2_PIX_FMT_RGB24,
.bpp= 24,
+   .bpl= 3,
.desc   = RGB24,
.pkf= 2,
.rgb= 1,
@@ -166,6 +170,7 @@ static struct sh_vou_fmt vou_fmt[] = {
{
.pfmt   = V4L2_PIX_FMT_RGB565,
.bpp= 16,
+   .bpl= 2,
.desc   = RGB565,
.pkf= 3,
.rgb= 1,
@@ -173,6 +178,7 @@ static struct sh_vou_fmt vou_fmt[] = {
{
.pfmt   = V4L2_PIX_FMT_RGB565X,
.bpp= 16,
+   .bpl= 2,
.desc   = RGB565 byteswapped,
.pkf= 3,
.rgb= 1,
@@ -703,7 +709,8 @@ static int sh_vou_try_fmt_vid_out(struct file *file, void 
*priv,
 
v4l_bound_align_image(pix-width, 0, VOU_MAX_IMAGE_WIDTH, 2,
  pix-height, 0, img_height_max, 1, 0);
-   pix-bytesperline = pix-width * 2;
+   pix-bytesperline = pix-width * vou_fmt[pix_idx].bpl;
+   pix-sizeimage = pix-height * ((pix-width * vou_fmt[pix_idx].bpp)  
3);
 
return 0;
 }
@@ -1380,7 +1387,7 @@ static int sh_vou_probe(struct platform_device *pdev)
pix-height = 480;
pix-pixelformat= V4L2_PIX_FMT_NV16;
pix-field  = V4L2_FIELD_NONE;
-   pix-bytesperline   = VOU_MAX_IMAGE_WIDTH * 2;
+   pix-bytesperline   = VOU_MAX_IMAGE_WIDTH;
pix-sizeimage  = VOU_MAX_IMAGE_WIDTH * 2 * 480;
pix-colorspace = V4L2_COLORSPACE_SMPTE170M;
 
-- 
2.1.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 10/10] sh-vou: convert to vb2

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This converts this driver to videobuf2. As usual it is a big and hard to review
patch, but this is always a big-bang change.

It has been tested with my Renesas board.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Tested-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 586 +---
 1 file changed, 247 insertions(+), 339 deletions(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index d431cb1..1ebf4ad 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -28,7 +28,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-mediabus.h
-#include media/videobuf-dma-contig.h
+#include media/videobuf2-dma-contig.h
 
 /* Mirror addresses are not available for all registers */
 #define VOUER  0
@@ -58,8 +58,19 @@ enum sh_vou_status {
SH_VOU_RUNNING,
 };
 
+#define VOU_MIN_IMAGE_WIDTH16
 #define VOU_MAX_IMAGE_WIDTH720
-#define VOU_MAX_IMAGE_HEIGHT   576
+#define VOU_MIN_IMAGE_HEIGHT   16
+
+struct sh_vou_buffer {
+   struct vb2_buffer vb;
+   struct list_head list;
+};
+
+static inline struct sh_vou_buffer *to_sh_vou_buffer(struct vb2_buffer *vb2)
+{
+   return container_of(vb2, struct sh_vou_buffer, vb);
+}
 
 struct sh_vou_device {
struct v4l2_device v4l2_dev;
@@ -71,19 +82,17 @@ struct sh_vou_device {
/* State information */
struct v4l2_pix_format pix;
struct v4l2_rect rect;
-   struct list_head queue;
+   struct list_head buf_list;
v4l2_std_id std;
int pix_idx;
-   struct videobuf_buffer *active;
+   struct vb2_queue queue;
+   struct vb2_alloc_ctx *alloc_ctx;
+   struct sh_vou_buffer *active;
enum sh_vou_status status;
+   unsigned sequence;
struct mutex fop_lock;
 };
 
-struct sh_vou_file {
-   struct v4l2_fh fh;
-   struct videobuf_queue vbq;
-};
-
 /* Register access routines for sides A, B and mirror addresses */
 static void sh_vou_reg_a_write(struct sh_vou_device *vou_dev, unsigned int reg,
   u32 value)
@@ -186,11 +195,11 @@ static struct sh_vou_fmt vou_fmt[] = {
 };
 
 static void sh_vou_schedule_next(struct sh_vou_device *vou_dev,
-struct videobuf_buffer *vb)
+struct vb2_buffer *vb)
 {
dma_addr_t addr1, addr2;
 
-   addr1 = videobuf_to_dma_contig(vb);
+   addr1 = vb2_dma_contig_plane_dma_addr(vb, 0);
switch (vou_dev-pix.pixelformat) {
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV16:
@@ -204,8 +213,7 @@ static void sh_vou_schedule_next(struct sh_vou_device 
*vou_dev,
sh_vou_reg_m_write(vou_dev, VOUAD2R, addr2);
 }
 
-static void sh_vou_stream_start(struct sh_vou_device *vou_dev,
-   struct videobuf_buffer *vb)
+static void sh_vou_stream_config(struct sh_vou_device *vou_dev)
 {
unsigned int row_coeff;
 #ifdef __LITTLE_ENDIAN
@@ -232,167 +240,136 @@ static void sh_vou_stream_start(struct sh_vou_device 
*vou_dev,
 
sh_vou_reg_a_write(vou_dev, VOUSWR, dataswap);
sh_vou_reg_ab_write(vou_dev, VOUAIR, vou_dev-pix.width * row_coeff);
-   sh_vou_schedule_next(vou_dev, vb);
-}
-
-static void free_buffer(struct videobuf_queue *vq, struct videobuf_buffer *vb)
-{
-   BUG_ON(in_interrupt());
-
-   /* Wait until this buffer is no longer in STATE_QUEUED or STATE_ACTIVE 
*/
-   videobuf_waiton(vq, vb, 0, 0);
-   videobuf_dma_contig_free(vq, vb);
-   vb-state = VIDEOBUF_NEEDS_INIT;
 }
 
 /* Locking: caller holds fop_lock mutex */
-static int sh_vou_buf_setup(struct videobuf_queue *vq, unsigned int *count,
-   unsigned int *size)
+static int sh_vou_queue_setup(struct vb2_queue *vq, const struct v4l2_format 
*fmt,
+  unsigned int *nbuffers, unsigned int *nplanes,
+  unsigned int sizes[], void *alloc_ctxs[])
 {
-   struct video_device *vdev = vq-priv_data;
-   struct sh_vou_device *vou_dev = video_get_drvdata(vdev);
-
-   *size = vou_fmt[vou_dev-pix_idx].bpp * vou_dev-pix.width *
-   vou_dev-pix.height / 8;
-
-   if (*count  2)
-   *count = 2;
-
-   /* Taking into account maximum frame size, *count will stay = 2 */
-   if (PAGE_ALIGN(*size) * *count  4 * 1024 * 1024)
-   *count = 4 * 1024 * 1024 / PAGE_ALIGN(*size);
+   struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq);
+   struct v4l2_pix_format *pix = vou_dev-pix;
+   int bytes_per_line = vou_fmt[vou_dev-pix_idx].bpp * pix-width / 8;
 
-   dev_dbg(vou_dev-v4l2_dev.dev, %s(): count=%d, size=%d\n, __func__,
-   *count, *size);
+   dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
 
+   if (fmt  fmt-fmt.pix.sizeimage  pix-height * bytes_per_line)
+   return -EINVAL;

[PATCH 01/10] sh-vou: hook up the clock correctly

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Bitrot has set in for this driver and the sh-vou.0 clock was never enabled,
so this driver didn't do anything. In addition, the clock was incorrectly
defined in clock-sh7724.c. Fix this.

While we're at it: use proper resource managed calls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
Cc: Magnus Damm d...@opensource.se
---
 arch/sh/kernel/cpu/sh4a/clock-sh7724.c |  2 +-
 drivers/media/platform/sh_vou.c| 54 --
 2 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c 
b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index c187b95..f1df899 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -343,7 +343,7 @@ static struct clk_lookup lookups[] = {
CLKDEV_CON_ID(2ddmac0, mstp_clks[HWBLK_2DDMAC]),
CLKDEV_DEV_ID(sh_fsi.0, mstp_clks[HWBLK_SPU]),
CLKDEV_CON_ID(jpu0, mstp_clks[HWBLK_JPU]),
-   CLKDEV_DEV_ID(sh-vou.0, mstp_clks[HWBLK_VOU]),
+   CLKDEV_CON_ID(sh-vou.0, mstp_clks[HWBLK_VOU]),
CLKDEV_CON_ID(beu0, mstp_clks[HWBLK_BEU0]),
CLKDEV_DEV_ID(sh_mobile_ceu.0, mstp_clks[HWBLK_CEU0]),
CLKDEV_CON_ID(veu0, mstp_clks[HWBLK_VEU0]),
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 829e85c..9e98233 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -21,6 +21,7 @@
 #include linux/slab.h
 #include linux/videodev2.h
 #include linux/module.h
+#include linux/clk.h
 
 #include media/sh_vou.h
 #include media/v4l2-common.h
@@ -65,6 +66,7 @@ struct sh_vou_device {
struct video_device vdev;
atomic_t use_count;
struct sh_vou_pdata *pdata;
+   struct clk *clk;
spinlock_t lock;
void __iomem *base;
/* State information */
@@ -1300,7 +1302,7 @@ static int sh_vou_probe(struct platform_device *pdev)
struct i2c_adapter *i2c_adap;
struct video_device *vdev;
struct sh_vou_device *vou_dev;
-   struct resource *reg_res, *region;
+   struct resource *reg_res;
struct v4l2_subdev *subdev;
int irq, ret;
 
@@ -1312,10 +1314,16 @@ static int sh_vou_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   vou_dev = kzalloc(sizeof(*vou_dev), GFP_KERNEL);
+   vou_dev = devm_kzalloc(pdev-dev, sizeof(*vou_dev), GFP_KERNEL);
if (!vou_dev)
return -ENOMEM;
 
+   vou_dev-clk = devm_clk_get(pdev-dev, sh-vou.0);
+   if (IS_ERR(vou_dev-clk)) {
+   dev_err(pdev-dev, cannot get clock\n);
+   return PTR_ERR(vou_dev-clk);
+   }
+
INIT_LIST_HEAD(vou_dev-queue);
spin_lock_init(vou_dev-lock);
mutex_init(vou_dev-fop_lock);
@@ -1340,28 +1348,18 @@ static int sh_vou_probe(struct platform_device *pdev)
pix-sizeimage  = VOU_MAX_IMAGE_WIDTH * 2 * 480;
pix-colorspace = V4L2_COLORSPACE_SMPTE170M;
 
-   region = request_mem_region(reg_res-start, resource_size(reg_res),
-   pdev-name);
-   if (!region) {
-   dev_err(pdev-dev, VOU region already claimed\n);
-   ret = -EBUSY;
-   goto ereqmemreg;
-   }
+   vou_dev-base = devm_ioremap_resource(pdev-dev, reg_res);
+   if (IS_ERR(vou_dev-base))
+   return PTR_ERR(vou_dev-base);
 
-   vou_dev-base = ioremap(reg_res-start, resource_size(reg_res));
-   if (!vou_dev-base) {
-   ret = -ENOMEM;
-   goto emap;
-   }
-
-   ret = request_irq(irq, sh_vou_isr, 0, vou, vou_dev);
+   ret = devm_request_irq(pdev-dev, irq, sh_vou_isr, 0, vou, vou_dev);
if (ret  0)
-   goto ereqirq;
+   return ret;
 
ret = v4l2_device_register(pdev-dev, vou_dev-v4l2_dev);
if (ret  0) {
dev_err(pdev-dev, Error registering v4l2 device\n);
-   goto ev4l2devreg;
+   return ret;
}
 
vdev = vou_dev-vdev;
@@ -1383,6 +1381,7 @@ static int sh_vou_probe(struct platform_device *pdev)
goto ei2cgadap;
}
 
+   clk_prepare_enable(vou_dev-clk);
ret = sh_vou_hw_init(vou_dev);
if (ret  0)
goto ereset;
@@ -1403,43 +1402,28 @@ static int sh_vou_probe(struct platform_device *pdev)
 evregdev:
 ei2cnd:
 ereset:
+   clk_disable_unprepare(vou_dev-clk);
i2c_put_adapter(i2c_adap);
 ei2cgadap:
pm_runtime_disable(pdev-dev);
v4l2_device_unregister(vou_dev-v4l2_dev);
-ev4l2devreg:
-   free_irq(irq, vou_dev);
-ereqirq:
-   iounmap(vou_dev-base);
-emap:
-   release_mem_region(reg_res-start, resource_size(reg_res));
-ereqmemreg:
-   kfree(vou_dev);
return ret;
 }
 
 static int sh_vou_remove(struct platform_device *pdev)
 {
-   int irq = platform_get_irq(pdev, 0);
struct v4l2_device 

[PATCH 05/10] sh-vou: fix incorrect initial pixelformat.

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

It was set to a format that wasn't supported.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 2adf16d..eaa432e 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -1376,7 +1376,7 @@ static int sh_vou_probe(struct platform_device *pdev)
rect-height= 480;
pix-width  = VOU_MAX_IMAGE_WIDTH;
pix-height = 480;
-   pix-pixelformat= V4L2_PIX_FMT_YVYU;
+   pix-pixelformat= V4L2_PIX_FMT_NV16;
pix-field  = V4L2_FIELD_NONE;
pix-bytesperline   = VOU_MAX_IMAGE_WIDTH * 2;
pix-sizeimage  = VOU_MAX_IMAGE_WIDTH * 2 * 480;
-- 
2.1.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 03/10] sh-vou: use v4l2_fh

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This allows us to drop the use_count and you get free G/S_PRIORITY support.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index ba1a16c..a75e6fa 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -64,7 +64,6 @@ enum sh_vou_status {
 struct sh_vou_device {
struct v4l2_device v4l2_dev;
struct video_device vdev;
-   atomic_t use_count;
struct sh_vou_pdata *pdata;
struct clk *clk;
spinlock_t lock;
@@ -81,6 +80,7 @@ struct sh_vou_device {
 };
 
 struct sh_vou_file {
+   struct v4l2_fh fh;
struct videobuf_queue vbq;
 };
 
@@ -1175,20 +1175,24 @@ static int sh_vou_open(struct file *file)
 
dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
 
+   v4l2_fh_init(vou_file-fh, vou_dev-vdev);
if (mutex_lock_interruptible(vou_dev-fop_lock)) {
kfree(vou_file);
return -ERESTARTSYS;
}
-   if (atomic_inc_return(vou_dev-use_count) == 1) {
+   v4l2_fh_add(vou_file-fh);
+   if (v4l2_fh_is_singular(vou_file-fh)) {
int ret;
+
/* First open */
vou_dev-status = SH_VOU_INITIALISING;
pm_runtime_get_sync(vou_dev-v4l2_dev.dev);
ret = sh_vou_hw_init(vou_dev);
if (ret  0) {
-   atomic_dec(vou_dev-use_count);
pm_runtime_put(vou_dev-v4l2_dev.dev);
vou_dev-status = SH_VOU_IDLE;
+   v4l2_fh_del(vou_file-fh);
+   v4l2_fh_exit(vou_file-fh);
mutex_unlock(vou_dev-fop_lock);
kfree(vou_file);
return ret;
@@ -1215,14 +1219,16 @@ static int sh_vou_release(struct file *file)
 
dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
 
-   if (!atomic_dec_return(vou_dev-use_count)) {
-   mutex_lock(vou_dev-fop_lock);
+   mutex_lock(vou_dev-fop_lock);
+   if (v4l2_fh_is_singular(vou_file-fh)) {
/* Last close */
vou_dev-status = SH_VOU_IDLE;
sh_vou_reg_a_set(vou_dev, VOUER, 0, 0x101);
pm_runtime_put(vou_dev-v4l2_dev.dev);
-   mutex_unlock(vou_dev-fop_lock);
}
+   v4l2_fh_del(vou_file-fh);
+   v4l2_fh_exit(vou_file-fh);
+   mutex_unlock(vou_dev-fop_lock);
 
file-private_data = NULL;
kfree(vou_file);
@@ -1329,7 +1335,6 @@ static int sh_vou_probe(struct platform_device *pdev)
INIT_LIST_HEAD(vou_dev-queue);
spin_lock_init(vou_dev-lock);
mutex_init(vou_dev-fop_lock);
-   atomic_set(vou_dev-use_count, 0);
vou_dev-pdata = vou_pdata;
vou_dev-status = SH_VOU_IDLE;
 
-- 
2.1.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 02/10] sh-vou: fix querycap support

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Fix v4l2-compliance errors due to empty driver and bus_info fields.

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

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 9e98233..ba1a16c 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -398,6 +398,8 @@ static int sh_vou_querycap(struct file *file, void  *priv,
dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
 
strlcpy(cap-card, SuperH VOU, sizeof(cap-card));
+   strlcpy(cap-driver, sh-vou, sizeof(cap-driver));
+   strlcpy(cap-bus_info, platform:sh-vou, sizeof(cap-bus_info));
cap-device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
cap-capabilities = cap-device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
-- 
2.1.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 00/10] sh-vou: fixes, convert to vb2

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This driver no longer works and uses old v4l2 frameworks. This patch series
updates the driver so it is once again working and is up to date.

It now passes the v4l2-compliance tests as well.

This has been tested with my Renesas development board.

Regards,

Hans

Hans Verkuil (10):
  sh-vou: hook up the clock correctly
  sh-vou: fix querycap support
  sh-vou: use v4l2_fh
  sh-vou: support compulsory G/S/ENUM_OUTPUT ioctls
  sh-vou: fix incorrect initial pixelformat.
  sh-vou: replace g/s_crop/cropcap by g/s_selection
  sh-vou: add support for log_status
  sh-vou: let sh_vou_s_fmt_vid_out call sh_vou_try_fmt_vid_out
  sh-vou: fix bytesperline
  sh-vou: convert to vb2

 arch/sh/kernel/cpu/sh4a/clock-sh7724.c |   2 +-
 drivers/media/platform/sh_vou.c| 825 +++--
 2 files changed, 381 insertions(+), 446 deletions(-)

-- 
2.1.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 06/10] sh-vou: replace g/s_crop/cropcap by g/s_selection

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Implement g/s_selection. The v4l2 core will emulate g/s_crop and
cropcap on top of g/s_selection.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 71 +++--
 1 file changed, 25 insertions(+), 46 deletions(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index eaa432e..7ed5a8b 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -951,24 +951,36 @@ static int sh_vou_g_std(struct file *file, void *priv, 
v4l2_std_id *std)
return 0;
 }
 
-static int sh_vou_g_crop(struct file *file, void *fh, struct v4l2_crop *a)
+static int sh_vou_g_selection(struct file *file, void *fh,
+ struct v4l2_selection *sel)
 {
struct sh_vou_device *vou_dev = video_drvdata(file);
 
-   dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
-
-   a-type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-   a-c = vou_dev-rect;
-
+   if (sel-type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+   switch (sel-target) {
+   case V4L2_SEL_TGT_COMPOSE:
+   sel-r = vou_dev-rect;
+   break;
+   case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+   case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+   sel-r.left = 0;
+   sel-r.top = 0;
+   sel-r.width = VOU_MAX_IMAGE_WIDTH;
+   sel-r.height = VOU_MAX_IMAGE_HEIGHT;
+   break;
+   default:
+   return -EINVAL;
+   }
return 0;
 }
 
 /* Assume a dull encoder, do all the work ourselves. */
-static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop 
*a)
+static int sh_vou_s_selection(struct file *file, void *fh,
+ struct v4l2_selection *sel)
 {
-   struct v4l2_crop a_writable = *a;
+   struct v4l2_rect *rect = sel-r;
struct sh_vou_device *vou_dev = video_drvdata(file);
-   struct v4l2_rect *rect = a_writable.c;
struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT};
struct v4l2_pix_format *pix = vou_dev-pix;
struct sh_vou_geometry geo;
@@ -982,10 +994,8 @@ static int sh_vou_s_crop(struct file *file, void *fh, 
const struct v4l2_crop *a)
unsigned int img_height_max;
int ret;
 
-   dev_dbg(vou_dev-v4l2_dev.dev, %s(): %ux%u@%u:%u\n, __func__,
-   rect-width, rect-height, rect-left, rect-top);
-
-   if (a-type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   if (sel-type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
+   sel-target != V4L2_SEL_TGT_COMPOSE)
return -EINVAL;
 
if (vou_dev-std  V4L2_STD_525_60)
@@ -1049,36 +1059,6 @@ static int sh_vou_s_crop(struct file *file, void *fh, 
const struct v4l2_crop *a)
return 0;
 }
 
-/*
- * Total field: NTSC 858 x 2 * 262/263, PAL 864 x 2 * 312/313, default 
rectangle
- * is the initial register values, height takes the interlaced format into
- * account. The actual image can only go up to 720 x 2 * 240, So, VOUVPR can
- * actually only meaningfully contain values = 720 and = 240 respectively, 
and
- * not = 864 and = 312.
- */
-static int sh_vou_cropcap(struct file *file, void *priv,
- struct v4l2_cropcap *a)
-{
-   struct sh_vou_device *vou_dev = video_drvdata(file);
-
-   dev_dbg(vou_dev-v4l2_dev.dev, %s()\n, __func__);
-
-   a-type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-   a-bounds.left  = 0;
-   a-bounds.top   = 0;
-   a-bounds.width = VOU_MAX_IMAGE_WIDTH;
-   a-bounds.height= VOU_MAX_IMAGE_HEIGHT;
-   /* Default = max, set VOUDPR = 0, which is not hardware default */
-   a-defrect.left = 0;
-   a-defrect.top  = 0;
-   a-defrect.width= VOU_MAX_IMAGE_WIDTH;
-   a-defrect.height   = VOU_MAX_IMAGE_HEIGHT;
-   a-pixelaspect.numerator= 1;
-   a-pixelaspect.denominator  = 1;
-
-   return 0;
-}
-
 static irqreturn_t sh_vou_isr(int irq, void *dev_id)
 {
struct sh_vou_device *vou_dev = dev_id;
@@ -1307,9 +1287,8 @@ static const struct v4l2_ioctl_ops sh_vou_ioctl_ops = {
.vidioc_enum_output = sh_vou_enum_output,
.vidioc_s_std   = sh_vou_s_std,
.vidioc_g_std   = sh_vou_g_std,
-   .vidioc_cropcap = sh_vou_cropcap,
-   .vidioc_g_crop  = sh_vou_g_crop,
-   .vidioc_s_crop  = sh_vou_s_crop,
+   .vidioc_g_selection = sh_vou_g_selection,
+   .vidioc_s_selection = sh_vou_s_selection,
 };
 
 static const struct v4l2_file_operations sh_vou_fops = {
-- 
2.1.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 

[PATCH 04/10] sh-vou: support compulsory G/S/ENUM_OUTPUT ioctls

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Video output drivers must support these ioctls. Otherwise applications
cannot deduce that these outputs exist and what capabilities they have.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/sh_vou.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index a75e6fa..2adf16d 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -874,6 +874,30 @@ static int sh_vou_streamoff(struct file *file, void *priv,
return 0;
 }
 
+static int sh_vou_enum_output(struct file *file, void *fh,
+ struct v4l2_output *a)
+{
+   struct sh_vou_device *vou_dev = video_drvdata(file);
+
+   if (a-index)
+   return -EINVAL;
+   strlcpy(a-name, Video Out, sizeof(a-name));
+   a-type = V4L2_OUTPUT_TYPE_ANALOG;
+   a-std = vou_dev-vdev.tvnorms;
+   return 0;
+}
+
+int sh_vou_g_output(struct file *file, void *fh, unsigned int *i)
+{
+   *i = 0;
+   return 0;
+}
+
+int sh_vou_s_output(struct file *file, void *fh, unsigned int i)
+{
+   return i ? -EINVAL : 0;
+}
+
 static u32 sh_vou_ntsc_mode(enum sh_vou_bus_fmt bus_fmt)
 {
switch (bus_fmt) {
@@ -1278,6 +1302,9 @@ static const struct v4l2_ioctl_ops sh_vou_ioctl_ops = {
.vidioc_dqbuf   = sh_vou_dqbuf,
.vidioc_streamon= sh_vou_streamon,
.vidioc_streamoff   = sh_vou_streamoff,
+   .vidioc_g_output= sh_vou_g_output,
+   .vidioc_s_output= sh_vou_s_output,
+   .vidioc_enum_output = sh_vou_enum_output,
.vidioc_s_std   = sh_vou_s_std,
.vidioc_g_std   = sh_vou_g_std,
.vidioc_cropcap = sh_vou_cropcap,
-- 
2.1.4

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


Re: [ATTN 0/9] SDR transmitter API

2015-06-05 Thread Antti Palosaari

On 06/05/2015 12:50 PM, Hans Verkuil wrote:

Hi Antti,

FYI: don't use ATTN as prefix: patchwork doesn't pick that up as a patch,
and if it doesn't appear there, then it is likely to be forgotten.

Can you repost it with the correct prefix? It's so much easier to process
for me if it ends up in patchwork...


Which is correct prefix?

Earlier I used PATCH RFC, but then I saw that ATTN:
[ANN] Report on the San Jose V4L/DVB mini-summit
http://www.spinics.net/lists/linux-media/msg76281.html

- Add 'ATTN' inside pull request subject line tp indicate that Mauro's 
(or some other maintainer's) attention is required. Should be limited to 
api changes, dependencies.


OK, it speaks only pull request, but that was patchset having API changes...

regards
Antti



--
http://palosaari.fi/
--
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] [media] vivid: don't use more than 1024 bytes of stack

2015-06-05 Thread Hans Verkuil
On 06/05/2015 12:29 PM, Mauro Carvalho Chehab wrote:
 Remove the following compilation warnings:
 
   drivers/media/platform/vivid/vivid-tpg.c: In function 'tpg_gen_text':
   drivers/media/platform/vivid/vivid-tpg.c:1562:1: warning: the frame 
 size of 1308 bytes is larger than 1024 bytes [-Wframe-larger-than=]
}
^
 
 This seems to be due to some bad optimization done by gcc.
 
 Moving the for() loop to happen inside the macro solves the
 issue.

Huh, interesting. I'd never have guessed that.

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

Thanks for looking at this!

Hans

 
 While here, fix CodingStyle at the switch().
 
 Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
 
 diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
 b/drivers/media/platform/vivid/vivid-tpg.c
 index b1147f2df26c..7a3ed580626a 100644
 --- a/drivers/media/platform/vivid/vivid-tpg.c
 +++ b/drivers/media/platform/vivid/vivid-tpg.c
 @@ -1492,12 +1492,10 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
 *basep[TPG_MAX_PLANES][2],
   else if (tpg-field == V4L2_FIELD_SEQ_TB || tpg-field == 
 V4L2_FIELD_SEQ_BT)
   div = 2;
  
 - for (p = 0; p  tpg-planes; p++) {
 - unsigned vdiv = tpg-vdownsampling[p];
 - unsigned hdiv = tpg-hdownsampling[p];
 -
 - /* Print text */
 -#define PRINTSTR(PIXTYPE) do {   \
 + /* Print text */
 +#define PRINTSTR(PIXTYPE) for (p = 0; p  tpg-planes; p++) {\
 + unsigned vdiv = tpg-vdownsampling[p];  \
 + unsigned hdiv = tpg-hdownsampling[p];  \
   PIXTYPE fg; \
   PIXTYPE bg; \
   memcpy(fg, tpg-textfg[p], sizeof(PIXTYPE));   \
 @@ -1548,16 +1546,19 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
 *basep[TPG_MAX_PLANES][2],
   }   \
  } while (0)
  
 - switch (tpg-twopixelsize[p]) {
 - case 2:
 - PRINTSTR(u8); break;
 - case 4:
 - PRINTSTR(u16); break;
 - case 6:
 - PRINTSTR(x24); break;
 - case 8:
 - PRINTSTR(u32); break;
 - }
 + switch (tpg-twopixelsize[p]) {
 + case 2:
 + PRINTSTR(u8);
 + break;
 + case 4:
 + PRINTSTR(u16);
 + break;
 + case 6:
 + PRINTSTR(x24);
 + break;
 + case 8:
 + PRINTSTR(u32);
 + break;
   }
  }
  
 

--
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] lmedm04: Enable dont_poll for TS2020 tuner.

2015-06-05 Thread Malcolm Priestley
Following a change made to TS2020 tuner in patches
ts2020: Provide DVBv5 API signal strength
ts2020: Allow stats polling to be suppressed

Polling on the driver must be suppressed because
the demuxer is stopped by I2C messages.

Signed-off-by: Malcolm Priestley tvbox...@gmail.com
---
 drivers/media/usb/dvb-usb-v2/lmedm04.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c 
b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 5de6f7c..f1983f2 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -799,6 +799,7 @@ static struct m88rs2000_config m88rs2000_config = {
 static struct ts2020_config ts2020_config = {
.tuner_address = 0x60,
.clk_out_div = 7,
+   .dont_poll = true
 };
 
 static int dm04_lme2510_set_voltage(struct dvb_frontend *fe,
-- 
2.1.4

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


Re: [PATCH] [media] v4l2-ioctl: Give more information when device_caps are missing

2015-06-05 Thread Hans Verkuil
On 06/02/2015 09:07 PM, Laura Abbott wrote:
 Currently, the warning for missing device_caps gives a backtrace like so:
 
 [8175c199] dump_stack+0x45/0x57
 [8109ad5a] warn_slowpath_common+0x8a/0xc0
 [8109ae8a] warn_slowpath_null+0x1a/0x20
 [a0237453] v4l_querycap+0x43/0x80 [videodev]
 [a0237734] __video_do_ioctl+0x2a4/0x320 [videodev]
 [812207e5] ? do_last+0x195/0x1210
 [a023a11e] video_usercopy+0x22e/0x5b0 [videodev]
 [a0237490] ? v4l_querycap+0x80/0x80 [videodev]
 [a023a4b5] video_ioctl2+0x15/0x20 [videodev]
 [a0233733] v4l2_ioctl+0x113/0x150 [videodev]
 [81225798] do_vfs_ioctl+0x2f8/0x4f0
 [8113b2d4] ? __audit_syscall_entry+0xb4/0x110
 [81022d7c] ? do_audit_syscall_entry+0x6c/0x70
 [81225a11] SyS_ioctl+0x81/0xa0
 [8113b526] ? __audit_syscall_exit+0x1f6/0x2a0
 [81763549] system_call_fastpath+0x12/0x17
 
 This indicates that device_caps are missing but doesn't give
 much of a clue which driver is actually at fault. Improve
 the warning output by showing the capabilities and which
 operations set the capabilities.
 
 Signed-off-by: Laura Abbott labb...@fedoraproject.org
 ---
  drivers/media/v4l2-core/v4l2-ioctl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
 b/drivers/media/v4l2-core/v4l2-ioctl.c
 index aa407cb..e509608 100644
 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
 @@ -1023,8 +1023,9 @@ static int v4l_querycap(const struct v4l2_ioctl_ops 
 *ops,
* Drivers MUST fill in device_caps, so check for this and
* warn if it was forgotten.
*/
 - WARN_ON(!(cap-capabilities  V4L2_CAP_DEVICE_CAPS) ||
 - !cap-device_caps);
 + WARN(!(cap-capabilities  V4L2_CAP_DEVICE_CAPS) ||
 + !cap-device_caps, Bad caps for ops %pS, %x %x,
 + ops, cap-capabilities, cap-device_caps);

Why not just print cap-driver? Much simpler and it always works!

Regards,

Hans

   cap-device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
  
   return ret;
 

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


[bp:for-next 15/22] drivers/edac/mce_amd_inj.c:47:21: sparse: symbol 'inj_type' was not declared. Should it be static?

2015-06-05 Thread kbuild test robot
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp for-next
head:   6db4e6b99ba0dad4e42612a546a99ccdbd766561
commit: 0451d14d05618e5fcbdc5017a30e3d609ddc8229 [15/22] EDAC, mce_amd_inj: 
Modify flags attribute to use string arguments
reproduce:
  # apt-get install sparse
  git checkout 0451d14d05618e5fcbdc5017a30e3d609ddc8229
  make ARCH=x86_64 allmodconfig
  make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by )

 drivers/edac/mce_amd_inj.c:47:21: sparse: symbol 'inj_type' was not 
 declared. Should it be static?
   drivers/edac/mce_amd_inj.c:320:1: sparse: symbol 
'__UNIQUE_ID_author__COUNTER__' has multiple initializers (originally 
initialized at drivers/edac/mce_amd_inj.c:319)

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
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] radio-bcm2048: Fix region selection

2015-06-05 Thread Pali Rohár
On Friday 05 June 2015 13:36:40 Hans Verkuil wrote:
 On 05/15/2015 11:32 PM, Pali Rohár wrote:
  From: maxx m...@spaceboyz.net
  
  This actually fixes region selection for BCM2048 FM receiver. To select
  the japanese FM-band an additional bit in FM_CTRL register needs to be
  set. This might not sound so important but it enables at least me to
  listen to some 'very interesting' radio transmission below normal
  FM-band.
  
  Patch writen by m...@spaceboyz.net
  
  Signed-off-by: Pali Rohár pali.ro...@gmail.com
  Cc: m...@spaceboyz.net
 
 Looks good to me. If someone can repost with correct names and SoBs, then I'll
 apply.
 

Jan, will you resend patch in correct format with correct names?

-- 
Pali Rohár
pali.ro...@gmail.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


Re: [ATTN 0/9] SDR transmitter API

2015-06-05 Thread Hans Verkuil
Hi Antti,

FYI: don't use ATTN as prefix: patchwork doesn't pick that up as a patch,
and if it doesn't appear there, then it is likely to be forgotten.

Can you repost it with the correct prefix? It's so much easier to process
for me if it ends up in patchwork...

Thanks!

Hans

On 05/26/2015 07:08 PM, Antti Palosaari wrote:
 That patch set adds V4L2 API support for SDR transmitters, with real
 life working example driver - HackRF.
 
 It also contains small change for old SDR API as I decided to rename
 tuner type from V4L2_TUNER_ADC to V4L2_TUNER_SDR. ADC is SDR receiver
 and DAC is SDR transmitter, so I eventually though it is better to
 rename ADC to common term than add new type for DAC. Old type works
 of course, it is defined also in order to avoid API breakage.
 
 Most of the V4L implementation stuff is pretty trivial, ~copy  paste
 from the SDR receiver.
 
 New capability flag V4L2_CAP_SDR_OUTPUT is added to indicate device
 is SDR transmitter.
 
 Old capability flag V4L2_CAP_MODULATOR is used to indicate there is
 'tuner' to set radio frequency for transmitter. That capability flag
 name is pretty misleading in a case of SDR as SDR does not have
 hardware modulator at all - but as it is existing flag it is hard to
 change anymore (V4L API uses term TUNER for radio receiver and
 MODULATOR for radio transmitter).
 
 New v4l2 buffer type V4L2_BUF_TYPE_SDR_OUTPUT.
 
 Transmitter format is negotiated similarly than receiver.
 
 regards
 Antti
 
 
 Antti Palosaari (9):
   v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR
   v4l2: add RF gain control
   DocBook: document tuner RF gain control
   v4l2: add support for SDR transmitter
   DocBook: document SDR transmitter
   hackrf: add control for RF amplifier
   hackrf: switch to single function which configures everything
   hackrf: add support for transmitter
   hackrf: do not set human readable name for formats
 
  Documentation/DocBook/media/v4l/compat.xml |   20 +
  Documentation/DocBook/media/v4l/controls.xml   |   19 +
  Documentation/DocBook/media/v4l/dev-sdr.xml|   32 +-
  Documentation/DocBook/media/v4l/io.xml |   10 +-
  Documentation/DocBook/media/v4l/pixfmt.xml |2 +-
  Documentation/DocBook/media/v4l/v4l2.xml   |9 +
  Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |2 +-
  .../DocBook/media/v4l/vidioc-querycap.xml  |6 +
  drivers/media/usb/hackrf/hackrf.c  | 1019 
 ++--
  drivers/media/v4l2-core/v4l2-ctrls.c   |4 +
  drivers/media/v4l2-core/v4l2-dev.c |   14 +-
  drivers/media/v4l2-core/v4l2-ioctl.c   |   31 +-
  drivers/media/v4l2-core/videobuf-core.c|4 +-
  include/media/v4l2-ioctl.h |8 +
  include/trace/events/v4l2.h|1 +
  include/uapi/linux/v4l2-controls.h |2 +
  include/uapi/linux/videodev2.h |   10 +-
  17 files changed, 898 insertions(+), 295 deletions(-)
 

--
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] [media] vivid: don't use more than 1024 bytes of stack

2015-06-05 Thread Mauro Carvalho Chehab
Em Fri, 05 Jun 2015 12:33:04 +0200
Hans Verkuil hverk...@xs4all.nl escreveu:

 On 06/05/2015 12:29 PM, Mauro Carvalho Chehab wrote:
  Remove the following compilation warnings:
  
  drivers/media/platform/vivid/vivid-tpg.c: In function 'tpg_gen_text':
  drivers/media/platform/vivid/vivid-tpg.c:1562:1: warning: the frame 
  size of 1308 bytes is larger than 1024 bytes [-Wframe-larger-than=]
   }
   ^
  
  This seems to be due to some bad optimization done by gcc.
  
  Moving the for() loop to happen inside the macro solves the
  issue.
 
 Huh, interesting. I'd never have guessed that.

Yeah, this fix is not too logical ;) It looks that GCC is doing some
very weird optimizations when the loop is outside the macro.


 
 Acked-by: Hans Verkuil hans.verk...@cisco.com
 
 Thanks for looking at this!

This was bothering me for a while. I had to do something ;)

 
   Hans
 
  
  While here, fix CodingStyle at the switch().
  
  Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
  
  diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
  b/drivers/media/platform/vivid/vivid-tpg.c
  index b1147f2df26c..7a3ed580626a 100644
  --- a/drivers/media/platform/vivid/vivid-tpg.c
  +++ b/drivers/media/platform/vivid/vivid-tpg.c
  @@ -1492,12 +1492,10 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
  *basep[TPG_MAX_PLANES][2],
  else if (tpg-field == V4L2_FIELD_SEQ_TB || tpg-field == 
  V4L2_FIELD_SEQ_BT)
  div = 2;
   
  -   for (p = 0; p  tpg-planes; p++) {
  -   unsigned vdiv = tpg-vdownsampling[p];
  -   unsigned hdiv = tpg-hdownsampling[p];
  -
  -   /* Print text */
  -#define PRINTSTR(PIXTYPE) do { \
  +   /* Print text */
  +#define PRINTSTR(PIXTYPE) for (p = 0; p  tpg-planes; p++) {  \
  +   unsigned vdiv = tpg-vdownsampling[p];  \
  +   unsigned hdiv = tpg-hdownsampling[p];  \
  PIXTYPE fg; \
  PIXTYPE bg; \
  memcpy(fg, tpg-textfg[p], sizeof(PIXTYPE));   \
  @@ -1548,16 +1546,19 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
  *basep[TPG_MAX_PLANES][2],
  }   \
   } while (0)
   
  -   switch (tpg-twopixelsize[p]) {
  -   case 2:
  -   PRINTSTR(u8); break;
  -   case 4:
  -   PRINTSTR(u16); break;
  -   case 6:
  -   PRINTSTR(x24); break;
  -   case 8:
  -   PRINTSTR(u32); break;
  -   }
  +   switch (tpg-twopixelsize[p]) {
  +   case 2:
  +   PRINTSTR(u8);
  +   break;
  +   case 4:
  +   PRINTSTR(u16);
  +   break;
  +   case 6:
  +   PRINTSTR(x24);
  +   break;
  +   case 8:
  +   PRINTSTR(u32);
  +   break;
  }
   }
   
  
 
--
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] stk1160: Add frame scaling support

2015-06-05 Thread Hans Verkuil
Hi Ezequiel,

As mentioned in irc: run v4l2-compliance -s and v4l2-compliance -f.
I quickly tried it and v4l2-compliance fails:

Test input 0:

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 7 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
fail: v4l2-test-formats.cpp(422): !pix.width || !pix.height
fail: v4l2-test-formats.cpp(726): Video Capture is valid, but 
TRY_FMT failed to return a format
test VIDIOC_TRY_FMT: FAIL
fail: v4l2-test-formats.cpp(422): !pix.width || !pix.height
fail: v4l2-test-formats.cpp(942): Video Capture is valid, but 
no S_FMT was implemented
test VIDIOC_S_FMT: FAIL
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)

and it ends with a segfault and this in the kernel log:

[  180.135178] stk1160: width 720, height 480
[  180.135187] stk1160: width 0, height 0
[  180.135240] stk1160: width 0, height 0
[  180.135317] stk1160: decimate 0x1f, column units -721, row units -481
[  180.135450] stk1160: width 1, height 1
[  180.135524] stk1160: decimate 0x1f, column units 719, row units 479
[  180.135572] stk1160: width 720, height 480
[  180.135701] stk1160: decimate 0x10, column units 0, row units 0
[  180.135750] divide error:  [#1] PREEMPT SMP 
[  180.135773] Modules linked in: stk1160 ivtv_alsa tuner_simple tuner_types 
tda9887 tda8290 tuner msp3400 saa7127 ivtv saa7115 videobuf2_vmalloc tveeprom 
videobuf2_memops videobuf2_core cx2341x v4l2_common videodev media 
x86_pkg_temp_thermal processor button [last unloaded: stk1160]
[  180.135851] CPU: 2 PID: 7391 Comm: v4l2-compliance Not tainted 
4.1.0-rc3-koryphon #837
[  180.135862] Hardware name: ASUSTeK COMPUTER INC. Z10PA-U8 Series/Z10PA-U8 
Series, BIOS 0303 11/20/2014
[  180.135873] task: 8810364b1830 ti: 88100c794000 task.ti: 
88100c794000
[  180.135882] RIP: 0010:[a003ed9a]  [a003ed9a] 
stk1160_try_fmt.isra.5+0x1ba/0x1e0 [stk1160]
[  180.135902] RSP: 0018:88100c797bd8  EFLAGS: 00010202
[  180.135910] RAX: 02d0 RBX:  RCX: 88100c797c14
[  180.135918] RDX:  RSI: 8810364107c0 RDI: 01e0
[  180.135927] RBP: 88100c797bf8 R08: 881036537500 R09: 01e0
[  180.135939] R10:  R11: 0005 R12: 
[  180.135948] R13:  R14: 0001 R15: 
[  180.135958] FS:  7f7acbad8740() GS:88107fc8() 
knlGS:
[  180.135968] CS:  0010 DS:  ES:  CR0: 80050033
[  180.135975] CR2: 7faa881e4148 CR3: 00102974d000 CR4: 001406e0
[  180.135984] Stack:
[  180.136003]  88103641  881036537500 
881036536c00
[  180.136018]  88100c797c48 a003ee4b 88100c797c58 
81a0dbc2
[  180.136033]  00010001  88100c797c48 
881036537500
[  180.136048] Call Trace:
[  180.136057]  [a003ee4b] vidioc_s_fmt_vid_cap+0x4b/0xf0 [stk1160]
[  180.136073]  [a074e163] v4l_s_fmt+0x123/0x490 [videodev]
[  180.136086]  [a074d294] __video_do_ioctl+0x274/0x310 [videodev]
[  180.136099]  [a074ee4a] ? video_usercopy+0x2fa/0x4c0 [videodev]
[  180.136111]  [a074ee86] video_usercopy+0x336/0x4c0 [videodev]
[  180.136122]  [a074d020] ? v4l_querycap+0x60/0x60 [videodev]
[  180.136135]  [813dea63] ? __this_cpu_preempt_check+0x13/0x20
[  180.136146]  [810d325f] ? __srcu_read_lock+0x5f/0xa0
[  180.136157]  [a074f020] video_ioctl2+0x10/0x20 [videodev]
[  180.136168]  [a07486a0] v4l2_ioctl+0xd0/0xf0 [videodev]
[  180.136179]  [8118fc60] do_vfs_ioctl+0x2e0/0x4e0
[  180.136187]  [8117bccc] ? vfs_write+0x14c/0x1b0
[  180.136196]  [8118fee1] SyS_ioctl+0x81/0xa0
[  180.136208]  [81a1266e] system_call_fastpath+0x12/0x71
[  180.136216] Code: 31 d2 41 89 c1 41 89 40 0c e9 d0 fe ff ff 0f 1f 00 44 89 
d0 41 be 01 00 00 00 45 31 ed c1 e8 1f 44 01 d0 d1 f8 05 d0 02 00 00 99 41 f7 
fa 31 d2 41 89 c2 44 8d 60 ff b8 d0 02 00 00 41 f7 f2 41 
[  180.136354] RIP  [a003ed9a] stk1160_try_fmt.isra.5+0x1ba/0x1e0 
[stk1160]
[  180.136366]  RSP 88100c797bd8
[  180.139977] ---[ end trace a699ade0cf2b43de ]---

So this needs a bit more work... Remember: 

[PATCH bp] EDAC, mce_amd_inj: inj_type can be static

2015-06-05 Thread kbuild test robot

Signed-off-by: Fengguang Wu fengguang...@intel.com
---
 mce_amd_inj.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
index 2a0c829..46a6b0e 100644
--- a/drivers/edac/mce_amd_inj.c
+++ b/drivers/edac/mce_amd_inj.c
@@ -44,7 +44,7 @@ static const char * const flags_options[] = {
 };
 
 /* Set default injection to SW_INJ */
-enum injection_type inj_type = SW_INJ;
+static enum injection_type inj_type = SW_INJ;
 
 #define MCE_INJECT_SET(reg)\
 static int inj_##reg##_set(void *data, u64 val)
\
--
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] radio-bcm2048: Enable access to automute and ctrl registers

2015-06-05 Thread Hans Verkuil
On 05/15/2015 11:31 PM, Pali Rohár wrote:
 From: maxx m...@spaceboyz.net
 
 This enables access to automute function of the chip via sysfs and
 gives direct access to FM_AUDIO_CTRL0/1 registers, also via sysfs. I
 don't think this is so important but helps in developing radio scanner
 apps.
 
 Patch writen by m...@spaceboyz.net
 
 Signed-off-by: Pali Rohár pali.ro...@gmail.com
 Cc: m...@spaceboyz.net

As Pavel mentioned, these patches need to be resend with correct Signed-off-by
lines.

Regarding this patch: I don't want to apply this since this really should be a
control. Or just enable it always. If someone wants to make this a control, then
let me know: there are two other drivers with an AUTOMUTE control: bttv and 
saa7134.

In both cases it is implemented as a private control, but it makes sense to
promote this to a standard user control. I can make a patch for that.

And for CTRL0/1: if you want direct register access, then implement
VIDIOC_DBG_G/S_REGISTER. This makes sure you have the right permissions etc.

More importantly: is anyone working on getting this driver out of staging? It's
been here for about a year and a half and I haven't seen any efforts to clean 
it up.

The whole sysfs part is out-of-spec and is another reason why I won't apply this
patch as is. Adding code to things that should go away isn't good...

So:

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

Regards,

Hans

 ---
  drivers/staging/media/bcm2048/radio-bcm2048.c |   96 
 +
  1 file changed, 96 insertions(+)
 
 diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
 b/drivers/staging/media/bcm2048/radio-bcm2048.c
 index 1482d4b..8f9ba7b 100644
 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
 +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
 @@ -826,6 +826,93 @@ static int bcm2048_get_mute(struct bcm2048_device *bdev)
   return err;
  }
  
 +static int bcm2048_set_automute(struct bcm2048_device *bdev, u8 automute)
 +{
 + int err;
 +
 + mutex_lock(bdev-mutex);
 +
 + err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_PAUSE, automute);
 +
 + mutex_unlock(bdev-mutex);
 + return err;
 +}
 +
 +static int bcm2048_get_automute(struct bcm2048_device *bdev)
 +{
 + int err;
 + u8 value;
 +
 + mutex_lock(bdev-mutex);
 +
 + err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_PAUSE, value);
 +
 + mutex_unlock(bdev-mutex);
 +
 + if (!err)
 + err = value;
 +
 + return err;
 +}
 +
 +static int bcm2048_set_ctrl0(struct bcm2048_device *bdev, u8 value)
 +{
 + int err;
 +
 + mutex_lock(bdev-mutex);
 +
 + err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, value);
 +
 + mutex_unlock(bdev-mutex);
 + return err;
 +}
 +
 +static int bcm2048_set_ctrl1(struct bcm2048_device *bdev, u8 value)
 +{
 + int err;
 +
 + mutex_lock(bdev-mutex);
 +
 + err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL1, value);
 +
 + mutex_unlock(bdev-mutex);
 + return err;
 +}
 +
 +static int bcm2048_get_ctrl0(struct bcm2048_device *bdev)
 +{
 + int err;
 + u8 value;
 +
 + mutex_lock(bdev-mutex);
 +
 + err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, value);
 +
 + mutex_unlock(bdev-mutex);
 +
 + if (!err)
 + err = value;
 +
 + return err;
 +}
 +
 +static int bcm2048_get_ctrl1(struct bcm2048_device *bdev)
 +{
 + int err;
 + u8 value;
 +
 + mutex_lock(bdev-mutex);
 +
 + err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL1, value);
 +
 + mutex_unlock(bdev-mutex);
 +
 + if (!err)
 + err = value;
 +
 + return err;
 +}
 +
  static int bcm2048_set_audio_route(struct bcm2048_device *bdev, u8 route)
  {
   int err;
 @@ -2058,6 +2145,9 @@ static ssize_t bcm2048_##prop##_read(struct device 
 *dev,\
  
  DEFINE_SYSFS_PROPERTY(power_state, unsigned, int, %u, 0)
  DEFINE_SYSFS_PROPERTY(mute, unsigned, int, %u, 0)
 +DEFINE_SYSFS_PROPERTY(automute, unsigned, int, %x, 0)
 +DEFINE_SYSFS_PROPERTY(ctrl0, unsigned, int, %x, 0)
 +DEFINE_SYSFS_PROPERTY(ctrl1, unsigned, int, %x, 0)
  DEFINE_SYSFS_PROPERTY(audio_route, unsigned, int, %u, 0)
  DEFINE_SYSFS_PROPERTY(dac_output, unsigned, int, %u, 0)
  
 @@ -2095,6 +2185,12 @@ static struct device_attribute attrs[] = {
   bcm2048_power_state_write),
   __ATTR(mute, S_IRUGO | S_IWUSR, bcm2048_mute_read,
   bcm2048_mute_write),
 + __ATTR(automute, S_IRUGO | S_IWUSR, bcm2048_automute_read,
 + bcm2048_automute_write),
 + __ATTR(ctrl0, S_IRUGO | S_IWUSR, bcm2048_ctrl0_read,
 + bcm2048_ctrl0_write),
 + __ATTR(ctrl1, S_IRUGO | S_IWUSR, bcm2048_ctrl1_read,
 + bcm2048_ctrl1_write),
   __ATTR(audio_route, S_IRUGO | S_IWUSR, bcm2048_audio_route_read,
   bcm2048_audio_route_write),
   __ATTR(dac_output, S_IRUGO | S_IWUSR, bcm2048_dac_output_read,
 

--
To unsubscribe from this list: 

Re: [PATCH] radio-bcm2048: Fix region selection

2015-06-05 Thread Hans Verkuil
On 05/15/2015 11:32 PM, Pali Rohár wrote:
 From: maxx m...@spaceboyz.net
 
 This actually fixes region selection for BCM2048 FM receiver. To select
 the japanese FM-band an additional bit in FM_CTRL register needs to be
 set. This might not sound so important but it enables at least me to
 listen to some 'very interesting' radio transmission below normal
 FM-band.
 
 Patch writen by m...@spaceboyz.net
 
 Signed-off-by: Pali Rohár pali.ro...@gmail.com
 Cc: m...@spaceboyz.net

Looks good to me. If someone can repost with correct names and SoBs, then I'll
apply.

Regards,

Hans

 ---
  drivers/staging/media/bcm2048/radio-bcm2048.c |   13 +
  1 file changed, 13 insertions(+)
 
 diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
 b/drivers/staging/media/bcm2048/radio-bcm2048.c
 index aeb6c3c..1482d4b 100644
 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
 +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
 @@ -739,7 +739,20 @@ static int bcm2048_set_region(struct bcm2048_device 
 *bdev, u8 region)
   return -EINVAL;
  
   mutex_lock(bdev-mutex);
 +
   bdev-region_info = region_configs[region];
 +
 + bdev-cache_fm_ctrl = ~BCM2048_BAND_SELECT;
 + if (region  2) {
 + bdev-cache_fm_ctrl |= BCM2048_BAND_SELECT;
 + err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL,
 + bdev-cache_fm_ctrl);
 + if (err) {
 + mutex_unlock(bdev-mutex);
 + goto done;
 + }
 + }
 +
   mutex_unlock(bdev-mutex);
  
   if (bdev-frequency  region_configs[region].bottom_frequency ||
 

--
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] Doc:nfc: Fix typo in nfc-hci.txt

2015-06-05 Thread Masanari Iida
This patch fix a spelling typo in nfc-hci.txt

Signed-off-by: Masanari Iida standby2...@gmail.com
---
 Documentation/nfc/nfc-hci.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/nfc/nfc-hci.txt b/Documentation/nfc/nfc-hci.txt
index 0686c9e..0dc078c 100644
--- a/Documentation/nfc/nfc-hci.txt
+++ b/Documentation/nfc/nfc-hci.txt
@@ -122,7 +122,7 @@ This must be done from a context that can sleep.
 PHY Management
 --
 
-The physical link (i2c, ...) management is defined by the following struture:
+The physical link (i2c, ...) management is defined by the following structure:
 
 struct nfc_phy_ops {
int (*write)(void *dev_id, struct sk_buff *skb);
-- 
2.4.2.387.gf86f31a

--
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 bp] EDAC, mce_amd_inj: inj_type can be static

2015-06-05 Thread Borislav Petkov
On Fri, Jun 05, 2015 at 07:24:26PM +0800, kbuild test robot wrote:
 
 Signed-off-by: Fengguang Wu fengguang...@intel.com
 ---
  mce_amd_inj.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
 index 2a0c829..46a6b0e 100644
 --- a/drivers/edac/mce_amd_inj.c
 +++ b/drivers/edac/mce_amd_inj.c
 @@ -44,7 +44,7 @@ static const char * const flags_options[] = {
  };
  
  /* Set default injection to SW_INJ */
 -enum injection_type inj_type = SW_INJ;
 +static enum injection_type inj_type = SW_INJ;
  
  #define MCE_INJECT_SET(reg)  \
  static int inj_##reg##_set(void *data, u64 val)  
 \

Thanks kbuild test robot, applied!

:-D

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
--
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 07/10] sh-vou: add support for log_status

2015-06-05 Thread Sergei Shtylyov

Hello.

On 6/5/2015 1:59 PM, Hans Verkuil wrote:


From: Hans Verkuil hans.verk...@cisco.com



Dump the VOU registers in log_status.



Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
  drivers/media/platform/sh_vou.c | 29 +
  1 file changed, 29 insertions(+)



diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 7ed5a8b..400efec 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -951,6 +951,34 @@ static int sh_vou_g_std(struct file *file, void *priv, 
v4l2_std_id *std)
return 0;
  }

+static int sh_vou_log_status(struct file *file, void *priv)
+{
+   struct sh_vou_device *vou_dev = video_drvdata(file);
+
+   pr_info(PSELA:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUER));
+   pr_info(VOUER:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUER));


   You're dumping the same register twice, under different names?


+   pr_info(VOUCR:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUCR));
+   pr_info(VOUSTR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSTR));
+   pr_info(VOUVCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUVCR));
+   pr_info(VOUISR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUISR));
+   pr_info(VOUBCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUBCR));
+   pr_info(VOUDPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDPR));
+   pr_info(VOUDSR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDSR));
+   pr_info(VOUVPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUVPR));
+   pr_info(VOUIR:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUIR));
+   pr_info(VOUSRR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSRR));
+   pr_info(VOUMSR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUMSR));
+   pr_info(VOUHIR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUHIR));
+   pr_info(VOUDFR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDFR));
+   pr_info(VOUAD1R: 0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAD1R));
+   pr_info(VOUAD2R: 0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAD2R));
+   pr_info(VOUAIR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAIR));
+   pr_info(VOUSWR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSWR));
+   pr_info(VOURCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOURCR));
+   pr_info(VOURPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOURPR));
+   return 0;
+}
+

[...]

WBR, Sergei

--
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][media] SI2168: Resolve unknown chip version errors with different HVR22x5 models

2015-06-05 Thread Olli Salonen
Hi Steven,

It seems to me that that part of the code is identical to your driver, no?

The media_tree driver:

retval = saa7164_api_i2c_read(bus,
 msgs[i].addr,
 0 /* reglen */,
 NULL /* reg */, msgs[i].len, msgs[i].buf);

It's exactly the same with a little bit different formatting.

Cheers,
-olli


On 4 June 2015 at 16:03, Steven Toth st...@kernellabs.com wrote:
 On Thu, Jun 4, 2015 at 9:22 AM, Olli Salonen olli.salo...@iki.fi wrote:
 I compiled an old HVR-2205 driver from my git tree:
 https://github.com/trsqr/media_tree/tree/hvr2205

 https://github.com/trsqr/media_tree/commit/61c2ef874b8a9620f498c9a4ab4138e97119462b

 That's the difference perhaps.

 --
 Steven Toth - Kernel Labs
 http://www.kernellabs.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 09/11] [media] rc: set IR_MAX_DURATION to 500 ms

2015-06-05 Thread Mauro Carvalho Chehab
The current definition is weird, and produce lots of sparse
warnings:

drivers/media/i2c/cx25840/cx25840-ir.c:448 txclk_tx_s_max_pulse_width() 
warn: impossible condition '(ns  4294967295) = (0-u32max  u32max)'
drivers/media/i2c/cx25840/cx25840-ir.c:461 rxclk_rx_s_max_pulse_width() 
warn: impossible condition '(ns  4294967295) = (0-u32max  u32max)'
drivers/media/i2c/cx25840/cx25840-ir.c:706 cx25840_ir_rx_read() warn: 
impossible condition '(v  4294967295) = (0-u32max  u32max)'
drivers/media/pci/ivtv/ivtv-queue.c:145 ivtv_queue_move() error: we 
previously assumed 'steal' could be null (see line 138)
drivers/media/rc/streamzap.c:155 sz_push_full_pulse() warn: impossible 
condition '(rawir.duration  4294967295) = (0-u32max  u32max)'
drivers/media/rc/streamzap.c:169 sz_push_full_pulse() warn: impossible 
condition '(rawir.duration  4294967295) = (0-u32max  u32max)'
drivers/media/rc/redrat3.c:325 redrat3_us_to_len() warn: impossible 
condition '(microsec  4294967295) = (0-u32max  u32max)'
drivers/media/rc/redrat3.c:383 redrat3_process_ir_data() warn: 
impossible condition '(rawir.duration  4294967295) = (0-u32max  u32max)'
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3676 pvr2_send_request_ex() 
error: we previously assumed 'write_data' could be null (see line 3648)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3829 pvr2_send_request_ex() 
error: we previously assumed 'read_data' could be null (see line 3649)
drivers/media/pci/cx23885/cx23888-ir.c:463 txclk_tx_s_max_pulse_width() 
warn: impossible condition '(ns  4294967295) = (0-u32max  u32max)'
drivers/media/pci/cx23885/cx23888-ir.c:476 rxclk_rx_s_max_pulse_width() 
warn: impossible condition '(ns  4294967295) = (0-u32max  u32max)'
drivers/media/pci/cx23885/cx23888-ir.c:696 cx23888_ir_rx_read() warn: 
impossible condition '(v  4294967295) = (0-u32max  u32max)'

Use a more realistic value for it.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index f1cb9daba489..45534da57759 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -242,7 +242,7 @@ static inline void init_ir_raw_event(struct ir_raw_event 
*ev)
memset(ev, 0, sizeof(*ev));
 }
 
-#define IR_MAX_DURATION 0x  /* a bit more than 4 seconds */
+#define IR_MAX_DURATION 5  /* 500 ms */
 #define US_TO_NS(usec) ((usec) * 1000)
 #define MS_TO_US(msec) ((msec) * 1000)
 #define MS_TO_NS(msec) ((msec) * 1000 * 1000)
-- 
2.4.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


[PATCH 1/3] v4l2-mem2mem: add support for prepare_buf

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

This was never added for some reason, so add it now.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 28 
 include/media/v4l2-mem2mem.h   |  4 
 2 files changed, 32 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index cbef15c..dc853e5 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -427,6 +427,25 @@ int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx 
*m2m_ctx,
 EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf);
 
 /**
+ * v4l2_m2m_prepare_buf() - prepare a source or destination buffer, depending 
on
+ * the type
+ */
+int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
+struct v4l2_buffer *buf)
+{
+   struct vb2_queue *vq;
+   int ret;
+
+   vq = v4l2_m2m_get_vq(m2m_ctx, buf-type);
+   ret = vb2_prepare_buf(vq, buf);
+   if (!ret)
+   v4l2_m2m_try_schedule(m2m_ctx);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf);
+
+/**
  * v4l2_m2m_create_bufs() - create a source or destination buffer, depending
  * on the type
  */
@@ -811,6 +830,15 @@ int v4l2_m2m_ioctl_dqbuf(struct file *file, void *priv,
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_dqbuf);
 
+int v4l2_m2m_ioctl_prepare_buf(struct file *file, void *priv,
+  struct v4l2_buffer *buf)
+{
+   struct v4l2_fh *fh = file-private_data;
+
+   return v4l2_m2m_prepare_buf(file, fh-m2m_ctx, buf);
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_prepare_buf);
+
 int v4l2_m2m_ioctl_expbuf(struct file *file, void *priv,
struct v4l2_exportbuffer *eb)
 {
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index c5f3914..3bbd96d 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -116,6 +116,8 @@ int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx 
*m2m_ctx,
  struct v4l2_buffer *buf);
 int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
   struct v4l2_buffer *buf);
+int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
+struct v4l2_buffer *buf);
 int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 struct v4l2_create_buffers *create);
 
@@ -248,6 +250,8 @@ int v4l2_m2m_ioctl_qbuf(struct file *file, void *fh,
struct v4l2_buffer *buf);
 int v4l2_m2m_ioctl_dqbuf(struct file *file, void *fh,
struct v4l2_buffer *buf);
+int v4l2_m2m_ioctl_prepare_buf(struct file *file, void *fh,
+  struct v4l2_buffer *buf);
 int v4l2_m2m_ioctl_streamon(struct file *file, void *fh,
enum v4l2_buf_type type);
 int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
-- 
2.1.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 02/11] [media] em28xx: remove dead code

2015-06-05 Thread Mauro Carvalho Chehab
As reported by smatch:
drivers/media/usb/em28xx/em28xx-video.c:842 get_ressource() info: 
ignoring unreachable code.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 14eba9c65de3..4397ce5e78df 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -839,7 +839,6 @@ static int get_ressource(enum v4l2_buf_type f_type)
return EM28XX_RESOURCE_VBI;
default:
BUG();
-   return 0;
}
 }
 
-- 
2.4.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


[PATCH 0/3] vim2m improvements

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add support for VIDIOC_PREPARE_BUF to v4l2-mem2mem and use it in vim2m.
Also fix a small bug in the debug logging that's done by v4l2-ioctl.c.

After adding support for CREATE_BUFS in vim2m a v4l2-compliance bug was
found and v4l2-compliance has now been fixed.

Hans Verkuil (3):
  v4l2-mem2mem: add support for prepare_buf
  v4l2-ioctl: log buffer type 0 correctly
  vim2m: add create_bufs and prepare_buf support

 drivers/media/platform/vim2m.c |  8 
 drivers/media/v4l2-core/v4l2-ioctl.c   |  1 +
 drivers/media/v4l2-core/v4l2-mem2mem.c | 28 
 include/media/v4l2-mem2mem.h   |  4 
 4 files changed, 41 insertions(+)

-- 
2.1.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 01/11] [media] drxk: better handle errors

2015-06-05 Thread Mauro Carvalho Chehab
As reported by smatch:
drivers/media/dvb-frontends/drxk_hard.c:3277 dvbt_sc_command() warn: 
missing break? reassigning 'status'

This is basically because the error handling logic there was crappy.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-frontends/drxk_hard.c 
b/drivers/media/dvb-frontends/drxk_hard.c
index ad35264a3819..b1fc4bd44a2b 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -3262,6 +3262,7 @@ static int dvbt_sc_command(struct drxk_state *state,
}
 
/* Write needed parameters and the command */
+   status = 0;
switch (cmd) {
/* All commands using 5 parameters */
/* All commands using 4 parameters */
@@ -3270,16 +3271,16 @@ static int dvbt_sc_command(struct drxk_state *state,
case OFDM_SC_RA_RAM_CMD_PROC_START:
case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM:
case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM:
-   status = write16(state, OFDM_SC_RA_RAM_PARAM1__A, param1);
+   status |= write16(state, OFDM_SC_RA_RAM_PARAM1__A, param1);
/* All commands using 1 parameters */
case OFDM_SC_RA_RAM_CMD_SET_ECHO_TIMING:
case OFDM_SC_RA_RAM_CMD_USER_IO:
-   status = write16(state, OFDM_SC_RA_RAM_PARAM0__A, param0);
+   status |= write16(state, OFDM_SC_RA_RAM_PARAM0__A, param0);
/* All commands using 0 parameters */
case OFDM_SC_RA_RAM_CMD_GET_OP_PARAM:
case OFDM_SC_RA_RAM_CMD_NULL:
/* Write command */
-   status = write16(state, OFDM_SC_RA_RAM_CMD__A, cmd);
+   status |= write16(state, OFDM_SC_RA_RAM_CMD__A, cmd);
break;
default:
/* Unknown command */
-- 
2.4.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


[PATCH 05/11] [media] bt8xx: remove needless check

2015-06-05 Thread Mauro Carvalho Chehab
As reported by smatch:
drivers/media/pci/bt8xx/dst_ca.c:323 ca_get_message() warn: this array 
is probably non-NULL. 'p_ca_message-msg'
drivers/media/pci/bt8xx/dst_ca.c:498 ca_send_message() warn: this array 
is probably non-NULL. 'p_ca_message-msg'

Those two checks are needless/useless, as the ca_msg struct is
declared as:
typedef struct ca_msg {
unsigned int index;
unsigned int type;
unsigned int length;
unsigned char msg[256];
} ca_msg_t;

So, if the p_ca_message pointer is not null, msg will also be
not null.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c
index c22c4ae06844..c5cc14ef8347 100644
--- a/drivers/media/pci/bt8xx/dst_ca.c
+++ b/drivers/media/pci/bt8xx/dst_ca.c
@@ -320,29 +320,27 @@ static int ca_get_message(struct dst_state *state, struct 
ca_msg *p_ca_message,
if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg)))
return -EFAULT;
 
-   if (p_ca_message-msg) {
-   dprintk(verbose, DST_CA_NOTICE, 1,  Message = [%*ph],
-   3, p_ca_message-msg);
+   dprintk(verbose, DST_CA_NOTICE, 1,  Message = [%*ph],
+   3, p_ca_message-msg);
 
-   for (i = 0; i  3; i++) {
-   command = command | p_ca_message-msg[i];
-   if (i  2)
-   command = command  8;
-   }
-   dprintk(verbose, DST_CA_NOTICE, 1,  Command=[0x%x], command);
+   for (i = 0; i  3; i++) {
+   command = command | p_ca_message-msg[i];
+   if (i  2)
+   command = command  8;
+   }
+   dprintk(verbose, DST_CA_NOTICE, 1,  Command=[0x%x], command);
 
-   switch (command) {
-   case CA_APP_INFO:
-   memcpy(p_ca_message-msg, state-messages, 128);
-   if (copy_to_user(arg, p_ca_message, sizeof (struct 
ca_msg)) )
-   return -EFAULT;
-   break;
-   case CA_INFO:
-   memcpy(p_ca_message-msg, state-messages, 128);
-   if (copy_to_user(arg, p_ca_message, sizeof (struct 
ca_msg)) )
-   return -EFAULT;
-   break;
-   }
+   switch (command) {
+   case CA_APP_INFO:
+   memcpy(p_ca_message-msg, state-messages, 128);
+   if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) )
+   return -EFAULT;
+   break;
+   case CA_INFO:
+   memcpy(p_ca_message-msg, state-messages, 128);
+   if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) )
+   return -EFAULT;
+   break;
}
 
return 0;
@@ -494,60 +492,58 @@ static int ca_send_message(struct dst_state *state, 
struct ca_msg *p_ca_message,
goto free_mem_and_exit;
}
 
+   /*  EN50221 tag */
+   command = 0;
 
-   if (p_ca_message-msg) {
-   /*  EN50221 tag */
-   command = 0;
+   for (i = 0; i  3; i++) {
+   command = command | p_ca_message-msg[i];
+   if (i  2)
+   command = command  8;
+   }
+   dprintk(verbose, DST_CA_DEBUG, 1,  Command=[0x%x]\n, command);
 
-   for (i = 0; i  3; i++) {
-   command = command | p_ca_message-msg[i];
-   if (i  2)
-   command = command  8;
+   switch (command) {
+   case CA_PMT:
+   dprintk(verbose, DST_CA_DEBUG, 1, Command = SEND_CA_PMT);
+   if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0))  0) {   
// code simplification started
+   dprintk(verbose, DST_CA_ERROR, 1,  --CA_PMT Failed 
!);
+   result = -1;
+   goto free_mem_and_exit;
}
-   dprintk(verbose, DST_CA_DEBUG, 1,  Command=[0x%x]\n, command);
-
-   switch (command) {
-   case CA_PMT:
-   dprintk(verbose, DST_CA_DEBUG, 1, Command = 
SEND_CA_PMT);
-   if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) 
 0) {   // code simplification started
-   dprintk(verbose, DST_CA_ERROR, 1,  --CA_PMT 
Failed !);
-   result = -1;
-   goto free_mem_and_exit;
-   }
-   dprintk(verbose, DST_CA_INFO, 1,  --CA_PMT Success 
!);
-   break;
-   case CA_PMT_REPLY:
-   dprintk(verbose, DST_CA_INFO, 1, Command = 
CA_PMT_REPLY);
-   /*  Have to handle the 2 basic types of cards here  
*/
-   

[PATCH 03/11] [media] sh_vou: avoid going past arrays

2015-06-05 Thread Mauro Carvalho Chehab
Smatch reports two issues:
drivers/media/platform/sh_vou.c:670 vou_adjust_output() error: buffer 
overflow 'vou_scale_v_num' 3 = 4
drivers/media/platform/sh_vou.c:670 vou_adjust_output() error: buffer 
overflow 'vou_scale_v_den' 3 = 4

It seems that there's actually a bug here: the same var (idx) is used
as an index for vertical and horizontal scaling arrays. However,
there are 4 elements on the h arrays, and only 3 at the v ones.

On the first loop, it may select index 4 for the horizontal array.

In this case, if the second loop fails to select an index, the
code would keep using 4 for the vertical array, with is past of
the array sizes.

The intent here seems to use index 0, if the scale is not found.

So, use a separate var for the vertical index.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 829e85c26610..8b799bae01b8 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -600,7 +600,7 @@ static void vou_adjust_output(struct sh_vou_geometry *geo, 
v4l2_std_id std)
 {
unsigned int best_err = UINT_MAX, best = geo-in_width,
width_max, height_max, img_height_max;
-   int i, idx = 0;
+   int i, idx_h = 0, idx_v = 0;
 
if (std  V4L2_STD_525_60) {
width_max = 858;
@@ -625,7 +625,7 @@ static void vou_adjust_output(struct sh_vou_geometry *geo, 
v4l2_std_id std)
err = abs(found - geo-output.width);
if (err  best_err) {
best_err = err;
-   idx = i;
+   idx_h = i;
best = found;
}
if (!err)
@@ -633,12 +633,12 @@ static void vou_adjust_output(struct sh_vou_geometry 
*geo, v4l2_std_id std)
}
 
geo-output.width = best;
-   geo-scale_idx_h = idx;
+   geo-scale_idx_h = idx_h;
if (geo-output.left + best  width_max)
geo-output.left = width_max - best;
 
pr_debug(%s(): W %u * %u/%u = %u\n, __func__, geo-in_width,
-vou_scale_h_num[idx], vou_scale_h_den[idx], best);
+vou_scale_h_num[idx_h], vou_scale_h_den[idx_h], best);
 
best_err = UINT_MAX;
 
@@ -655,7 +655,7 @@ static void vou_adjust_output(struct sh_vou_geometry *geo, 
v4l2_std_id std)
err = abs(found - geo-output.height);
if (err  best_err) {
best_err = err;
-   idx = i;
+   idx_v = i;
best = found;
}
if (!err)
@@ -663,12 +663,12 @@ static void vou_adjust_output(struct sh_vou_geometry 
*geo, v4l2_std_id std)
}
 
geo-output.height = best;
-   geo-scale_idx_v = idx;
+   geo-scale_idx_v = idx_v;
if (geo-output.top + best  height_max)
geo-output.top = height_max - best;
 
pr_debug(%s(): H %u * %u/%u = %u\n, __func__, geo-in_height,
-vou_scale_v_num[idx], vou_scale_v_den[idx], best);
+vou_scale_v_num[idx_v], vou_scale_v_den[idx_v], best);
 }
 
 static int sh_vou_s_fmt_vid_out(struct file *file, void *priv,
-- 
2.4.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


[PATCH 3/3] vim2m: add create_bufs and prepare_buf support

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Add support for the missing VIDIOC_CREATE_BUFS and VIDIOC_PREPARE_BUF
ioctls.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/platform/vim2m.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index cecfd75..295fde5 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -693,6 +693,8 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops = {
.vidioc_querybuf= v4l2_m2m_ioctl_querybuf,
.vidioc_qbuf= v4l2_m2m_ioctl_qbuf,
.vidioc_dqbuf   = v4l2_m2m_ioctl_dqbuf,
+   .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
+   .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_expbuf  = v4l2_m2m_ioctl_expbuf,
 
.vidioc_streamon= v4l2_m2m_ioctl_streamon,
@@ -720,6 +722,12 @@ static int vim2m_queue_setup(struct vb2_queue *vq,
 
size = q_data-width * q_data-height * q_data-fmt-depth  3;
 
+   if (fmt) {
+   if (fmt-fmt.pix.sizeimage  size)
+   return -EINVAL;
+   size = fmt-fmt.pix.sizeimage;
+   }
+
while (size * count  MEM2MEM_VID_MEM_LIMIT)
(count)--;
 
-- 
2.1.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 06/11] [media] ivtv: fix two smatch warnings

2015-06-05 Thread Mauro Carvalho Chehab
Smatch currently produces two warnings:
drivers/media/pci/ivtv/ivtv-fileops.c:901 ivtv_v4l2_close() warn: 
suspicious bitop condition
drivers/media/pci/ivtv/ivtv-fileops.c:1026 ivtv_open() warn: suspicious 
bitop condition

Those are false positives, but it is not hard to get rid of them by
using a different way to evaluate the macro, splitting the logical
boolean evaluation from the bitmap one.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/pci/ivtv/ivtv-driver.h 
b/drivers/media/pci/ivtv/ivtv-driver.h
index e8b6c7ad2ba9..ee0ef6e48c7d 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -830,7 +830,8 @@ static inline int ivtv_raw_vbi(const struct ivtv *itv)
do {\
struct v4l2_subdev *__sd;   \
__v4l2_device_call_subdevs_p((itv)-v4l2_dev, __sd,\
-   !(hw) || (__sd-grp_id  (hw)), o, f , ##args); \
+!(hw) ? true : (__sd-grp_id  (hw)),  \
+o, f, ##args); \
} while (0)
 
 #define ivtv_call_all(itv, o, f, args...) ivtv_call_hw(itv, 0, o, f , ##args)
-- 
2.4.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


[PATCH 07/11] [media] tm6000: remove needless check

2015-06-05 Thread Mauro Carvalho Chehab
Smatch reports a warning:
drivers/media/usb/tm6000/tm6000-video.c:646 tm6000_prepare_isoc() 
error: we previously assumed 'dev-urb_buffer' could be null (see line 624)

This is not really a problem, but it actually shows that the check
if urb_buffer is NULL is being done twice: at the if and at
tm6000_alloc_urb_buffers().

We don't need to do it twice. So, remove the extra check. The code
become cleaner, and, as a collateral effect, smatch becomes happy.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/tm6000/tm6000-video.c 
b/drivers/media/usb/tm6000/tm6000-video.c
index 77ce9efe1f24..5287d2960282 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -621,7 +621,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev)
dev-isoc_in.maxsize, size);
 
 
-   if (!dev-urb_buffer  tm6000_alloc_urb_buffers(dev)  0) {
+   if (tm6000_alloc_urb_buffers(dev)  0) {
tm6000_err(cannot allocate memory for urb buffers\n);
 
/* call free, as some buffers might have been allocated */
-- 
2.4.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


[PATCH 00/11] Some smatch fixups

2015-06-05 Thread Mauro Carvalho Chehab
Fix several smatch warnings.

There are only 26 smatch warnings now:

drivers/media/pci/cx23885/cx23885-dvb.c:2046 dvb_register() Function too hairy. 
 Giving up.

This is actually a memory allocation limit of 50MB at smatch.
I sent a patch changing such limit to 200MB to Dan.

drivers/media/dvb-frontends/stv0900_core.c:1183 stv0900_get_optim_carr_loop() 
error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1185 stv0900_get_optim_carr_loop() 
error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1187 stv0900_get_optim_carr_loop() 
error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1189 stv0900_get_optim_carr_loop() 
error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1191 stv0900_get_optim_carr_loop() 
error: buffer overflow 'cllas2' 11 = 13
drivers/media/media-entity.c:238:17: warning: Variable length array is used.
drivers/media/media-entity.c:239:17: warning: Variable length array is used.
drivers/media/pci/ttpci/av7110.c:2210 frontend_init() warn: missing break? 
reassigning 'av7110-fe'
drivers/media/pci/ttpci/budget.c:631 frontend_init() warn: missing break? 
reassigning 'budget-dvb_frontend'
drivers/media/platform/vivid/vivid-rds-gen.c:82 vivid_rds_generate() error: 
buffer overflow 'rds-psname' 9 = 43
drivers/media/platform/vivid/vivid-rds-gen.c:83 vivid_rds_generate() error: 
buffer overflow 'rds-psname' 9 = 42
drivers/media/platform/vivid/vivid-rds-gen.c:89 vivid_rds_generate() error: 
buffer overflow 'rds-radiotext' 65 = 84
drivers/media/platform/vivid/vivid-rds-gen.c:90 vivid_rds_generate() error: 
buffer overflow 'rds-radiotext' 65 = 85
drivers/media/platform/vivid/vivid-rds-gen.c:92 vivid_rds_generate() error: 
buffer overflow 'rds-radiotext' 65 = 86
drivers/media/platform/vivid/vivid-rds-gen.c:93 vivid_rds_generate() error: 
buffer overflow 'rds-radiotext' 65 = 87
drivers/media/radio/radio-aimslab.c:73 rtrack_alloc() warn: possible memory 
leak of 'rt'
drivers/media/radio/radio-aztech.c:87 aztech_alloc() warn: possible memory leak 
of 'az'
drivers/media/radio/radio-gemtek.c:189 gemtek_alloc() warn: possible memory 
leak of 'gt'
drivers/media/radio/radio-trust.c:60 trust_alloc() warn: possible memory leak 
of 'tr'
drivers/media/radio/radio-typhoon.c:79 typhoon_alloc() warn: possible memory 
leak of 'ty'
drivers/media/radio/radio-zoltrix.c:83 zoltrix_alloc() warn: possible memory 
leak of 'zol'
drivers/media/usb/pvrusb2/pvrusb2-encoder.c:227 pvr2_encoder_cmd() error: 
buffer overflow 'wrData' 16 = 16
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3676 pvr2_send_request_ex() error: we 
previously assumed 'write_data' could be null (see line 3648)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3829 pvr2_send_request_ex() error: we 
previously assumed 'read_data' could be null (see line 3649)

  Those seem to be false positives that would require a bigger logic
  change (or some change at smatch side). Probably not worth to touch
  the driver code.

drivers/media/pci/ivtv/ivtv-queue.c:145 ivtv_queue_move() error: we previously 
assumed 'steal' could be null (see line 138)
  I suspect that this is a real bug and should be addressed.
  Fixing it would require some tests with the hardware, and a better
  understanding on what the function should be expecting to do when 
  steal is NULL.

Mauro Carvalho Chehab (11):
  [media] drxk: better handle errors
  [media] em28xx: remove dead code
  [media] sh_vou: avoid going past arrays
  [media] dib0090: Remove a dead code
  [media] bt8xx: remove needless check
  [media] ivtv: fix two smatch warnings
  [media] tm6000: remove needless check
  [media] ir: Fix IR_MAX_DURATION enforcement
  [media] rc: set IR_MAX_DURATION to 500 ms
  [media] usbvision: cleanup the code
  [media] lirc_imon: simplify error handling code

 drivers/media/dvb-frontends/dib0090.c |   4 +-
 drivers/media/dvb-frontends/drxk_hard.c   |   7 +-
 drivers/media/pci/bt8xx/dst_ca.c  | 132 +-
 drivers/media/pci/ivtv/ivtv-driver.h  |   3 +-
 drivers/media/platform/sh_vou.c   |  14 +--
 drivers/media/rc/redrat3.c|   5 +-
 drivers/media/rc/streamzap.c  |   6 +-
 drivers/media/usb/em28xx/em28xx-video.c   |   1 -
 drivers/media/usb/tm6000/tm6000-video.c   |   2 +-
 drivers/media/usb/usbvision/usbvision-video.c |  17 +++-
 drivers/staging/media/lirc/lirc_imon.c|  95 --
 include/media/rc-core.h   |   2 +-
 12 files changed, 139 insertions(+), 149 deletions(-)

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


[PATCH 2/3] v4l2-ioctl: log buffer type 0 correctly

2015-06-05 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

If userspace passed the invalid buffer type 0 to the kernel, then the
kernel log would show 'type=(null)' since there was no string defined
for type 0. Fix this.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 368bc3a..1ce89a4 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -142,6 +142,7 @@ const char *v4l2_field_names[] = {
 EXPORT_SYMBOL(v4l2_field_names);
 
 const char *v4l2_type_names[] = {
+   [0]= 0,
[V4L2_BUF_TYPE_VIDEO_CAPTURE]  = vid-cap,
[V4L2_BUF_TYPE_VIDEO_OVERLAY]  = vid-overlay,
[V4L2_BUF_TYPE_VIDEO_OUTPUT]   = vid-out,
-- 
2.1.4

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


Re: [PATCH][media] SI2168: Resolve unknown chip version errors with different HVR22x5 models

2015-06-05 Thread Antti Palosaari

On 06/05/2015 04:40 PM, Olli Salonen wrote:

Hi Steven,

It seems to me that that part of the code is identical to your driver, no?

The media_tree driver:

retval = saa7164_api_i2c_read(bus,
  msgs[i].addr,
  0 /* reglen */,
  NULL /* reg */, msgs[i].len, msgs[i].buf);

It's exactly the same with a little bit different formatting.


And that looks correct.

But the patch which does not look correct, or is at least unclear, is that
[media] saa7164: Improvements for I2C handling
http://permalink.gmane.org/gmane.comp.video.linuxtv.scm/22211

First change does not have any effect as len should be zero in any case 
and memcpy() should do nothing.


Second change looks something that is likely wrong. There is some hack 
which increases data len. All that register len stuff is logically wrong 
- I2C adapter handles just bytes and should not know nothing about 
client register layout. OK, there is some exceptions (like af9035) where 
I2C firmware actually knows register layout for some strange reason.


So could you remove that patch and test?

Antti

--
http://palosaari.fi/
--
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 10/11] [media] usbvision: cleanup the code

2015-06-05 Thread Mauro Carvalho Chehab
There's a dead code on usbvision that makes it harder to read
and produces a smatch warning about bad identation.

Improve the code readability and add a FIXME to warn about
the current hack there.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/usbvision/usbvision-video.c 
b/drivers/media/usb/usbvision/usbvision-video.c
index 12b403e78d52..1c6d31f7c1b9 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -1061,13 +1061,24 @@ static ssize_t usbvision_read(struct file *file, char 
__user *buf,
   __func__,
   (unsigned long)count, frame-bytes_read);
 
-   /* For now, forget the frame if it has not been read in one shot. */
-/* if (frame-bytes_read = frame-scanlength) {*/ /* All data has been 
read */
+#if 1
+   /*
+* FIXME:
+* For now, forget the frame if it has not been read in one shot.
+*/
+   frame-bytes_read = 0;
+
+   /* Mark it as available to be used again. */
+   frame-grabstate = frame_state_unused;
+#else
+   if (frame-bytes_read = frame-scanlength) {
+   /* All data has been read */
frame-bytes_read = 0;
 
/* Mark it as available to be used again. */
frame-grabstate = frame_state_unused;
-/* } */
+   }
+#endif
 
return count;
 }
-- 
2.4.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


[PATCH 08/11] [media] ir: Fix IR_MAX_DURATION enforcement

2015-06-05 Thread Mauro Carvalho Chehab
Don't assume that IR_MAX_DURATION is a bitmask. It isn't.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index c83292ad1b34..ec74244a3853 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -322,7 +322,7 @@ static u32 redrat3_us_to_len(u32 microsec)
u32 result;
u32 divisor;
 
-   microsec = IR_MAX_DURATION;
+   microsec = (microsec  IR_MAX_DURATION) ? IR_MAX_DURATION : microsec;
divisor = (RR3_CLK_CONV_FACTOR / 1000);
result = (u32)(microsec * divisor) / 1000;
 
@@ -380,7 +380,8 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
if (i == 0)
trailer = rawir.duration;
/* cap the value to IR_MAX_DURATION */
-   rawir.duration = IR_MAX_DURATION;
+   rawir.duration = (rawir.duration  IR_MAX_DURATION) ?
+IR_MAX_DURATION : rawir.duration;
 
dev_dbg(dev, storing %s with duration %d (i: %d)\n,
rawir.pulse ? pulse : space, rawir.duration, i);
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index bf4a44272f0e..5a17cb88ff27 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -152,7 +152,8 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
sz-signal_last.tv_usec);
rawir.duration -= sz-sum;
rawir.duration = US_TO_NS(rawir.duration);
-   rawir.duration = IR_MAX_DURATION;
+   rawir.duration = (rawir.duration  IR_MAX_DURATION) ?
+IR_MAX_DURATION : rawir.duration;
}
sz_push(sz, rawir);
 
@@ -165,7 +166,8 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
rawir.duration += SZ_RESOLUTION / 2;
sz-sum += rawir.duration;
rawir.duration = US_TO_NS(rawir.duration);
-   rawir.duration = IR_MAX_DURATION;
+   rawir.duration = (rawir.duration  IR_MAX_DURATION) ?
+IR_MAX_DURATION : rawir.duration;
sz_push(sz, rawir);
 }
 
-- 
2.4.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


[PATCH 04/11] [media] dib0090: Remove a dead code

2015-06-05 Thread Mauro Carvalho Chehab
As reported by smatch:
drivers/media/dvb-frontends/dib0090.c:1710 
dib0090_dc_offset_calibration() warn: missing break? reassigning '*tune_state'

There's no need to change tune_state there, as the fall though code
will change it again to another state. So, simplify it by
removing the dead code.

While here, fix a typo:
Sart = Start

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-frontends/dib0090.c 
b/drivers/media/dvb-frontends/dib0090.c
index 68e2af2650d3..47cb72243b9d 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -1696,12 +1696,10 @@ static int dib0090_dc_offset_calibration(struct 
dib0090_state *state, enum front
 
if (state-identity.p1g)
state-dc = dc_p1g_table;
-   *tune_state = CT_TUNER_STEP_0;
 
/* fall through */
-
case CT_TUNER_STEP_0:
-   dprintk(Sart/continue DC calibration for %s path, 
(state-dc-i == 1) ? I : Q);
+   dprintk(Start/continue DC calibration for %s path, 
(state-dc-i == 1) ? I : Q);
dib0090_write_reg(state, 0x01, state-dc-bb1);
dib0090_write_reg(state, 0x07, state-bb7 | (state-dc-i  
7));
 
-- 
2.4.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


[PATCH 0/9] Some smatch fixups

2015-06-05 Thread Mauro Carvalho Chehab
Fix several smatch warnings.

There are still 27 smatch warnings at drivers/media:


This one:
drivers/media/pci/cx23885/cx23885-dvb.c:2046 dvb_register() Function 
too hairy.  Giving up.

It is just to a random memory limit at smatch that allows it to
allocate only 50Mb of memory for name allocation. I fixed it
locally and submitted a fix to Dan.

Those seem to be false-positives:
drivers/media/dvb-frontends/stv0900_core.c:1183 
stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1185 
stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1187 
stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1189 
stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
drivers/media/dvb-frontends/stv0900_core.c:1191 
stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
drivers/media/media-entity.c:238:17: warning: Variable length array is 
used.
drivers/media/media-entity.c:239:17: warning: Variable length array is 
used.
drivers/media/pci/ttpci/av7110.c:2210 frontend_init() warn: missing 
break? reassigning 'av7110-fe'
drivers/media/pci/ttpci/budget.c:631 frontend_init() warn: missing 
break? reassigning 'budget-dvb_frontend'
drivers/media/platform/vivid/vivid-rds-gen.c:82 vivid_rds_generate() 
error: buffer overflow 'rds-psname' 9 = 43
drivers/media/platform/vivid/vivid-rds-gen.c:83 vivid_rds_generate() 
error: buffer overflow 'rds-psname' 9 = 42
drivers/media/platform/vivid/vivid-rds-gen.c:89 vivid_rds_generate() 
error: buffer overflow 'rds-radiotext' 65 = 84
drivers/media/platform/vivid/vivid-rds-gen.c:90 vivid_rds_generate() 
error: buffer overflow 'rds-radiotext' 65 = 85
drivers/media/platform/vivid/vivid-rds-gen.c:92 vivid_rds_generate() 
error: buffer overflow 'rds-radiotext' 65 = 86
drivers/media/platform/vivid/vivid-rds-gen.c:93 vivid_rds_generate() 
error: buffer overflow 'rds-radiotext' 65 = 87
drivers/media/radio/radio-aimslab.c:73 rtrack_alloc() warn: possible 
memory leak of 'rt'
drivers/media/radio/radio-aztech.c:87 aztech_alloc() warn: possible 
memory leak of 'az'
drivers/media/radio/radio-gemtek.c:189 gemtek_alloc() warn: possible 
memory leak of 'gt'
drivers/media/radio/radio-trust.c:60 trust_alloc() warn: possible 
memory leak of 'tr'
drivers/media/radio/radio-typhoon.c:79 typhoon_alloc() warn: possible 
memory leak of 'ty'
drivers/media/radio/radio-zoltrix.c:83 zoltrix_alloc() warn: possible 
memory leak of 'zol'
drivers/media/usb/pvrusb2/pvrusb2-encoder.c:227 pvr2_encoder_cmd() 
error: buffer overflow 'wrData' 16 = 16
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3676 pvr2_send_request_ex() 
error: we previously assumed 'write_data' could be null (see line 3648)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3829 pvr2_send_request_ex() 
error: we previously assumed 'read_data' could be null (see line 3649)

I didn't find an easy/worth way to remove the above.

This one is due to a code that got commented:
drivers/media/usb/usbvision/usbvision-video.c:1072 usbvision_read() 
warn: inconsistent indenting

Probably the best here is to remove the commented code and fix 
identation.

This one seems a real bug, but fixing it would require some tests with 
the hardware, and a better understanding on what the function should be 
expecting to do when steal is NULL:
drivers/media/pci/ivtv/ivtv-queue.c:145 ivtv_queue_move() error: we 
previously assumed 'steal' could be null (see line 138)

Mauro Carvalho Chehab (9):
  [media] drxk: better handle errors
  [media] em28xx: remove dead code
  [media] sh_vou: avoid going past arrays
  dib0090: Remove a dead code
  [media] bt8xx: remove needless check
  [media] ivtv: fix two smatch warnings
  tm6000: remove needless check
  [media] ir: Fix IR_MAX_DURATION enforcement
  rc: set IR_MAX_DURATION to 500 ms

 drivers/media/dvb-frontends/dib0090.c   |   4 +-
 drivers/media/dvb-frontends/drxk_hard.c |   7 +-
 drivers/media/pci/bt8xx/dst_ca.c| 132 
 drivers/media/pci/ivtv/ivtv-driver.h|   3 +-
 drivers/media/platform/sh_vou.c |  14 ++--
 drivers/media/rc/redrat3.c  |   5 +-
 drivers/media/rc/streamzap.c|   6 +-
 drivers/media/usb/em28xx/em28xx-video.c |   1 -
 drivers/media/usb/tm6000/tm6000-video.c |   2 +-
 include/media/rc-core.h |   2 +-
 10 files changed, 87 insertions(+), 89 deletions(-)

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


[PATCH 11/11] [media] lirc_imon: simplify error handling code

2015-06-05 Thread Mauro Carvalho Chehab
Instead of using a state machine and a switch with lots of
fall-trough, use gotos and cleanup the error handling loop.

That removes those two smatch warnings:
drivers/staging/media/lirc/lirc_imon.c:933 imon_probe() warn: possible 
memory leak of 'context'
drivers/staging/media/lirc/lirc_imon.c:933 imon_probe() warn: possible 
memory leak of 'driver'

And make the error handling code more standard.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/staging/media/lirc/lirc_imon.c 
b/drivers/staging/media/lirc/lirc_imon.c
index 335b98a54237..62ec9f70dae4 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -693,10 +693,9 @@ static int imon_probe(struct usb_interface *interface,
int ifnum;
int lirc_minor = 0;
int num_endpts;
-   int retval = 0;
+   int retval = -ENOMEM;
int display_ep_found = 0;
int ir_ep_found = 0;
-   int alloc_status = 0;
int vfd_proto_6p = 0;
struct imon_context *context = NULL;
int i;
@@ -706,10 +705,8 @@ static int imon_probe(struct usb_interface *interface,
mutex_lock(driver_lock);
 
context = kzalloc(sizeof(struct imon_context), GFP_KERNEL);
-   if (!context) {
-   alloc_status = 1;
-   goto alloc_status_switch;
-   }
+   if (!context)
+   goto driver_unlock;
 
/*
 * Try to auto-detect the type of display if the user hasn't set
@@ -775,8 +772,7 @@ static int imon_probe(struct usb_interface *interface,
dev_err(dev, %s: no valid input (IR) endpoint found.\n,
__func__);
retval = -ENODEV;
-   alloc_status = 2;
-   goto alloc_status_switch;
+   goto free_context;
}
 
/* Determine if display requires 6 packets */
@@ -790,31 +786,26 @@ static int imon_probe(struct usb_interface *interface,
 
driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
if (!driver) {
-   alloc_status = 2;
-   goto alloc_status_switch;
+   goto free_context;
}
rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
if (!rbuf) {
-   alloc_status = 3;
-   goto alloc_status_switch;
+   goto free_driver;
}
if (lirc_buffer_init(rbuf, BUF_CHUNK_SIZE, BUF_SIZE)) {
dev_err(dev, %s: lirc_buffer_init failed\n, __func__);
-   alloc_status = 4;
-   goto alloc_status_switch;
+   goto free_rbuf;
}
rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!rx_urb) {
dev_err(dev, %s: usb_alloc_urb failed for IR urb\n, __func__);
-   alloc_status = 5;
-   goto alloc_status_switch;
+   goto free_lirc_buf;
}
tx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!tx_urb) {
dev_err(dev, %s: usb_alloc_urb failed for display urb\n,
__func__);
-   alloc_status = 6;
-   goto alloc_status_switch;
+   goto free_rx_urb;
}
 
mutex_init(context-ctx_lock);
@@ -840,11 +831,11 @@ static int imon_probe(struct usb_interface *interface,
lirc_minor = lirc_register_driver(driver);
if (lirc_minor  0) {
dev_err(dev, %s: lirc_register_driver failed\n, __func__);
-   alloc_status = 7;
-   goto unlock;
-   } else
-   dev_info(dev, Registered iMON driver (lirc minor: %d)\n,
-lirc_minor);
+   goto free_tx_urb;
+   }
+
+   dev_info(dev, Registered iMON driver (lirc minor: %d)\n,
+   lirc_minor);
 
/* Needed while unregistering! */
driver-minor = lirc_minor;
@@ -872,11 +863,9 @@ static int imon_probe(struct usb_interface *interface,
context-rx_endpoint-bInterval);
 
retval = usb_submit_urb(context-rx_urb, GFP_KERNEL);
-
if (retval) {
dev_err(dev, usb_submit_urb failed for intf0 (%d)\n, retval);
-   alloc_status = 8;
-   goto unlock;
+   goto unregister_lirc;
}
 
usb_set_intfdata(interface, context);
@@ -895,39 +884,31 @@ static int imon_probe(struct usb_interface *interface,
dev_info(dev, iMON device (%04x:%04x, intf%d) on usb%d:%d 
initialized\n,
vendor, product, ifnum, usbdev-bus-busnum, usbdev-devnum);
 
-unlock:
-   mutex_unlock(context-ctx_lock);
-alloc_status_switch:
+   /* Everything went fine. Just unlock and return retval (with is 0) */
+   goto driver_unlock;
 
-   switch (alloc_status) {
-   case 8:
-   lirc_unregister_driver(driver-minor);
-   case 7:
-   usb_free_urb(tx_urb);
-   case 6:
-   usb_free_urb(rx_urb);
-  

Re: [PATCH 07/10] sh-vou: add support for log_status

2015-06-05 Thread Hans Verkuil
On 06/05/2015 03:28 PM, Sergei Shtylyov wrote:
 Hello.
 
 On 6/5/2015 1:59 PM, Hans Verkuil wrote:
 
 From: Hans Verkuil hans.verk...@cisco.com
 
 Dump the VOU registers in log_status.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
   drivers/media/platform/sh_vou.c | 29 +
   1 file changed, 29 insertions(+)
 
 diff --git a/drivers/media/platform/sh_vou.c 
 b/drivers/media/platform/sh_vou.c
 index 7ed5a8b..400efec 100644
 --- a/drivers/media/platform/sh_vou.c
 +++ b/drivers/media/platform/sh_vou.c
 @@ -951,6 +951,34 @@ static int sh_vou_g_std(struct file *file, void *priv, 
 v4l2_std_id *std)
  return 0;
   }

 +static int sh_vou_log_status(struct file *file, void *priv)
 +{
 +struct sh_vou_device *vou_dev = video_drvdata(file);
 +
 +pr_info(PSELA:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUER));
 +pr_info(VOUER:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUER));
 
 You're dumping the same register twice, under different names?

Oops, PSELA doesn't belong here. I'll remove that line. Thanks for spotting 
this.

Regards,

Hans

 
 +pr_info(VOUCR:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUCR));
 +pr_info(VOUSTR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSTR));
 +pr_info(VOUVCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUVCR));
 +pr_info(VOUISR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUISR));
 +pr_info(VOUBCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUBCR));
 +pr_info(VOUDPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDPR));
 +pr_info(VOUDSR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDSR));
 +pr_info(VOUVPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUVPR));
 +pr_info(VOUIR:   0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUIR));
 +pr_info(VOUSRR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSRR));
 +pr_info(VOUMSR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUMSR));
 +pr_info(VOUHIR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUHIR));
 +pr_info(VOUDFR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUDFR));
 +pr_info(VOUAD1R: 0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAD1R));
 +pr_info(VOUAD2R: 0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAD2R));
 +pr_info(VOUAIR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUAIR));
 +pr_info(VOUSWR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOUSWR));
 +pr_info(VOURCR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOURCR));
 +pr_info(VOURPR:  0x%08x\n, sh_vou_reg_a_read(vou_dev, VOURPR));
 +return 0;
 +}
 +
 [...]
 
 WBR, Sergei
 
 --
 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
 

--
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] v4l2-ioctl: Give more information when device_caps are missing

2015-06-05 Thread Laura Abbott
Currently, the warning for missing device_caps gives a backtrace like so:

[8175c199] dump_stack+0x45/0x57
[8109ad5a] warn_slowpath_common+0x8a/0xc0
[8109ae8a] warn_slowpath_null+0x1a/0x20
[a0237453] v4l_querycap+0x43/0x80 [videodev]
[a0237734] __video_do_ioctl+0x2a4/0x320 [videodev]
[812207e5] ? do_last+0x195/0x1210
[a023a11e] video_usercopy+0x22e/0x5b0 [videodev]
[a0237490] ? v4l_querycap+0x80/0x80 [videodev]
[a023a4b5] video_ioctl2+0x15/0x20 [videodev]
[a0233733] v4l2_ioctl+0x113/0x150 [videodev]
[81225798] do_vfs_ioctl+0x2f8/0x4f0
[8113b2d4] ? __audit_syscall_entry+0xb4/0x110
[81022d7c] ? do_audit_syscall_entry+0x6c/0x70
[81225a11] SyS_ioctl+0x81/0xa0
[8113b526] ? __audit_syscall_exit+0x1f6/0x2a0
[81763549] system_call_fastpath+0x12/0x17

This indicates that device_caps are missing but doesn't give
much of a clue which driver is actually at fault. Improve
the warning output by showing the capabilities and the
responsible driver.

Signed-off-by: Laura Abbott labb...@fedoraproject.org
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index aa407cb..f7cd17d 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1023,8 +1023,9 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 * Drivers MUST fill in device_caps, so check for this and
 * warn if it was forgotten.
 */
-   WARN_ON(!(cap-capabilities  V4L2_CAP_DEVICE_CAPS) ||
-   !cap-device_caps);
+   WARN(!(cap-capabilities  V4L2_CAP_DEVICE_CAPS) ||
+   !cap-device_caps, Bad caps for driver %s, %x %x,
+   cap-driver, cap-capabilities, cap-device_caps);
cap-device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
 
return ret;
-- 
2.4.1

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


Re: [PATCH] [media] vivid: don't use more than 1024 bytes of stack

2015-06-05 Thread Mauro Carvalho Chehab
Em Fri, 05 Jun 2015 17:10:53 +0200
Hans Verkuil hverk...@xs4all.nl escreveu:

 On 06/05/2015 12:29 PM, Mauro Carvalho Chehab wrote:
  Remove the following compilation warnings:
  
  drivers/media/platform/vivid/vivid-tpg.c: In function 'tpg_gen_text':
  drivers/media/platform/vivid/vivid-tpg.c:1562:1: warning: the frame 
  size of 1308 bytes is larger than 1024 bytes [-Wframe-larger-than=]
   }
   ^
  
  This seems to be due to some bad optimization done by gcc.
  
  Moving the for() loop to happen inside the macro solves the
  issue.
  
  While here, fix CodingStyle at the switch().
  
  Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
  
  diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
  b/drivers/media/platform/vivid/vivid-tpg.c
  index b1147f2df26c..7a3ed580626a 100644
  --- a/drivers/media/platform/vivid/vivid-tpg.c
  +++ b/drivers/media/platform/vivid/vivid-tpg.c
  @@ -1492,12 +1492,10 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
  *basep[TPG_MAX_PLANES][2],
  else if (tpg-field == V4L2_FIELD_SEQ_TB || tpg-field == 
  V4L2_FIELD_SEQ_BT)
  div = 2;
   
  -   for (p = 0; p  tpg-planes; p++) {
  -   unsigned vdiv = tpg-vdownsampling[p];
  -   unsigned hdiv = tpg-hdownsampling[p];
  -
  -   /* Print text */
  -#define PRINTSTR(PIXTYPE) do { \
  +   /* Print text */
  +#define PRINTSTR(PIXTYPE) for (p = 0; p  tpg-planes; p++) {  \
  +   unsigned vdiv = tpg-vdownsampling[p];  \
  +   unsigned hdiv = tpg-hdownsampling[p];  \
  PIXTYPE fg; \
  PIXTYPE bg; \
  memcpy(fg, tpg-textfg[p], sizeof(PIXTYPE));   \
  @@ -1548,16 +1546,19 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
  *basep[TPG_MAX_PLANES][2],
  }   \
   } while (0)
   
  -   switch (tpg-twopixelsize[p]) {
  -   case 2:
  -   PRINTSTR(u8); break;
  -   case 4:
  -   PRINTSTR(u16); break;
  -   case 6:
  -   PRINTSTR(x24); break;
  -   case 8:
  -   PRINTSTR(u32); break;
  -   }
  +   switch (tpg-twopixelsize[p]) {
 
 This doesn't work I just discovered. Compiling gives this warning:
 
 drivers/media/platform/vivid/vivid-tpg.c: In function ‘tpg_gen_text’:
 drivers/media/platform/vivid/vivid-tpg.c:1549:27: warning: ‘p’ may be used 
 uninitialized in this function [-Wmaybe-uninitialized]
   switch (tpg-twopixelsize[p]) {
^
 

Weird. here (gcc 5.1.1) I didn't get any warning.

 And the value for tpg-twopixelsize[p] will actually differ depending on the 
 value of p.
 
 It's probably best to revert this patch.
 
 The correct approach is likely to make four functions, one for case,
 with the macro as the function body.

I tried that (without the for). The result was worse.

I'll double check it latter today.

 
 Regards,
 
   Hans
 
  +   case 2:
  +   PRINTSTR(u8);
  +   break;
  +   case 4:
  +   PRINTSTR(u16);
  +   break;
  +   case 6:
  +   PRINTSTR(x24);
  +   break;
  +   case 8:
  +   PRINTSTR(u32);
  +   break;
  }
   }
   
  
 
--
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: move PRINTSTR to separate functions

2015-06-05 Thread Hans Verkuil
Commit 84cb7be43cec12868e94163c99fdc34c0297c3b8 broke vivid-tpg (uninitialized 
variable p).

This patch takes a different approach: four different functions are created, 
one for
each PRINTSTR version.

In order to avoid the 'the frame size of 1308 bytes is larger than 1024 bytes' 
warning I
had to mark those functions with 'noinline'. For whatever reason gcc seems to 
inline this
aggressively and it is doing weird things with the stack.

I tried to read the assembly code, but I couldn't see what exactly it was doing 
on the stack.

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

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index c86c8ff..32ebf0d 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1462,40 +1462,10 @@ static void tpg_precalculate_line(struct tpg_data *tpg)
 /* need this to do rgb24 rendering */
 typedef struct { u16 __; u8 _; } __packed x24;
 
-void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
- int y, int x, char *text)
-{
-   int line;
-   unsigned step = V4L2_FIELD_HAS_T_OR_B(tpg-field) ? 2 : 1;
-   unsigned div = step;
-   unsigned first = 0;
-   unsigned len = strlen(text);
-   unsigned p;
-
-   if (font8x16 == NULL || basep == NULL)
-   return;
-
-   /* Checks if it is possible to show string */
-   if (y + 16 = tpg-compose.height || x + 8 = tpg-compose.width)
-   return;
-
-   if (len  (tpg-compose.width - x) / 8)
-   len = (tpg-compose.width - x) / 8;
-   if (tpg-vflip)
-   y = tpg-compose.height - y - 16;
-   if (tpg-hflip)
-   x = tpg-compose.width - x - 8;
-   y += tpg-compose.top;
-   x += tpg-compose.left;
-   if (tpg-field == V4L2_FIELD_BOTTOM)
-   first = 1;
-   else if (tpg-field == V4L2_FIELD_SEQ_TB || tpg-field == 
V4L2_FIELD_SEQ_BT)
-   div = 2;
-
-   /* Print text */
-#define PRINTSTR(PIXTYPE) for (p = 0; p  tpg-planes; p++) {  \
-   unsigned vdiv = tpg-vdownsampling[p];  \
-   unsigned hdiv = tpg-hdownsampling[p];  \
+#define PRINTSTR(PIXTYPE) do { \
+   unsigned vdiv = tpg-vdownsampling[p]; \
+   unsigned hdiv = tpg-hdownsampling[p]; \
+   int line;   \
PIXTYPE fg; \
PIXTYPE bg; \
memcpy(fg, tpg-textfg[p], sizeof(PIXTYPE));   \
@@ -1546,19 +1516,83 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
}   \
 } while (0)
 
-   switch (tpg-twopixelsize[p]) {
-   case 2:
-   PRINTSTR(u8);
-   break;
-   case 4:
-   PRINTSTR(u16);
-   break;
-   case 6:
-   PRINTSTR(x24);
-   break;
-   case 8:
-   PRINTSTR(u32);
-   break;
+static noinline void tpg_print_str_2(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
+   unsigned p, unsigned first, unsigned div, unsigned step,
+   int y, int x, char *text, unsigned len)
+{
+   PRINTSTR(u8);
+}
+
+static noinline void tpg_print_str_4(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
+   unsigned p, unsigned first, unsigned div, unsigned step,
+   int y, int x, char *text, unsigned len)
+{
+   PRINTSTR(u16);
+}
+
+static noinline void tpg_print_str_6(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
+   unsigned p, unsigned first, unsigned div, unsigned step,
+   int y, int x, char *text, unsigned len)
+{
+   PRINTSTR(x24);
+}
+
+static noinline void tpg_print_str_8(const struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
+   unsigned p, unsigned first, unsigned div, unsigned step,
+   int y, int x, char *text, unsigned len)
+{
+   PRINTSTR(u32);
+}
+
+void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
+ int y, int x, char *text)
+{
+   unsigned step = V4L2_FIELD_HAS_T_OR_B(tpg-field) ? 2 : 1;
+   unsigned div = step;
+   unsigned first = 0;
+   unsigned len = strlen(text);
+   unsigned p;
+
+   if (font8x16 == NULL || basep == NULL)
+   return;
+
+   /* Checks if it is possible to show string */
+   if (y + 16 = tpg-compose.height || x + 8 = tpg-compose.width)
+   return;
+
+   if (len  (tpg-compose.width - x) / 8)
+   len = (tpg-compose.width - x) / 8;
+   if (tpg-vflip)
+   y = tpg-compose.height - y - 16;
+   if (tpg-hflip)
+   x = tpg-compose.width - x - 8;
+   y += tpg-compose.top;
+   x += tpg-compose.left;
+   if (tpg-field == V4L2_FIELD_BOTTOM)
+   first = 1;
+   else if (tpg-field == 

Re: [PATCH v2 1/2] clk: change clk_ops' -round_rate() prototype

2015-06-05 Thread Boris Brezillon
Hi Paul,

On Thu, 4 Jun 2015 23:02:25 + (UTC)
Paul Walmsley p...@pwsan.com wrote:

 Hi folks
 
 just a brief comment on this one:
 
 On Thu, 30 Apr 2015, Boris Brezillon wrote:
 
  Clock rates are stored in an unsigned long field, but -round_rate()
  (which returns a rounded rate from a requested one) returns a long
  value (errors are reported using negative error codes), which can lead
  to long overflow if the clock rate exceed 2Ghz.
  
  Change -round_rate() prototype to return 0 or an error code, and pass the
  requested rate as a pointer so that it can be adjusted depending on
  hardware capabilities.
 
 ...
 
  diff --git a/Documentation/clk.txt b/Documentation/clk.txt
  index 0e4f90a..fca8b7a 100644
  --- a/Documentation/clk.txt
  +++ b/Documentation/clk.txt
  @@ -68,8 +68,8 @@ the operations defined in clk.h:
  int (*is_enabled)(struct clk_hw *hw);
  unsigned long   (*recalc_rate)(struct clk_hw *hw,
  unsigned long parent_rate);
  -   long(*round_rate)(struct clk_hw *hw,
  -   unsigned long rate,
  +   int (*round_rate)(struct clk_hw *hw,
  +   unsigned long *rate,
  unsigned long *parent_rate);
  long(*determine_rate)(struct clk_hw *hw,
  unsigned long rate,
 
 I'd suggest that we should probably go straight to 64-bit rates.  There 
 are already plenty of clock sources that can generate rates higher than 
 4GiHz.

Yep, that was something I was considering too. If Stephen agrees I'll
change that in the next version.
BTW, you're referring to the second version of this patch, but things
have changed a bit: Stephen recommended to only modify the
-determine_rate() prototype and pass a structure instead of a list of
arguments.
Here is the last version of this series [1].

Best Regards,

Boris

[1]http://patchwork.linux-mips.org/patch/10092/

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.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


Re: [PATCH] [media] vivid: don't use more than 1024 bytes of stack

2015-06-05 Thread Hans Verkuil
On 06/05/2015 12:29 PM, Mauro Carvalho Chehab wrote:
 Remove the following compilation warnings:
 
   drivers/media/platform/vivid/vivid-tpg.c: In function 'tpg_gen_text':
   drivers/media/platform/vivid/vivid-tpg.c:1562:1: warning: the frame 
 size of 1308 bytes is larger than 1024 bytes [-Wframe-larger-than=]
}
^
 
 This seems to be due to some bad optimization done by gcc.
 
 Moving the for() loop to happen inside the macro solves the
 issue.
 
 While here, fix CodingStyle at the switch().
 
 Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
 
 diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
 b/drivers/media/platform/vivid/vivid-tpg.c
 index b1147f2df26c..7a3ed580626a 100644
 --- a/drivers/media/platform/vivid/vivid-tpg.c
 +++ b/drivers/media/platform/vivid/vivid-tpg.c
 @@ -1492,12 +1492,10 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
 *basep[TPG_MAX_PLANES][2],
   else if (tpg-field == V4L2_FIELD_SEQ_TB || tpg-field == 
 V4L2_FIELD_SEQ_BT)
   div = 2;
  
 - for (p = 0; p  tpg-planes; p++) {
 - unsigned vdiv = tpg-vdownsampling[p];
 - unsigned hdiv = tpg-hdownsampling[p];
 -
 - /* Print text */
 -#define PRINTSTR(PIXTYPE) do {   \
 + /* Print text */
 +#define PRINTSTR(PIXTYPE) for (p = 0; p  tpg-planes; p++) {\
 + unsigned vdiv = tpg-vdownsampling[p];  \
 + unsigned hdiv = tpg-hdownsampling[p];  \
   PIXTYPE fg; \
   PIXTYPE bg; \
   memcpy(fg, tpg-textfg[p], sizeof(PIXTYPE));   \
 @@ -1548,16 +1546,19 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 
 *basep[TPG_MAX_PLANES][2],
   }   \
  } while (0)
  
 - switch (tpg-twopixelsize[p]) {
 - case 2:
 - PRINTSTR(u8); break;
 - case 4:
 - PRINTSTR(u16); break;
 - case 6:
 - PRINTSTR(x24); break;
 - case 8:
 - PRINTSTR(u32); break;
 - }
 + switch (tpg-twopixelsize[p]) {

This doesn't work I just discovered. Compiling gives this warning:

drivers/media/platform/vivid/vivid-tpg.c: In function ‘tpg_gen_text’:
drivers/media/platform/vivid/vivid-tpg.c:1549:27: warning: ‘p’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  switch (tpg-twopixelsize[p]) {
   ^

And the value for tpg-twopixelsize[p] will actually differ depending on the 
value of p.

It's probably best to revert this patch.

The correct approach is likely to make four functions, one for case,
with the macro as the function body.

Regards,

Hans

 + case 2:
 + PRINTSTR(u8);
 + break;
 + case 4:
 + PRINTSTR(u16);
 + break;
 + case 6:
 + PRINTSTR(x24);
 + break;
 + case 8:
 + PRINTSTR(u32);
 + break;
   }
  }
  
 

--
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: define Media Controller API when CONFIG_MEDIA_CONTROLLER enabled

2015-06-05 Thread Shuah Khan
Change to define Media Controller API when CONFIG_MEDIA_CONTROLLER
is enabled. Define stubs for CONFIG_MEDIA_CONTROLLER disabled case.
This will help avoid drivers needing to enclose Media Controller
code within ifdef CONFIG_MEDIA_CONTROLLER block.

Signed-off-by: Shuah Khan shua...@osg.samsung.com
---
 drivers/media/media-device.c |  4 
 include/media/media-device.h | 27 +++
 2 files changed, 31 insertions(+)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index a4d5b24..c55ab50 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -30,6 +30,8 @@
 #include media/media-devnode.h
 #include media/media-entity.h
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+
 /* 
-
  * Userspace API
  */
@@ -495,3 +497,5 @@ struct media_device *media_device_find_devres(struct device 
*dev)
return devres_find(dev, media_device_release_devres, NULL, NULL);
 }
 EXPORT_SYMBOL_GPL(media_device_find_devres);
+
+#endif /* CONFIG_MEDIA_CONTROLLER */
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 22792cd..a44f18f 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -80,6 +80,8 @@ struct media_device {
   unsigned int notification);
 };
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+
 /* Supported link_notify @notification values. */
 #define MEDIA_DEV_NOTIFY_PRE_LINK_CH   0
 #define MEDIA_DEV_NOTIFY_POST_LINK_CH  1
@@ -102,4 +104,29 @@ struct media_device *media_device_find_devres(struct 
device *dev);
 #define media_device_for_each_entity(entity, mdev) \
list_for_each_entry(entity, (mdev)-entities, list)
 
+#else
+static inline int media_device_register(struct media_device *mdev)
+{
+   return 0;
+}
+static inline void media_device_unregister(struct media_device *mdev)
+{
+}
+static inline int media_device_register_entity(struct media_device *mdev,
+   struct media_entity *entity)
+{
+   return 0;
+}
+static inline void media_device_unregister_entity(struct media_entity *entity)
+{
+}
+static inline struct media_device *media_device_get_devres(struct device *dev)
+{
+   return NULL;
+}
+static inline struct media_device *media_device_find_devres(struct device *dev)
+{
+   return NULL;
+}
+#endif /* CONFIG_MEDIA_CONTROLLER */
 #endif
-- 
2.1.4

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


Re: [PATCH] Doc:nfc: Fix typo in nfc-hci.txt

2015-06-05 Thread Jonathan Corbet
On Fri,  5 Jun 2015 21:38:19 +0900
Masanari Iida standby2...@gmail.com wrote:

 This patch fix a spelling typo in nfc-hci.txt

Applied to the docs tree, thanks.

jon
--
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] s5k5baf: Convert use of __constant_cpu_to_be16 to cpu_to_be16

2015-06-05 Thread Vaishali Thakkar
In little endian cases, macro cpu_to_be16 unfolds to __swab16 which
provides special case for constants. In big endian cases,
__constant_cpu_to_be16 and cpu_to_be16 expand directly to the
same expression. So, replace __constant_cpu_to_be16 with
cpu_to_be16 with the goal of getting rid of the definition of
__constant_cpu_to_be16 completely.

The semantic patch that performs this transformation is as follows:

@@expression x;@@

- __constant_cpu_to_be16(x)
+ cpu_to_be16(x)

Signed-off-by: Vaishali Thakkar vthakkar1...@gmail.com
---
 drivers/media/i2c/s5k5baf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 297ef04..7a43b55 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -491,7 +491,7 @@ static void s5k5baf_write_arr_seq(struct s5k5baf *state, 
u16 addr,
v4l2_dbg(3, debug, c, i2c_write_seq(count=%d): %*ph\n, count,
 min(2 * count, 64), seq);
 
-   buf[0] = __constant_cpu_to_be16(REG_CMD_BUF);
+   buf[0] = cpu_to_be16(REG_CMD_BUF);
 
while (count  0) {
int n = min_t(int, count, ARRAY_SIZE(buf) - 1);
-- 
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


cron job: media_tree daily build: WARNINGS

2015-06-05 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:   Sat Jun  6 04:00:19 CEST 2015
git branch: test
git hash:   c70316f2a193fcd62232cddc1b2d44997ca2c930
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-44-g40791b9
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:4.0.0-3.slh.1-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-bf561: 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.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1-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.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: WARNINGS
linux-4.1-rc1-x86_64: WARNINGS
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.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



Si2168 B40 frimware.

2015-06-05 Thread Unembossed Name

Hi,

Yesterday I extracted a new firmware for Si2168 B40 rev. from Windows 
driver.

It's designed for ROM version 4.0.2 and has a version build 4.0.19
Here is a name of 
file:dvb-demod-si2168-b40-rom4_0_2-patch-build4_0_19.fw.tar.gz

And a link for download: http://beholder.ru/bb/download/file.php?id=854
Anybody want to test it? Unfortunately, I can not do it myself, because I do 
not own hardware with B40 revision.


Best regards. 


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


About Si2168 Part, Revision and ROM detection.

2015-06-05 Thread Unembossed Name

Hi,

Information below was given by a hardware vendor, who uses these demodulators on their dvb-t2 products. As an explanation on our 
questions for Si2168 Linux driver development.

I think it can give more clue with Part, Revision and ROM detection algorithm 
in Linux driver for that demodulator.

Also, I would like to suggest a following naming method for files containing 
firmware patches. It's self explaining:
dvb-demod-si2168-a30-rom3_0_2-patch-build3_0_20.fw
dvb-demod-si2168-b40-rom4_0_2-patch-build4_0_19.fw.tar.gz
dvb-demod-si2168-b40-rom4_0_2-startup-without-patch-stub.fw
(Stub code to startup B40 without patch at all: 
0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00)
I think such naming scheme can help to avoid possible mess with fw patch 
versions.

Here is a detection code:
NTSTATUS si2168_cmd_part_info(tPART_INFO *part_info)
{
   NTSTATUS ntStatus;

   BYTE cmdBuffer[1] = {Si2168_PART_INFO_CMD};
   BYTE rspBuffer[13] = {0};

   ntStatus = si2168_cmd_rsp(cmdBuffer, sizeof(cmdBuffer), rspBuffer, 
sizeof(rspBuffer));
   if (ntStatus != STATUS_SUCCESS)
   return ntStatus;

   part_info-chiprev = rspBuffer[1]  0x0F;
   part_info-part = rspBuffer[2];
   part_info-pmajor = rspBuffer[3];
   part_info-pminor = rspBuffer[4];
   part_info-pbuild = rspBuffer[5];
   part_info-serial = ((ULONG)rspBuffer[11]  24) | ((ULONG)rspBuffer[10]  16) | ((ULONG)rspBuffer[9]  8) | 
((ULONG)rspBuffer[8]);

   part_info-romid = rspBuffer[12];

   DBGPRINT((CHIP REV   : %d\n, part_info-chiprev));
   DBGPRINT((CHIP PART  : %d\n, part_info-part));
   DBGPRINT((CHIP PMAJOR: %c\n, part_info-pmajor));
   DBGPRINT((CHIP PMINOR: %c\n, part_info-pminor));
   DBGPRINT((CHIP PBUILD: %d\n, part_info-pbuild));
   DBGPRINT((CHIP SERIAL: %08X\n, part_info-serial ));
   DBGPRINT((CHIP ROMID : %d\n, part_info-romid));

   return STATUS_SUCCESS;
}

Best regards. 


--
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 2/2] sound/usb: Update ALSA driver to use media controller API

2015-06-05 Thread Shuah Khan
On 06/03/2015 01:14 PM, Mauro Carvalho Chehab wrote:
 Em Wed, 03 Jun 2015 09:12:54 -0600
 Shuah Khan shua...@osg.samsung.com escreveu:
 
 Change ALSA driver to use media controller API to share tuner
 with DVB and V4L2 drivers that control AU0828 media device.
 Media device is created based on a newly added field value
 in the struct snd_usb_audio_quirk. Using this approach, the
 media controller API usage can be added for a specific device.
 In this patch, media controller API is enabled for AU0828 hw.
 snd_usb_create_quirk() will check this new field, if set will
 create a media device using media_device_get_devres() interface.
 media_device_get_devres() will allocate a new media device
 devres or return an existing one, if it finds one.

 During probe, media usb driver could have created the media
 device devres. It will then register the media device if it
 isn't already registered. Media device unregister is done
 from usb_audio_disconnect().

 New structure media_ctl is added to group the new fields
 to support media entity and links. This new structure is
 added to struct snd_usb_substream. A new media entity for
 ALSA and a link from tuner entity to the newly registered
 ALSA entity are created from snd_usb_init_substream() and
 removed from free_substream(). The state is kept to indicate
 if tuner is linked. This is to account for case when tuner
 entity doesn't exist. Media pipeline gets started to mark
 the tuner busy from snd_usb_substream_capture_trigger in
 response to SNDRV_PCM_TRIGGER_START and pipeline is stopped
 in response to SNDRV_PCM_TRIGGER_STOP. snd_usb_pcm_close()
 stops pipeline to cover the case when SNDRV_PCM_TRIGGER_STOP
 isn't issued. Pipeline start and stop are done only when
 tuner_linked is set.

 Tested with and without CONFIG_MEDIA_CONTROLLER enabled.
 Tested tuner entity doesn't exist case as au0828 v4l2
 driver is the one that will create the tuner when it gets
 updated to use media controller API.

 Signed-off-by: Shuah Khan shua...@osg.samsung.com
 ---
  sound/usb/Makefile   |   3 +-
  sound/usb/card.c |   5 ++
  sound/usb/card.h |   1 +
  sound/usb/media.c| 181 
 +++
  sound/usb/media.h|  40 +++
  sound/usb/pcm.c  |  10 ++-
  sound/usb/quirks-table.h |   1 +
  sound/usb/quirks.c   |   9 ++-
  sound/usb/stream.c   |   3 +
  sound/usb/usbaudio.h |   1 +
  10 files changed, 251 insertions(+), 3 deletions(-)
  create mode 100644 sound/usb/media.c
  create mode 100644 sound/usb/media.h

 diff --git a/sound/usb/Makefile b/sound/usb/Makefile
 index 2d2d122..7fe4fdd 100644
 --- a/sound/usb/Makefile
 +++ b/sound/usb/Makefile
 @@ -13,7 +13,8 @@ snd-usb-audio-objs :=  card.o \
  pcm.o \
  proc.o \
  quirks.o \
 -stream.o
 +stream.o \
 +media.o
  
  snd-usbmidi-lib-objs := midi.o
  
 diff --git a/sound/usb/card.c b/sound/usb/card.c
 index 1fab977..469d2bf 100644
 --- a/sound/usb/card.c
 +++ b/sound/usb/card.c
 @@ -66,6 +66,7 @@
  #include format.h
  #include power.h
  #include stream.h
 +#include media.h
  
  MODULE_AUTHOR(Takashi Iwai ti...@suse.de);
  MODULE_DESCRIPTION(USB Audio);
 @@ -619,6 +620,10 @@ static void usb_audio_disconnect(struct usb_interface 
 *intf)
  list_for_each_entry(mixer, chip-mixer_list, list) {
  snd_usb_mixer_disconnect(mixer);
  }
 +/* Nice to check quirk  quirk-media_device
 + * need some special handlings. Doesn't look like
 + * we have access to quirk here */
 +media_device_delete(intf);
  }
  
  chip-num_interfaces--;
 diff --git a/sound/usb/card.h b/sound/usb/card.h
 index ef580b4..235a85f 100644
 --- a/sound/usb/card.h
 +++ b/sound/usb/card.h
 @@ -155,6 +155,7 @@ struct snd_usb_substream {
  } dsd_dop;
  
  bool trigger_tstamp_pending_update; /* trigger timestamp being updated 
 from initial estimate */
 +void *media_ctl;
  };
  
  struct snd_usb_stream {
 diff --git a/sound/usb/media.c b/sound/usb/media.c
 new file mode 100644
 index 000..8e8a0b3
 --- /dev/null
 +++ b/sound/usb/media.c
 @@ -0,0 +1,181 @@
 +/*
 + * media.c - managed media token resource
 + *
 + * Copyright (c) 2015 Shuah Khan shua...@osg.samsung.com
 + * Copyright (c) 2015 Samsung Electronics Co., Ltd.
 + *
 + * This file is released under the GPLv2.
 + */
 +
 +/*
 + * This file adds Media Controller support to ALSA driver
 + * to use the Media Controller API to share tuner with DVB
 + * and V4L2 drivers that control media device. Media device
 + * is created based on existing quirks framework. Using this
 + * approach, the media controller API usage can be added for
 + * a specific device.
 +*/
 +
 +#ifdef CONFIG_MEDIA_CONTROLLER
 +#if defined(CONFIG_MEDIA_SUPPORT) || \
 +(defined(CONFIG_MEDIA_SUPPORT_MODULE)  defined(MODULE))
 

Re: [PATCH 0/9] Some smatch fixups

2015-06-05 Thread Mauro Carvalho Chehab
Em Fri, 05 Jun 2015 11:27:33 -0300
Mauro Carvalho Chehab mche...@osg.samsung.com escreveu:

 Fix several smatch warnings.
 
 There are still 27 smatch warnings at drivers/media:

Please discard this e-mail. Git sent it by accident. This is a version
of patch 0/11, saved with another name (and another extension).

The same applies to the other e-mail with the very same subject.

The real one is [PATCH 00/11] Some smatch fixups.

 
 
 This one:
   drivers/media/pci/cx23885/cx23885-dvb.c:2046 dvb_register() Function 
 too hairy.  Giving up.
 
 It is just to a random memory limit at smatch that allows it to
 allocate only 50Mb of memory for name allocation. I fixed it
 locally and submitted a fix to Dan.
 
 Those seem to be false-positives:
   drivers/media/dvb-frontends/stv0900_core.c:1183 
 stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
   drivers/media/dvb-frontends/stv0900_core.c:1185 
 stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
   drivers/media/dvb-frontends/stv0900_core.c:1187 
 stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
   drivers/media/dvb-frontends/stv0900_core.c:1189 
 stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
   drivers/media/dvb-frontends/stv0900_core.c:1191 
 stv0900_get_optim_carr_loop() error: buffer overflow 'cllas2' 11 = 13
   drivers/media/media-entity.c:238:17: warning: Variable length array is 
 used.
   drivers/media/media-entity.c:239:17: warning: Variable length array is 
 used.
   drivers/media/pci/ttpci/av7110.c:2210 frontend_init() warn: missing 
 break? reassigning 'av7110-fe'
   drivers/media/pci/ttpci/budget.c:631 frontend_init() warn: missing 
 break? reassigning 'budget-dvb_frontend'
   drivers/media/platform/vivid/vivid-rds-gen.c:82 vivid_rds_generate() 
 error: buffer overflow 'rds-psname' 9 = 43
   drivers/media/platform/vivid/vivid-rds-gen.c:83 vivid_rds_generate() 
 error: buffer overflow 'rds-psname' 9 = 42
   drivers/media/platform/vivid/vivid-rds-gen.c:89 vivid_rds_generate() 
 error: buffer overflow 'rds-radiotext' 65 = 84
   drivers/media/platform/vivid/vivid-rds-gen.c:90 vivid_rds_generate() 
 error: buffer overflow 'rds-radiotext' 65 = 85
   drivers/media/platform/vivid/vivid-rds-gen.c:92 vivid_rds_generate() 
 error: buffer overflow 'rds-radiotext' 65 = 86
   drivers/media/platform/vivid/vivid-rds-gen.c:93 vivid_rds_generate() 
 error: buffer overflow 'rds-radiotext' 65 = 87
   drivers/media/radio/radio-aimslab.c:73 rtrack_alloc() warn: possible 
 memory leak of 'rt'
   drivers/media/radio/radio-aztech.c:87 aztech_alloc() warn: possible 
 memory leak of 'az'
   drivers/media/radio/radio-gemtek.c:189 gemtek_alloc() warn: possible 
 memory leak of 'gt'
   drivers/media/radio/radio-trust.c:60 trust_alloc() warn: possible 
 memory leak of 'tr'
   drivers/media/radio/radio-typhoon.c:79 typhoon_alloc() warn: possible 
 memory leak of 'ty'
   drivers/media/radio/radio-zoltrix.c:83 zoltrix_alloc() warn: possible 
 memory leak of 'zol'
   drivers/media/usb/pvrusb2/pvrusb2-encoder.c:227 pvr2_encoder_cmd() 
 error: buffer overflow 'wrData' 16 = 16
   drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3676 pvr2_send_request_ex() 
 error: we previously assumed 'write_data' could be null (see line 3648)
   drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3829 pvr2_send_request_ex() 
 error: we previously assumed 'read_data' could be null (see line 3649)
 
 I didn't find an easy/worth way to remove the above.
 
 This one is due to a code that got commented:
   drivers/media/usb/usbvision/usbvision-video.c:1072 usbvision_read() 
 warn: inconsistent indenting
 
 Probably the best here is to remove the commented code and fix 
 identation.
 
 This one seems a real bug, but fixing it would require some tests with 
 the hardware, and a better understanding on what the function should be 
 expecting to do when steal is NULL:
   drivers/media/pci/ivtv/ivtv-queue.c:145 ivtv_queue_move() error: we 
 previously assumed 'steal' could be null (see line 138)
 
 Mauro Carvalho Chehab (9):
   [media] drxk: better handle errors
   [media] em28xx: remove dead code
   [media] sh_vou: avoid going past arrays
   dib0090: Remove a dead code
   [media] bt8xx: remove needless check
   [media] ivtv: fix two smatch warnings
   tm6000: remove needless check
   [media] ir: Fix IR_MAX_DURATION enforcement
   rc: set IR_MAX_DURATION to 500 ms
 
  drivers/media/dvb-frontends/dib0090.c   |   4 +-
  drivers/media/dvb-frontends/drxk_hard.c |   7 +-
  drivers/media/pci/bt8xx/dst_ca.c| 132 
 
  drivers/media/pci/ivtv/ivtv-driver.h|   3 +-
  drivers/media/platform/sh_vou.c |  14 ++--
  drivers/media/rc/redrat3.c  |   5 +-
  drivers/media/rc/streamzap.c|   6 +-
  drivers/media/usb/em28xx/em28xx-video.c |   1 -
  drivers/media/usb/tm6000/tm6000-video.c |  

Re: [PATCH 08/11] [media] ir: Fix IR_MAX_DURATION enforcement

2015-06-05 Thread Sean Young
On Fri, Jun 05, 2015 at 11:27:41AM -0300, Mauro Carvalho Chehab wrote:
 Don't assume that IR_MAX_DURATION is a bitmask. It isn't.

The patch is right, but note that IR_MAX_DURATION is 0x, and in
all these cases it is being compared to a u32, so it is always false.

Should these statements simply be removed? None of the other drivers
do these checks.


Sean

 
 Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com
 
 diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
 index c83292ad1b34..ec74244a3853 100644
 --- a/drivers/media/rc/redrat3.c
 +++ b/drivers/media/rc/redrat3.c
 @@ -322,7 +322,7 @@ static u32 redrat3_us_to_len(u32 microsec)
   u32 result;
   u32 divisor;
  
 - microsec = IR_MAX_DURATION;
 + microsec = (microsec  IR_MAX_DURATION) ? IR_MAX_DURATION : microsec;
   divisor = (RR3_CLK_CONV_FACTOR / 1000);
   result = (u32)(microsec * divisor) / 1000;
  
 @@ -380,7 +380,8 @@ static void redrat3_process_ir_data(struct redrat3_dev 
 *rr3)
   if (i == 0)
   trailer = rawir.duration;
   /* cap the value to IR_MAX_DURATION */
 - rawir.duration = IR_MAX_DURATION;
 + rawir.duration = (rawir.duration  IR_MAX_DURATION) ?
 +  IR_MAX_DURATION : rawir.duration;
  
   dev_dbg(dev, storing %s with duration %d (i: %d)\n,
   rawir.pulse ? pulse : space, rawir.duration, i);
 diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
 index bf4a44272f0e..5a17cb88ff27 100644
 --- a/drivers/media/rc/streamzap.c
 +++ b/drivers/media/rc/streamzap.c
 @@ -152,7 +152,8 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
   sz-signal_last.tv_usec);
   rawir.duration -= sz-sum;
   rawir.duration = US_TO_NS(rawir.duration);
 - rawir.duration = IR_MAX_DURATION;
 + rawir.duration = (rawir.duration  IR_MAX_DURATION) ?
 +  IR_MAX_DURATION : rawir.duration;
   }
   sz_push(sz, rawir);
  
 @@ -165,7 +166,8 @@ static void sz_push_full_pulse(struct streamzap_ir *sz,
   rawir.duration += SZ_RESOLUTION / 2;
   sz-sum += rawir.duration;
   rawir.duration = US_TO_NS(rawir.duration);
 - rawir.duration = IR_MAX_DURATION;
 + rawir.duration = (rawir.duration  IR_MAX_DURATION) ?
 +  IR_MAX_DURATION : rawir.duration;
   sz_push(sz, rawir);
  }
--
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 v4.2] New ST driver, various fixes

2015-06-05 Thread Hans Verkuil
This adds a bunch of various fixes and a new bdisp driver for ST.

Regards,

Hans

The following changes since commit c1c3c85ddf60a6d97c122d57d385b4929fcec4b3:

  [media] DocBook: fix FE_SET_PROPERTY ioctl arguments (2015-06-01 06:10:15 
-0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.2o

for you to fetch changes up to febaafbd27c975a7a92ef99af31f06170c231129:

  v4l2-ioctl: log buffer type 0 correctly (2015-06-05 16:55:51 +0200)


Fabian Frederick (1):
  omap_vout: use swap() in omapvid_init()

Fabien Dessenne (3):
  bdisp: add DT bindings documentation
  bdisp: 2D blitter driver using v4l2 mem2mem framework
  bdisp: add debug file system

Fabio Estevam (1):
  radio-si470x-i2c: Pass the IRQF_ONESHOT flag

Hans Verkuil (6):
  vivid: move video loopback control to the capture device
  stk1160: add DMABUF support
  vivid-tpg: improve Y16 color setup
  v4l2-ioctl: clear the reserved field of v4l2_create_buffers
  DocBook media: correct description of reserved fields
  v4l2-ioctl: log buffer type 0 correctly

Juergen Gier (1):
  saa7134: switch tuner FMD1216ME_MK3 to analog

Nikhil Devshatwar (1):
  v4l: of: Correct pclk-sample for BT656 bus

 Documentation/DocBook/media/v4l/io.xml |   12 +-
 Documentation/DocBook/media/v4l/pixfmt.xml |8 +-
 Documentation/DocBook/media/v4l/vidioc-create-bufs.xml |3 +-
 Documentation/DocBook/media/v4l/vidioc-enum-frameintervals.xml |3 +-
 Documentation/DocBook/media/v4l/vidioc-enum-framesizes.xml |3 +-
 Documentation/DocBook/media/v4l/vidioc-expbuf.xml  |3 +-
 Documentation/DocBook/media/v4l/vidioc-g-selection.xml |2 +-
 Documentation/DocBook/media/v4l/vidioc-querybuf.xml|3 +-
 Documentation/DocBook/media/v4l/vidioc-reqbufs.xml |4 +-
 Documentation/devicetree/bindings/media/st,stih4xx.txt |   32 ++
 Documentation/video4linux/vivid.txt|2 +-
 drivers/media/pci/saa7134/saa7134-cards.c  |   17 +-
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/omap/omap_vout.c|   10 +-
 drivers/media/platform/sti/bdisp/Kconfig   |9 +
 drivers/media/platform/sti/bdisp/Makefile  |3 +
 drivers/media/platform/sti/bdisp/bdisp-debug.c |  668 

 drivers/media/platform/sti/bdisp/bdisp-filter.h|  346 
+++
 drivers/media/platform/sti/bdisp/bdisp-hw.c|  823 
+++
 drivers/media/platform/sti/bdisp/bdisp-reg.h   |  235 
++
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c  | 1420 

 drivers/media/platform/sti/bdisp/bdisp.h   |  216 +
 drivers/media/platform/vivid/vivid-core.h  |2 +-
 drivers/media/platform/vivid/vivid-ctrls.c |   81 ++--
 drivers/media/platform/vivid/vivid-tpg.c   |   11 +-
 drivers/media/radio/si470x/radio-si470x-i2c.c  |3 +-
 drivers/media/usb/stk1160/stk1160-v4l.c|3 +-
 drivers/media/v4l2-core/v4l2-ioctl.c   |3 +
 drivers/media/v4l2-core/v4l2-of.c  |8 +-
 30 files changed, 3866 insertions(+), 79 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/st,stih4xx.txt
 create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
 create mode 100644 drivers/media/platform/sti/bdisp/Makefile
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-debug.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
 create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h
--
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 08/11] [media] ir: Fix IR_MAX_DURATION enforcement

2015-06-05 Thread Mauro Carvalho Chehab
Em Fri, 05 Jun 2015 16:00:43 +0100
Sean Young s...@mess.org escreveu:

 On Fri, Jun 05, 2015 at 03:55:38PM +0100, Sean Young wrote:
  On Fri, Jun 05, 2015 at 11:27:41AM -0300, Mauro Carvalho Chehab wrote:
   Don't assume that IR_MAX_DURATION is a bitmask. It isn't.
  
  The patch is right, but note that IR_MAX_DURATION is 0x, and in
  all these cases it is being compared to a u32, so it is always false.
  
  Should these statements simply be removed? None of the other drivers
  do these checks.
 
 Sorry please ignore me, I should have read the whole patch series. :(

Yeah, patch 9/11 addresses it. We'll very likely need a check against
a maximum value. The Y2038 patches converting several timestamps to 64 bits.

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


[GIT PULL FOR v4.2] Helper to abstract vma handling in media layer

2015-06-05 Thread Hans Verkuil
This pull request merged Jan's vb2/mm patches to abstract vma handling.

See http://www.spinics.net/lists/linux-media/msg89653.html for more info.

It's the same pull request as from May 25th, but with an additional patch that
puts get_vaddr_frames() behind a config option (requested by Andrew Morton).

Regards,

Hans

The following changes since commit 64d5702229d86deacf42a43bc893a981f72d4908:

  [media] vivid.txt: update the vivid documentation (2015-06-05 11:52:12 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git for-v4.2m

for you to fetch changes up to 1382dd5a8f783f368f8b1dd687ee0bf0a93ed899:

  mm: Move get_vaddr_frames() behind a config option (2015-06-05 17:01:17 +0200)


Jan Kara (9):
  mm: Provide new get_vaddr_frames() helper
  media: omap_vout: Convert omap_vout_uservirt_to_phys() to use 
get_vaddr_pfns()
  vb2: Provide helpers for mapping virtual addresses
  media: vb2: Convert vb2_dma_sg_get_userptr() to use frame vector
  media: vb2: Convert vb2_vmalloc_get_userptr() to use frame vector
  media: vb2: Convert vb2_dc_get_userptr() to use frame vector
  media: vb2: Remove unused functions
  drm/exynos: Convert g2d_userptr_get_dma_addr() to use get_vaddr_frames()
  mm: Move get_vaddr_frames() behind a config option

 drivers/gpu/drm/exynos/Kconfig |   1 +
 drivers/gpu/drm/exynos/exynos_drm_g2d.c|  91 
++
 drivers/gpu/drm/exynos/exynos_drm_gem.c|  97 

 drivers/media/platform/omap/Kconfig|   1 +
 drivers/media/platform/omap/omap_vout.c|  69 +++
 drivers/media/v4l2-core/Kconfig|   1 +
 drivers/media/v4l2-core/videobuf2-dma-contig.c | 214 
---
 drivers/media/v4l2-core/videobuf2-dma-sg.c |  97 
+---
 drivers/media/v4l2-core/videobuf2-memops.c | 148 
-
 drivers/media/v4l2-core/videobuf2-vmalloc.c|  94 
---
 include/linux/mm.h |  44 +++
 include/media/videobuf2-memops.h   |  11 ++--
 mm/Kconfig |   3 +
 mm/Makefile|   1 +
 mm/frame_vector.c  | 232 
+
 mm/gup.c   |   1 +
 16 files changed, 480 insertions(+), 625 deletions(-)
 create mode 100644 mm/frame_vector.c
--
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 08/11] [media] ir: Fix IR_MAX_DURATION enforcement

2015-06-05 Thread Sean Young
On Fri, Jun 05, 2015 at 03:55:38PM +0100, Sean Young wrote:
 On Fri, Jun 05, 2015 at 11:27:41AM -0300, Mauro Carvalho Chehab wrote:
  Don't assume that IR_MAX_DURATION is a bitmask. It isn't.
 
 The patch is right, but note that IR_MAX_DURATION is 0x, and in
 all these cases it is being compared to a u32, so it is always false.
 
 Should these statements simply be removed? None of the other drivers
 do these checks.

Sorry please ignore me, I should have read the whole patch series. :(


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