[PATCH] [media] dvb_core: Replace memset with eth_zero_addr

2015-06-19 Thread Vaishali Thakkar
Use eth_zero_addr to assign the zero address to the given address
array instead of memset when second argument is address of zero.

The Coccinelle semantic patch that makes this change is as follows:

// smpl
@eth_zero_addr@
expression e;
@@

-memset(e,0x00,ETH_ALEN);
+eth_zero_addr(e);
// /smpl

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

diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index a694fb1..b81e026 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -709,7 +709,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 
*buf, size_t buf_len )
if (!priv-ule_dbit) {
 /* dest_addr buffer is only 
valid if priv-ule_dbit == 0 */
memcpy(ethh-h_dest, dest_addr, 
ETH_ALEN);
-   memset(ethh-h_source, 0, 
ETH_ALEN);
+   eth_zero_addr(ethh-h_source);
}
else /* zeroize source and dest */
memset( ethh, 0, ETH_ALEN*2 );
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in


cron job: media_tree daily build: OK

2015-06-19 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 20 04:00:17 CEST 2015
git branch: test
git hash:   6f32a8c97f11eb074027052b6b507891e5c9d8b1
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: OK
linux-4.1-rc1-x86_64: OK
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


[PATCH for v4.2] cobalt: set Kconfig default to n

2015-06-19 Thread Hans Verkuil
Since this board is a Cisco-internal board there is no point in having it 
compiled
by default. So set the Kconfig default to n.

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

diff --git a/drivers/media/pci/cobalt/Kconfig b/drivers/media/pci/cobalt/Kconfig
index 3be1b2c..4d0777a 100644
--- a/drivers/media/pci/cobalt/Kconfig
+++ b/drivers/media/pci/cobalt/Kconfig
@@ -7,6 +7,7 @@ config VIDEO_COBALT
select VIDEO_ADV7511
select VIDEO_ADV7842
select VIDEOBUF2_DMA_SG
+   default n
---help---
  This is a video4linux driver for the Cisco PCIe Cobalt card.
 
--
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 v10.1] leds: aat1290: add support for V4L2 Flash sub-device

2015-06-19 Thread Jacek Anaszewski
Add support for V4L2 Flash sub-device to the aat1290 LED Flash class
driver. The support allows for V4L2 Flash sub-device to take the control
of the LED Flash class device.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Bryan Wu coolo...@gmail.com
Cc: Richard Purdie rpur...@rpsys.net
Cc: Sakari Ailus sakari.ai...@iki.fi
---
- fixed sparse warnings by adding 'static' modifiers to the functions:
  * aat1290_intensity_to_brightness
  * aat1290_brightness_to_intensity

 drivers/leds/Kconfig|1 +
 drivers/leds/leds-aat1290.c |  137 +--
 2 files changed, 132 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 14876d3..a1013c5 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -44,6 +44,7 @@ config LEDS_AAT1290
depends on LEDS_CLASS_FLASH
depends on GPIOLIB
depends on OF
+   depends on PINCTRL
help
 This option enables support for the LEDs on the AAT1290.
 
diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
index b055882..2a5254c 100644
--- a/drivers/leds/leds-aat1290.c
+++ b/drivers/leds/leds-aat1290.c
@@ -17,9 +17,11 @@
 #include linux/module.h
 #include linux/mutex.h
 #include linux/of.h
+#include linux/pinctrl/consumer.h
 #include linux/platform_device.h
 #include linux/slab.h
 #include linux/workqueue.h
+#include media/v4l2-flash-led-class.h
 
 #define AAT1290_MOVIE_MODE_CURRENT_ADDR17
 #define AAT1290_MAX_MM_CURR_PERCENT_0  16
@@ -52,6 +54,8 @@ struct aat1290_led_config_data {
u32 max_flash_current;
/* maximum flash timeout */
u32 max_flash_tm;
+   /* external strobe capability */
+   bool has_external_strobe;
/* max LED brightness level */
enum led_brightness max_brightness;
 };
@@ -64,6 +68,8 @@ struct aat1290_led {
 
/* corresponding LED Flash class device */
struct led_classdev_flash fled_cdev;
+   /* V4L2 Flash device */
+   struct v4l2_flash *v4l2_flash;
 
/* FLEN pin */
struct gpio_desc *gpio_fl_en;
@@ -230,11 +236,15 @@ static int aat1290_led_flash_timeout_set(struct 
led_classdev_flash *fled_cdev,
 }
 
 static int aat1290_led_parse_dt(struct aat1290_led *led,
-   struct aat1290_led_config_data *cfg)
+   struct aat1290_led_config_data *cfg,
+   struct device_node **sub_node)
 {
struct led_classdev *led_cdev = led-fled_cdev.led_cdev;
struct device *dev = led-pdev-dev;
struct device_node *child_node;
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+   struct pinctrl *pinctrl;
+#endif
int ret = 0;
 
led-gpio_fl_en = devm_gpiod_get(dev, flen, GPIOD_ASIS);
@@ -251,6 +261,17 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
return ret;
}
 
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+   pinctrl = devm_pinctrl_get_select_default(led-pdev-dev);
+   if (IS_ERR(pinctrl)) {
+   cfg-has_external_strobe = false;
+   dev_info(dev,
+No support for external strobe detected.\n);
+   } else {
+   cfg-has_external_strobe = true;
+   }
+#endif
+
child_node = of_get_next_available_child(dev-of_node, NULL);
if (!child_node) {
dev_err(dev, No DT child node found for connected LED.\n);
@@ -288,6 +309,8 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
 
of_node_put(child_node);
 
+   *sub_node = child_node;
+
return ret;
 }
 
@@ -316,7 +339,8 @@ static int init_mm_current_scale(struct aat1290_led *led,
int i, max_mm_current =
AAT1290_MAX_MM_CURRENT(cfg-max_flash_current);
 
-   led-mm_current_scale = kzalloc(sizeof(max_mm_current_percent),
+   led-mm_current_scale = devm_kzalloc(led-pdev-dev,
+   sizeof(max_mm_current_percent),
GFP_KERNEL);
if (!led-mm_current_scale)
return -ENOMEM;
@@ -329,11 +353,12 @@ static int init_mm_current_scale(struct aat1290_led *led,
 }
 
 static int aat1290_led_get_configuration(struct aat1290_led *led,
-   struct aat1290_led_config_data *cfg)
+   struct aat1290_led_config_data *cfg,
+   struct device_node **sub_node)
 {
int ret;
 
-   ret = aat1290_led_parse_dt(led, cfg);
+   ret = aat1290_led_parse_dt(led, cfg, sub_node);
if (ret  0)
return ret;
/*
@@ -346,7 +371,10 @@ static int aat1290_led_get_configuration(struct 
aat1290_led *led,
 
aat1290_led_validate_mm_current(led, cfg);
 
-   kfree(led-mm_current_scale);
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+#else
+   devm_kfree(led-pdev-dev, 

Total system hang/freeze - segfault - error 4 in libc-2.21.so

2015-06-19 Thread Michael


Greetings!

Apologies if this is the inappropriate method of contact. I was 
directed here from tvheadend's support forum.


I have an Asrock Q2900-ITX with an RTL2838 USB DVB-T device (0bda:2838) 
that works out of the box on Kernels 3.19.0 (Ubuntu Vivid) and 4.0.5 
(both distros).


Unfortunately, while using the device, either system (my laptop or 
media center) will freeze. No response at all, power-cycle needed.
I downgraded Arch to the 3.14.44 LTS kernel where everything seems 
stable.


There's no log of kernel panicking. The only form of errors I could 
find at all are at the time of the freeze:


kernel: [   10.330935] show_signal_msg: 39 callbacks suppressed
kernel: [   10.330946] PVRManager[1212]: segfault at 18 ip 
7fecdf6fe929 sp 7feca67fb430 error 4 in 
libc-2.21.so[7fecdf67d000+1c]


Maybe this means something to you guys? I am willing to provide more 
information and stuff if you want. This is pretty alien to me.


Thank you!
Michael

--
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] leds: aat1290: Add 'static' modifier to init_mm_current_scale

2015-06-19 Thread Jacek Anaszewski
Fix sparse warning by adding static modifier to the function
init_mm_current_scale.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
---
 drivers/leds/leds-aat1290.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
index 8635404..b055882 100644
--- a/drivers/leds/leds-aat1290.c
+++ b/drivers/leds/leds-aat1290.c
@@ -308,7 +308,7 @@ static void aat1290_led_validate_mm_current(struct 
aat1290_led *led,
cfg-max_brightness = b + 1;
 }
 
-int init_mm_current_scale(struct aat1290_led *led,
+static int init_mm_current_scale(struct aat1290_led *led,
struct aat1290_led_config_data *cfg)
 {
int max_mm_current_percent[] = { 20, 22, 25, 28, 32, 36, 40, 45, 50, 56,
-- 
1.7.9.5

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


[PATCH v3] media: i2c: ADV7604: Migrate to regmap

2015-06-19 Thread Pablo Anton
This is a preliminary patch in order to add support for ALSA.
It replaces all current i2c access with regmap.

Signed-off-by: Pablo Anton pablo.an...@veo-labs.com
Signed-off-by: Jean-Michel Hautbois jean-michel.hautb...@veo-labs.com
Acked-by: Hans Verkuil hans.verk...@cisco.com
Tested-by: Hans Verkuil hans.verk...@cisco.com
---
v3: check return value of regmap_read
start configure_regmaps from ADV7604_PAGE_AVLINK
add Acked-by and Tested-by
change some v4l2_info to v4l2_err

 drivers/media/i2c/adv7604.c | 351 
 1 file changed, 256 insertions(+), 95 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 60ffcf0..0bbf800 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -36,6 +36,7 @@
 #include linux/v4l2-dv-timings.h
 #include linux/videodev2.h
 #include linux/workqueue.h
+#include linux/regmap.h
 
 #include media/adv7604.h
 #include media/v4l2-ctrls.h
@@ -166,6 +167,9 @@ struct adv76xx_state {
/* i2c clients */
struct i2c_client *i2c_clients[ADV76XX_PAGE_MAX];
 
+   /* Regmaps */
+   struct regmap *regmap[ADV76XX_PAGE_MAX];
+
/* controls */
struct v4l2_ctrl *detect_tx_5v_ctrl;
struct v4l2_ctrl *analog_sampling_phase_ctrl;
@@ -346,66 +350,39 @@ static inline unsigned vtotal(const struct 
v4l2_bt_timings *t)
 
 /* --- */
 
-static s32 adv_smbus_read_byte_data_check(struct i2c_client *client,
-   u8 command, bool check)
-{
-   union i2c_smbus_data data;
-
-   if (!i2c_smbus_xfer(client-adapter, client-addr, client-flags,
-   I2C_SMBUS_READ, command,
-   I2C_SMBUS_BYTE_DATA, data))
-   return data.byte;
-   if (check)
-   v4l_err(client, error reading %02x, %02x\n,
-   client-addr, command);
-   return -EIO;
-}
-
-static s32 adv_smbus_read_byte_data(struct adv76xx_state *state,
-   enum adv76xx_page page, u8 command)
+static int adv76xx_read_check(struct adv76xx_state *state,
+int client_page, u8 reg)
 {
-   return adv_smbus_read_byte_data_check(state-i2c_clients[page],
- command, true);
-}
-
-static s32 adv_smbus_write_byte_data(struct adv76xx_state *state,
-enum adv76xx_page page, u8 command,
-u8 value)
-{
-   struct i2c_client *client = state-i2c_clients[page];
-   union i2c_smbus_data data;
+   struct i2c_client *client = state-i2c_clients[client_page];
int err;
-   int i;
+   unsigned int val;
 
-   data.byte = value;
-   for (i = 0; i  3; i++) {
-   err = i2c_smbus_xfer(client-adapter, client-addr,
-   client-flags,
-   I2C_SMBUS_WRITE, command,
-   I2C_SMBUS_BYTE_DATA, data);
-   if (!err)
-   break;
+   err = regmap_read(state-regmap[client_page], reg, val);
+
+   if (err) {
+   v4l_err(client, error reading %02x, %02x\n,
+   client-addr, reg);
+   return err;
}
-   if (err  0)
-   v4l_err(client, error writing %02x, %02x, %02x\n,
-   client-addr, command, value);
-   return err;
+   return val;
 }
 
-static s32 adv_smbus_write_i2c_block_data(struct adv76xx_state *state,
- enum adv76xx_page page, u8 command,
- unsigned length, const u8 *values)
+/* adv76xx_write_block(): Write raw data with a maximum of I2C_SMBUS_BLOCK_MAX
+ * size to one or more registers.
+ *
+ * A value of zero will be returned on success, a negative errno will
+ * be returned in error cases.
+ */
+static int adv76xx_write_block(struct adv76xx_state *state, int client_page,
+ unsigned int init_reg, const void *val,
+ size_t val_len)
 {
-   struct i2c_client *client = state-i2c_clients[page];
-   union i2c_smbus_data data;
+   struct regmap *regmap = state-regmap[client_page];
+
+   if (val_len  I2C_SMBUS_BLOCK_MAX)
+   val_len = I2C_SMBUS_BLOCK_MAX;
 
-   if (length  I2C_SMBUS_BLOCK_MAX)
-   length = I2C_SMBUS_BLOCK_MAX;
-   data.block[0] = length;
-   memcpy(data.block + 1, values, length);
-   return i2c_smbus_xfer(client-adapter, client-addr, client-flags,
- I2C_SMBUS_WRITE, command,
- I2C_SMBUS_I2C_BLOCK_DATA, data);
+   return regmap_raw_write(regmap, init_reg, val, val_len);
 }
 
 /* --- */
@@ -414,14 +391,14 

Re: [PATCH] staging: media: lirc: fix coding style error

2015-06-19 Thread Sudip Mukherjee
On Fri, Jun 19, 2015 at 02:22:02PM +0530, Sunil Shahu wrote:
 Fix code indentation error by replacing tab in place of spaces.
 
 Signed-off-by: Sunil Shahu shsh...@gmail.com
when you are sending a modified patch, please mark it as [PATCH v2]
otherwise it becomes confusing.

regards
sudip
--
To unsubscribe from this list: send the line unsubscribe linux-media in


[PATCH] v4l: vsp1: Fix plane stride and size checks

2015-06-19 Thread Laurent Pinchart
The checks need to be performed on up to two planes, as the third plane,
if present, must have the same stride and size as the second plane.

The code incorrectly performs the checks on at least two planes instead
of at most two planes, fix it.

Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com
---
 drivers/media/platform/vsp1/vsp1_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index c1b5a09b8331..60aa99faaa7f 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -245,7 +245,7 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
 * the datasheet, strides not aligned to a multiple of 128 bytes result
 * in image corruption.
 */
-   for (i = 0; i  max(info-planes, 2U); ++i) {
+   for (i = 0; i  min(info-planes, 2U); ++i) {
unsigned int hsub = i  0 ? info-hsub : 1;
unsigned int vsub = i  0 ? info-vsub : 1;
unsigned int align = 128;
-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [URGENT FOR v4.1] [PATCH v2] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Hans Verkuil
On 06/19/2015 02:02 PM, Laurent Pinchart wrote:
 Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
 vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
 using a zero value for v4l2_buffer.bytesused.
 
 However, the condition is checked incorrectly, as the v4L2_buffer
 bytesused field is supposed to be ignored for multiplanar buffers. This
 results in spurious warnings when using the multiplanar API.
 
 Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
 v4l2_plane.bytesused for multiplanar buffers.
 
 Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the 
 vb2_queue struct)
 Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com

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

Thanks!

Hans

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 33 
 ++--
  1 file changed, 23 insertions(+), 10 deletions(-)
 
 Changes since v1:
 
 - Rename __check_once to check_once
 - Drop __read_mostly on check_once
 - Use pr_warn instead of pr_warn_once
 
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index d835814a24d4..4eaf2f4f0294 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
  }
  EXPORT_SYMBOL_GPL(vb2_discard_done);
  
 +static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
 +{
 + static bool check_once;
 +
 + if (check_once)
 + return;
 +
 + check_once = true;
 + __WARN();
 +
 + pr_warn(use of bytesused == 0 is deprecated and will be removed in the 
 future,\n);
 + if (vb-vb2_queue-allow_zero_bytesused)
 + pr_warn(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
 + else
 + pr_warn(use the actual size instead.\n);
 +}
 +
  /**
   * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
   * v4l2_buffer by the userspace. The caller has already verified that struct
 @@ -1252,16 +1269,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  {
   unsigned int plane;
  
 - if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 - if (WARN_ON_ONCE(b-bytesused == 0)) {
 - pr_warn_once(use of bytesused == 0 is deprecated and 
 will be removed in the future,\n);
 - if (vb-vb2_queue-allow_zero_bytesused)
 - pr_warn_once(use 
 VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
 - else
 - pr_warn_once(use the actual size instead.\n);
 - }
 - }
 -
   if (V4L2_TYPE_IS_MULTIPLANAR(b-type)) {
   if (b-memory == V4L2_MEMORY_USERPTR) {
   for (plane = 0; plane  vb-num_planes; ++plane) {
 @@ -1302,6 +1309,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
   struct v4l2_plane *pdst = v4l2_planes[plane];
   struct v4l2_plane *psrc = b-m.planes[plane];
  
 + if (psrc-bytesused == 0)
 + vb2_warn_zero_bytesused(vb);
 +
   if (vb-vb2_queue-allow_zero_bytesused)
   pdst-bytesused = psrc-bytesused;
   else
 @@ -1336,6 +1346,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
   }
  
   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 + if (b-bytesused == 0)
 + vb2_warn_zero_bytesused(vb);
 +
   if (vb-vb2_queue-allow_zero_bytesused)
   v4l2_planes[0].bytesused = b-bytesused;
   else
 

--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [URGENT FOR v4.1] [PATCH v2] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Marek Szyprowski

Hello,

On 2015-06-19 14:02, Laurent Pinchart wrote:

Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
using a zero value for v4l2_buffer.bytesused.

However, the condition is checked incorrectly, as the v4L2_buffer
bytesused field is supposed to be ignored for multiplanar buffers. This
results in spurious warnings when using the multiplanar API.

Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
v4l2_plane.bytesused for multiplanar buffers.

Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the vb2_queue 
struct)
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com


Acked-by: Marek Szyprowski m.szyprow...@samsung.com


---
  drivers/media/v4l2-core/videobuf2-core.c | 33 ++--
  1 file changed, 23 insertions(+), 10 deletions(-)

Changes since v1:

- Rename __check_once to check_once
- Drop __read_mostly on check_once
- Use pr_warn instead of pr_warn_once

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index d835814a24d4..4eaf2f4f0294 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
  }
  EXPORT_SYMBOL_GPL(vb2_discard_done);
  
+static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)

+{
+   static bool check_once;
+
+   if (check_once)
+   return;
+
+   check_once = true;
+   __WARN();
+
+   pr_warn(use of bytesused == 0 is deprecated and will be removed in the 
future,\n);
+   if (vb-vb2_queue-allow_zero_bytesused)
+   pr_warn(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
+   else
+   pr_warn(use the actual size instead.\n);
+}
+
  /**
   * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
   * v4l2_buffer by the userspace. The caller has already verified that struct
@@ -1252,16 +1269,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
  {
unsigned int plane;
  
-	if (V4L2_TYPE_IS_OUTPUT(b-type)) {

-   if (WARN_ON_ONCE(b-bytesused == 0)) {
-   pr_warn_once(use of bytesused == 0 is deprecated and will 
be removed in the future,\n);
-   if (vb-vb2_queue-allow_zero_bytesused)
-   pr_warn_once(use 
VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
-   else
-   pr_warn_once(use the actual size instead.\n);
-   }
-   }
-
if (V4L2_TYPE_IS_MULTIPLANAR(b-type)) {
if (b-memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane  vb-num_planes; ++plane) {
@@ -1302,6 +1309,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
struct v4l2_plane *pdst = v4l2_planes[plane];
struct v4l2_plane *psrc = b-m.planes[plane];
  
+if (psrc-bytesused == 0)

+   vb2_warn_zero_bytesused(vb);
+
if (vb-vb2_queue-allow_zero_bytesused)
pdst-bytesused = psrc-bytesused;
else
@@ -1336,6 +1346,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
}
  
  		if (V4L2_TYPE_IS_OUTPUT(b-type)) {

+   if (b-bytesused == 0)
+   vb2_warn_zero_bytesused(vb);
+
if (vb-vb2_queue-allow_zero_bytesused)
v4l2_planes[0].bytesused = b-bytesused;
else


Best regards
--
Marek Szyprowski, PhD
Samsung RD Institute Poland

--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [URGENT FOR v4.1] [PATCH v2] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Kamil Debski
Hi Laurent,

First - thank you so much for the patch. I had a look into the code
and it looks good. You have my Ack.

Thank and best wishes,
Kamil Debski

On 19 June 2015 at 13:04, Hans Verkuil hverk...@xs4all.nl wrote:
 On 06/19/2015 02:02 PM, Laurent Pinchart wrote:
 Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
 vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
 using a zero value for v4l2_buffer.bytesused.

 However, the condition is checked incorrectly, as the v4L2_buffer
 bytesused field is supposed to be ignored for multiplanar buffers. This
 results in spurious warnings when using the multiplanar API.

 Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
 v4l2_plane.bytesused for multiplanar buffers.

 Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the 
 vb2_queue struct)
 Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com

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

Acked-by: Kamil Debski ka...@wypas.org


 Thanks!

 Hans

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 33 
 ++--
  1 file changed, 23 insertions(+), 10 deletions(-)

 Changes since v1:

 - Rename __check_once to check_once
 - Drop __read_mostly on check_once
 - Use pr_warn instead of pr_warn_once

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index d835814a24d4..4eaf2f4f0294 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
  }
  EXPORT_SYMBOL_GPL(vb2_discard_done);

 +static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
 +{
 + static bool check_once;
 +
 + if (check_once)
 + return;
 +
 + check_once = true;
 + __WARN();
 +
 + pr_warn(use of bytesused == 0 is deprecated and will be removed in 
 the future,\n);
 + if (vb-vb2_queue-allow_zero_bytesused)
 + pr_warn(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) 
 instead.\n);
 + else
 + pr_warn(use the actual size instead.\n);
 +}
 +
  /**
   * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
   * v4l2_buffer by the userspace. The caller has already verified that struct
 @@ -1252,16 +1269,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  {
   unsigned int plane;

 - if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 - if (WARN_ON_ONCE(b-bytesused == 0)) {
 - pr_warn_once(use of bytesused == 0 is deprecated and 
 will be removed in the future,\n);
 - if (vb-vb2_queue-allow_zero_bytesused)
 - pr_warn_once(use 
 VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
 - else
 - pr_warn_once(use the actual size instead.\n);
 - }
 - }
 -
   if (V4L2_TYPE_IS_MULTIPLANAR(b-type)) {
   if (b-memory == V4L2_MEMORY_USERPTR) {
   for (plane = 0; plane  vb-num_planes; ++plane) {
 @@ -1302,6 +1309,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
   struct v4l2_plane *pdst = v4l2_planes[plane];
   struct v4l2_plane *psrc = b-m.planes[plane];

 + if (psrc-bytesused == 0)
 + vb2_warn_zero_bytesused(vb);
 +
   if (vb-vb2_queue-allow_zero_bytesused)
   pdst-bytesused = psrc-bytesused;
   else
 @@ -1336,6 +1346,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
   }

   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 + if (b-bytesused == 0)
 + vb2_warn_zero_bytesused(vb);
 +
   if (vb-vb2_queue-allow_zero_bytesused)
   v4l2_planes[0].bytesused = b-bytesused;
   else


--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [PATCH v2] media: i2c: ADV7604: Migrate to regmap

2015-06-19 Thread Hans Verkuil
On 06/16/2015 10:38 AM, Pablo Anton wrote:
 This is a preliminary patch in order to add support for ALSA.
 It replaces all current i2c access with regmap.
 
 Signed-off-by: Pablo Anton pablo.an...@veo-labs.com
 Signed-off-by: Jean-Michel Hautbois jean-michel.hautb...@veo-labs.com

After fixing the missing return value check that Lars-Peter found you can
add my:

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

Regards,

Hans

 ---
 v2: Rebase after renaming
 
  drivers/media/i2c/adv7604.c | 337 
 
  1 file changed, 244 insertions(+), 93 deletions(-)
 
 diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
 index 60ffcf0..38ae454 100644
 --- a/drivers/media/i2c/adv7604.c
 +++ b/drivers/media/i2c/adv7604.c
 @@ -36,6 +36,7 @@
  #include linux/v4l2-dv-timings.h
  #include linux/videodev2.h
  #include linux/workqueue.h
 +#include linux/regmap.h
  
  #include media/adv7604.h
  #include media/v4l2-ctrls.h
 @@ -166,6 +167,9 @@ struct adv76xx_state {
   /* i2c clients */
   struct i2c_client *i2c_clients[ADV76XX_PAGE_MAX];
  
 + /* Regmaps */
 + struct regmap *regmap[ADV76XX_PAGE_MAX];
 +
   /* controls */
   struct v4l2_ctrl *detect_tx_5v_ctrl;
   struct v4l2_ctrl *analog_sampling_phase_ctrl;
 @@ -346,66 +350,39 @@ static inline unsigned vtotal(const struct 
 v4l2_bt_timings *t)
  
  /* --- */
  
 -static s32 adv_smbus_read_byte_data_check(struct i2c_client *client,
 - u8 command, bool check)
 -{
 - union i2c_smbus_data data;
 -
 - if (!i2c_smbus_xfer(client-adapter, client-addr, client-flags,
 - I2C_SMBUS_READ, command,
 - I2C_SMBUS_BYTE_DATA, data))
 - return data.byte;
 - if (check)
 - v4l_err(client, error reading %02x, %02x\n,
 - client-addr, command);
 - return -EIO;
 -}
 -
 -static s32 adv_smbus_read_byte_data(struct adv76xx_state *state,
 - enum adv76xx_page page, u8 command)
 +static int adv76xx_read_check(struct adv76xx_state *state,
 +  int client_page, u8 reg)
  {
 - return adv_smbus_read_byte_data_check(state-i2c_clients[page],
 -   command, true);
 -}
 -
 -static s32 adv_smbus_write_byte_data(struct adv76xx_state *state,
 -  enum adv76xx_page page, u8 command,
 -  u8 value)
 -{
 - struct i2c_client *client = state-i2c_clients[page];
 - union i2c_smbus_data data;
 + struct i2c_client *client = state-i2c_clients[client_page];
   int err;
 - int i;
 + unsigned int val;
  
 - data.byte = value;
 - for (i = 0; i  3; i++) {
 - err = i2c_smbus_xfer(client-adapter, client-addr,
 - client-flags,
 - I2C_SMBUS_WRITE, command,
 - I2C_SMBUS_BYTE_DATA, data);
 - if (!err)
 - break;
 + err = regmap_read(state-regmap[client_page], reg, val);
 +
 + if (err) {
 + v4l_err(client, error reading %02x, %02x\n,
 + client-addr, reg);
 + return err;
   }
 - if (err  0)
 - v4l_err(client, error writing %02x, %02x, %02x\n,
 - client-addr, command, value);
 - return err;
 + return val;
  }
  
 -static s32 adv_smbus_write_i2c_block_data(struct adv76xx_state *state,
 -   enum adv76xx_page page, u8 command,
 -   unsigned length, const u8 *values)
 +/* adv76xx_write_block(): Write raw data with a maximum of 
 I2C_SMBUS_BLOCK_MAX
 + * size to one or more registers.
 + *
 + * A value of zero will be returned on success, a negative errno will
 + * be returned in error cases.
 + */
 +static int adv76xx_write_block(struct adv76xx_state *state, int client_page,
 +   unsigned int init_reg, const void *val,
 +   size_t val_len)
  {
 - struct i2c_client *client = state-i2c_clients[page];
 - union i2c_smbus_data data;
 + struct regmap *regmap = state-regmap[client_page];
 +
 + if (val_len  I2C_SMBUS_BLOCK_MAX)
 + val_len = I2C_SMBUS_BLOCK_MAX;
  
 - if (length  I2C_SMBUS_BLOCK_MAX)
 - length = I2C_SMBUS_BLOCK_MAX;
 - data.block[0] = length;
 - memcpy(data.block + 1, values, length);
 - return i2c_smbus_xfer(client-adapter, client-addr, client-flags,
 -   I2C_SMBUS_WRITE, command,
 -   I2C_SMBUS_I2C_BLOCK_DATA, data);
 + return regmap_raw_write(regmap, init_reg, val, val_len);
  }
  
  /* --- */
 

Re: [URGENT] [PATCH] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Hans Verkuil
On 06/19/2015 01:50 PM, Laurent Pinchart wrote:
 Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
 vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
 using a zero value for v4l2_buffer.bytesused.
 
 However, the condition is checked incorrectly, as the v4L2_buffer
 bytesused field is supposed to be ignored for multiplanar buffers. This
 results in spurious warnings when using the multiplanar API.
 
 Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
 v4l2_plane.bytesused for multiplanar buffers.
 
 Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the 
 vb2_queue struct)
 Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com
 ---
  drivers/media/v4l2-core/videobuf2-core.c | 33 
 ++--
  1 file changed, 23 insertions(+), 10 deletions(-)
 
 The bug was introduced in v4.1-rc1. It would be quite bad if it made it to
 v4.1 as many users will start complaining.
 
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index d835814a24d4..93b315459098 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
  }
  EXPORT_SYMBOL_GPL(vb2_discard_done);
  
 +static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
 +{
 + static bool __check_once __read_mostly;

Why the underscores? Why the __read_mostly?

Just say: 'static bool check_once;'

Much more readable, and there really is no benefit whatsoever for adding
a __read_mostly attribute here.

 +
 + if (__check_once)
 + return;
 +
 + __check_once = true;
 + __WARN();
 +
 + pr_warn_once(use of bytesused == 0 is deprecated and will be removed 
 in the future,\n);

This can be pr_warn now. pr_warn_once will implicitly only do another 
'check_once' check
with its own 'check_once' variable.

 + if (vb-vb2_queue-allow_zero_bytesused)
 + pr_warn_once(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) 
 instead.\n);
 + else
 + pr_warn_once(use the actual size instead.\n);
 +}

Regards,

Hans

 +
  /**
   * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
   * v4l2_buffer by the userspace. The caller has already verified that struct
 @@ -1252,16 +1269,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  {
   unsigned int plane;
  
 - if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 - if (WARN_ON_ONCE(b-bytesused == 0)) {
 - pr_warn_once(use of bytesused == 0 is deprecated and 
 will be removed in the future,\n);
 - if (vb-vb2_queue-allow_zero_bytesused)
 - pr_warn_once(use 
 VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
 - else
 - pr_warn_once(use the actual size instead.\n);
 - }
 - }
 -
   if (V4L2_TYPE_IS_MULTIPLANAR(b-type)) {
   if (b-memory == V4L2_MEMORY_USERPTR) {
   for (plane = 0; plane  vb-num_planes; ++plane) {
 @@ -1302,6 +1309,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
   struct v4l2_plane *pdst = v4l2_planes[plane];
   struct v4l2_plane *psrc = b-m.planes[plane];
  
 + if (psrc-bytesused == 0)
 + vb2_warn_zero_bytesused(vb);
 +
   if (vb-vb2_queue-allow_zero_bytesused)
   pdst-bytesused = psrc-bytesused;
   else
 @@ -1336,6 +1346,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
   }
  
   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 + if (b-bytesused == 0)
 + vb2_warn_zero_bytesused(vb);
 +
   if (vb-vb2_queue-allow_zero_bytesused)
   v4l2_planes[0].bytesused = b-bytesused;
   else
 

--
To unsubscribe from this list: send the line unsubscribe linux-media in


[PATCH] staging: media: lirc: fix coding style error

2015-06-19 Thread Sunil Shahu
Fix code indentation error by replacing tab in place of spaces.

Signed-off-by: Sunil Shahu shsh...@gmail.com
---
 drivers/staging/media/lirc/lirc_sasem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/lirc/lirc_sasem.c 
b/drivers/staging/media/lirc/lirc_sasem.c
index 8ebee96..c14ca7e 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -185,7 +185,7 @@ static void deregister_from_lirc(struct sasem_context 
*context)
   __func__, retval);
else
dev_info(context-dev-dev,
-Deregistered Sasem driver (minor:%d)\n, minor);
+Deregistered Sasem driver (minor:%d)\n, minor);
 
 }
 
-- 
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


[URGENT FOR v4.1] [PATCH v2] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Laurent Pinchart
Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
using a zero value for v4l2_buffer.bytesused.

However, the condition is checked incorrectly, as the v4L2_buffer
bytesused field is supposed to be ignored for multiplanar buffers. This
results in spurious warnings when using the multiplanar API.

Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
v4l2_plane.bytesused for multiplanar buffers.

Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the 
vb2_queue struct)
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 33 ++--
 1 file changed, 23 insertions(+), 10 deletions(-)

Changes since v1:

- Rename __check_once to check_once
- Drop __read_mostly on check_once
- Use pr_warn instead of pr_warn_once

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index d835814a24d4..4eaf2f4f0294 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(vb2_discard_done);
 
+static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
+{
+   static bool check_once;
+
+   if (check_once)
+   return;
+
+   check_once = true;
+   __WARN();
+
+   pr_warn(use of bytesused == 0 is deprecated and will be removed in the 
future,\n);
+   if (vb-vb2_queue-allow_zero_bytesused)
+   pr_warn(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
+   else
+   pr_warn(use the actual size instead.\n);
+}
+
 /**
  * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
  * v4l2_buffer by the userspace. The caller has already verified that struct
@@ -1252,16 +1269,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 {
unsigned int plane;
 
-   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
-   if (WARN_ON_ONCE(b-bytesused == 0)) {
-   pr_warn_once(use of bytesused == 0 is deprecated and 
will be removed in the future,\n);
-   if (vb-vb2_queue-allow_zero_bytesused)
-   pr_warn_once(use 
VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
-   else
-   pr_warn_once(use the actual size instead.\n);
-   }
-   }
-
if (V4L2_TYPE_IS_MULTIPLANAR(b-type)) {
if (b-memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane  vb-num_planes; ++plane) {
@@ -1302,6 +1309,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
struct v4l2_plane *pdst = v4l2_planes[plane];
struct v4l2_plane *psrc = b-m.planes[plane];
 
+   if (psrc-bytesused == 0)
+   vb2_warn_zero_bytesused(vb);
+
if (vb-vb2_queue-allow_zero_bytesused)
pdst-bytesused = psrc-bytesused;
else
@@ -1336,6 +1346,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
}
 
if (V4L2_TYPE_IS_OUTPUT(b-type)) {
+   if (b-bytesused == 0)
+   vb2_warn_zero_bytesused(vb);
+
if (vb-vb2_queue-allow_zero_bytesused)
v4l2_planes[0].bytesused = b-bytesused;
else
-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [PATCH] Revert [media] vb2: Push mmap_sem down to memops

2015-06-19 Thread Hans Verkuil
On 06/18/2015 12:33 PM, Jan Kara wrote:
 On Mon 15-06-15 09:24:55, Hans Verkuil wrote:
 This reverts commit 48b25a3a713b90988b6882d318f7c0a6bed9aabc.

 That commit caused two regressions. The first is a BUG:

 BUG: unable to handle kernel NULL pointer dereference at 0100
 IP: [810d5cd0] __lock_acquire+0x2f0/0x2070
 PGD 0
 Oops:  [#1] PREEMPT SMP
 Modules linked in: vivid v4l2_dv_timings videobuf2_vmalloc videobuf2_memops 
 videobuf2_core v4l2_common videodev media vmw_balloon vmw_vmci acpi_cpufreq 
 processor button
 CPU: 0 PID: 1542 Comm: v4l2-ctl Not tainted 4.1.0-rc3-test-media #1190
 Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference 
 Platform, BIOS 6.00 05/20/2014
 task: 880220ce4200 ti: 88021d16c000 task.ti: 88021d16c000
 RIP: 0010:[810d5cd0]  [810d5cd0] 
 __lock_acquire+0x2f0/0x2070
 RSP: 0018:88021d16f9b8  EFLAGS: 00010002
 RAX: 0046 RBX: 0292 RCX: 0001
 RDX:  RSI: 0001 RDI: 0100
 RBP: 88021d16fa88 R08: 0001 R09: 
 R10: 0001 R11:  R12: 0001
 R13: 880220ce4200 R14: 0100 R15: 
 FS:  7f2441e7f740() GS:880236e0() knlGS:
 CS:  0010 DS:  ES:  CR0: 8005003b
 CR2: 0100 CR3: 01e0b000 CR4: 001406f0
 Stack:
  88021d16fa98 810d6543 0006 0246
  88021d16fa08 810d532d 880220ce4a78 8802
  88020001  0001 0093a4a0
 Call Trace:
  [810d6543] ? __lock_acquire+0xb63/0x2070
  [810d532d] ? mark_held_locks+0x6d/0xa0
  [810d37a8] ? __lock_is_held+0x58/0x80
  [810d852c] lock_acquire+0x6c/0xa0
  [a039f1f6] ? vb2_vmalloc_put_userptr+0x36/0x110 
 [videobuf2_vmalloc]
  [819b1a92] down_read+0x42/0x60
  [a039f1f6] ? vb2_vmalloc_put_userptr+0x36/0x110 
 [videobuf2_vmalloc]
  [819af1b1] ? mutex_lock_nested+0x2b1/0x560
  [a038fdc5] ? vb2_queue_release+0x25/0x40 [videobuf2_core]
  [a039f1f6] vb2_vmalloc_put_userptr+0x36/0x110 [videobuf2_vmalloc]
  [a038b626] __vb2_queue_free+0x146/0x5e0 [videobuf2_core]
  [a038fdd3] vb2_queue_release+0x33/0x40 [videobuf2_core]
  [a038fe75] _vb2_fop_release+0x95/0xb0 [videobuf2_core]
  [a038feb9] vb2_fop_release+0x29/0x50 [videobuf2_core]
  [a03ad372] vivid_fop_release+0x92/0x230 [vivid]
  [a0358460] v4l2_release+0x30/0x80 [videodev]
  [811a51d5] __fput+0xe5/0x200
  [811a5339] fput+0x9/0x10
  [810a9fa4] task_work_run+0xc4/0xf0
  [8108c670] do_exit+0x3a0/0xaf0
  [819b3a9b] ? _raw_spin_unlock_irq+0x2b/0x60
  [8108e0ff] do_group_exit+0x4f/0xe0
  [8109a170] get_signal+0x200/0x8c0
  [819b14b5] ? __mutex_unlock_slowpath+0xf5/0x240
  [81002593] do_signal+0x23/0x820
  [819b1609] ? mutex_unlock+0x9/0x10
  [a0358648] ? v4l2_ioctl+0x78/0xf0 [videodev]
  [819b4653] ? int_very_careful+0x5/0x46
  [810d54bd] ? trace_hardirqs_on_caller+0x15d/0x200
  [81002de0] do_notify_resume+0x50/0x60
  [819b46a6] int_signal+0x12/0x17
 Code: ca 81 31 c0 e8 7a e2 8c 00 e8 aa 1d 8d 00 0f 1f 44 00 00 31 db 48 81 
 c4 a8 00 00 00 89 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 66 90 49 81 3e 40 4e 
 02 82 b8 00 00 00 00 44 0f 44 e0 41 83 ff 01 0f
 RIP  [810d5cd0] __lock_acquire+0x2f0/0x2070
  RSP 88021d16f9b8
 CR2: 0100
 ---[ end trace 25595c2b8560cb57 ]---
 Fixing recursive fault but reboot is needed!
 
 Ah, that's tricky. We can end up calling task_work_run() via
 exit_task_work() after mm has been shut down. And the task work will be
 dropping the last reference to all file descriptors which ends up shutting
 down vb2 after current-mm has been cleaned up.
 
 So in the light of this it's probably better for the initial patch to
 completely avoid grabbing mmap_sem in put_userptr(). It breaks locking for
 vma-vm_ops-close() but that's already broken in vb2 as I explained in my
 other email. And the remainder of the patch set will make sure we don't
 need mmap_sem in put_userptr() at all and thus fixes the whole issue.
 
 This also explains why I never saw the problem in my testing - I was always
 testing the patch set as a whole.
 
 I'll send an updated first patch later today.

I just wanted to thank you for your quick work in resolving both regressions and
making a new patch series. Much appreciated! I was afraid this would prove to be
complex to fix, so I'm glad that I was wrong about that.

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-media in


[URGENT] [PATCH] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Laurent Pinchart
Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
using a zero value for v4l2_buffer.bytesused.

However, the condition is checked incorrectly, as the v4L2_buffer
bytesused field is supposed to be ignored for multiplanar buffers. This
results in spurious warnings when using the multiplanar API.

Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
v4l2_plane.bytesused for multiplanar buffers.

Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the 
vb2_queue struct)
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 33 ++--
 1 file changed, 23 insertions(+), 10 deletions(-)

The bug was introduced in v4.1-rc1. It would be quite bad if it made it to
v4.1 as many users will start complaining.

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index d835814a24d4..93b315459098 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(vb2_discard_done);
 
+static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
+{
+   static bool __check_once __read_mostly;
+
+   if (__check_once)
+   return;
+
+   __check_once = true;
+   __WARN();
+
+   pr_warn_once(use of bytesused == 0 is deprecated and will be removed 
in the future,\n);
+   if (vb-vb2_queue-allow_zero_bytesused)
+   pr_warn_once(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) 
instead.\n);
+   else
+   pr_warn_once(use the actual size instead.\n);
+}
+
 /**
  * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a
  * v4l2_buffer by the userspace. The caller has already verified that struct
@@ -1252,16 +1269,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
 {
unsigned int plane;
 
-   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
-   if (WARN_ON_ONCE(b-bytesused == 0)) {
-   pr_warn_once(use of bytesused == 0 is deprecated and 
will be removed in the future,\n);
-   if (vb-vb2_queue-allow_zero_bytesused)
-   pr_warn_once(use 
VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n);
-   else
-   pr_warn_once(use the actual size instead.\n);
-   }
-   }
-
if (V4L2_TYPE_IS_MULTIPLANAR(b-type)) {
if (b-memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane  vb-num_planes; ++plane) {
@@ -1302,6 +1309,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
struct v4l2_plane *pdst = v4l2_planes[plane];
struct v4l2_plane *psrc = b-m.planes[plane];
 
+   if (psrc-bytesused == 0)
+   vb2_warn_zero_bytesused(vb);
+
if (vb-vb2_queue-allow_zero_bytesused)
pdst-bytesused = psrc-bytesused;
else
@@ -1336,6 +1346,9 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
const struct v4l2_buffer *b
}
 
if (V4L2_TYPE_IS_OUTPUT(b-type)) {
+   if (b-bytesused == 0)
+   vb2_warn_zero_bytesused(vb);
+
if (vb-vb2_queue-allow_zero_bytesused)
v4l2_planes[0].bytesused = b-bytesused;
else
-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [URGENT] [PATCH] vb2: Don't WARN when v4l2_buffer.bytesused is 0 for multiplanar buffers

2015-06-19 Thread Laurent Pinchart
Hi Hans,

On Friday 19 June 2015 13:56:23 Hans Verkuil wrote:
 On 06/19/2015 01:50 PM, Laurent Pinchart wrote:
  Commit f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
  vb2_queue struct) added a WARN_ONCE to catch usage of a deprecated API
  using a zero value for v4l2_buffer.bytesused.
  
  However, the condition is checked incorrectly, as the v4L2_buffer
  bytesused field is supposed to be ignored for multiplanar buffers. This
  results in spurious warnings when using the multiplanar API.
  
  Fix it by checking v4l2_buffer.bytesused for uniplanar buffers and
  v4l2_plane.bytesused for multiplanar buffers.
  
  Fixes: f61bf13b6a07 ([media] vb2: add allow_zero_bytesused flag to the
  vb2_queue struct) Signed-off-by: Laurent Pinchart
  laurent.pinchart+rene...@ideasonboard.com
  --- 
   drivers/media/v4l2-core/videobuf2-core.c | 33 +--
   1 file changed, 23 insertions(+), 10 deletions(-)
  
  The bug was introduced in v4.1-rc1. It would be quite bad if it made it to
  v4.1 as many users will start complaining.
  
  diff --git a/drivers/media/v4l2-core/videobuf2-core.c
  b/drivers/media/v4l2-core/videobuf2-core.c index
  d835814a24d4..93b315459098 100644
  --- a/drivers/media/v4l2-core/videobuf2-core.c
  +++ b/drivers/media/v4l2-core/videobuf2-core.c
  @@ -1242,6 +1242,23 @@ void vb2_discard_done(struct vb2_queue *q)
  
   }
   EXPORT_SYMBOL_GPL(vb2_discard_done);
  
  +static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
  +{
  +   static bool __check_once __read_mostly;
 
 Why the underscores? Why the __read_mostly?

Copied from WARN_ONCE :-)

 Just say: 'static bool check_once;'
 
 Much more readable, and there really is no benefit whatsoever for adding
 a __read_mostly attribute here.

I'll remove them.

  +
  +   if (__check_once)
  +   return;
  +
  +   __check_once = true;
  +   __WARN();
  +
  +   pr_warn_once(use of bytesused == 0 is deprecated and will be removed 
in
  the future,\n);
 This can be pr_warn now. pr_warn_once will implicitly only do another
 'check_once' check with its own 'check_once' variable.

I had intended to do so but just forgot.

v2 on its way.

  +   if (vb-vb2_queue-allow_zero_bytesused)
  +   pr_warn_once(use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.
\n);
  +   else
  +   pr_warn_once(use the actual size instead.\n);
  +}

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: HDMI and Composite capture on Lager, for kernel 4.1, version 3

2015-06-19 Thread Hans Verkuil
On 06/03/2015 03:59 PM, William Towle wrote:
   Version 3. Obsoletes version 2, as seen at:
   
 http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/91668
 
   Key changes in this version: this has some reworking of the adv7604
 driver probe and soc_camera initialisation functions. In addition,
 we give rcar_vin.c a dependency on CONFIG_MEDIA_CONTROLLER in line with
 the drivers used with it.

I'm not sure if I've asked this before, but shouldn't soc-camera be extended
with support for the DV_TIMINGS ioctls in order to control the adv7604?

It's peculiar that that is not included in this patch series...

Regards,

Hans

 
 Cheers,
   Wills.
 
 To follow:
   [PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI
   [PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
   [PATCH 03/15] media: adv7180: add of match table
   [PATCH 04/15] media: adv7604: chip info and formats for ADV7612
   [PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI
   [PATCH 06/15] media: adv7604: ability to read default input port
   [PATCH 07/15] ARM: shmobile: lager dts: specify default-input for
   [PATCH 08/15] v4l: subdev: Add pad config allocator and init
   [PATCH 09/15] media: soc_camera pad-aware driver initialisation
   [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt
   [PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad
   [PATCH 12/15] media: soc_camera: Fill std field in enum_input
   [PATCH 13/15] media: soc_camera: Fix error reporting in expbuf
   [PATCH 14/15] media: soc_camera: fill in bus_info field
   [PATCH 15/15] media: rcar_vin: Reject videobufs that are too small
 --
 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


Re: [PATCH v9 2/8] media: Add registration helpers for V4L2 flash sub-devices

2015-06-19 Thread Jacek Anaszewski

Hi Alexey,

On 06/18/2015 07:45 PM, Alexey Klimov wrote:

Hi Jacek,

On Mon, May 25, 2015 at 6:13 PM, Jacek Anaszewski
j.anaszew...@samsung.com wrote:

This patch adds helper functions for registering/unregistering
LED Flash class devices as V4L2 sub-devices. The functions should
be called from the LED subsystem device driver. In case the
support for V4L2 Flash sub-devices is disabled in the kernel
config the functions' empty versions will be used.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Sakari Ailus sakari.ai...@iki.fi
Cc: Hans Verkuil hans.verk...@cisco.com
---
  drivers/media/v4l2-core/Kconfig|   11 +
  drivers/media/v4l2-core/Makefile   |2 +
  drivers/media/v4l2-core/v4l2-flash-led-class.c |  671 
  include/media/v4l2-flash-led-class.h   |  148 ++
  4 files changed, 832 insertions(+)
  create mode 100644 drivers/media/v4l2-core/v4l2-flash-led-class.c
  create mode 100644 include/media/v4l2-flash-led-class.h

[...]

+struct v4l2_flash *v4l2_flash_init(
+   struct device *dev, struct device_node *of_node,
+   struct led_classdev_flash *fled_cdev,
+   struct led_classdev_flash *iled_cdev,
+   const struct v4l2_flash_ops *ops,
+   struct v4l2_flash_config *config)
+{
+   struct v4l2_flash *v4l2_flash;



+   struct led_classdev *led_cdev = fled_cdev-led_cdev;
+   struct v4l2_subdev *sd;
+   int ret;
+
+   if (!fled_cdev || !ops || !config)
+   return ERR_PTR(-EINVAL);


Could you please if it is correct? You're checking fled_cdev but four
lines above you're using fled_cdev and taking led_cdev pointer from
there. Maybe it's better to move calculation of led_cdev down and
place after if-check?


Thanks for spotting this. I'll submit fixed version soon.

--
Best Regards,
Jacek Anaszewski
--
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: [RFC PATCH 2/2] v4l2-utils: extend set-dv-timing options for RB version

2015-06-19 Thread Hans Verkuil
On 06/16/2015 11:30 AM, Prashant Laddha wrote:
 To support the timings calculations for reduced blanking version 2
 (RB v2), extended the command line options to include flag indicating
 whether to use RB V2 or not. Updated the command usage for the same.
 
 Cc: Hans Verkuil hans.verk...@cisco.com
 Signed-off-by: Prashant Laddha prlad...@cisco.com
 ---
  utils/v4l2-ctl/v4l2-ctl-stds.cpp | 13 +++--
  1 file changed, 11 insertions(+), 2 deletions(-)
 
 diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp 
 b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
 index c0e919b..9734c80 100644
 --- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
 +++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
 @@ -41,7 +41,10 @@ void stds_usage(void)
   index=index: use the index as provided 
 by --list-dv-timings\n
   or specify timings using cvt/gtf options 
 as follows:\n
   
 cvt/gtf,width=width,height=height,fps=frames per sec\n
 - interlaced=0/1,reduced-blanking=0/1\n
 + 
 interlaced=0/1,reduced-blanking=0/1,use-rb-v2=0/1\n
 + use-rb-v2 indicates whether to use reduced 
 blanking version 2\n
 + or not. This flag is relevant only for cvt 
 timings and has\n
 + effect only if reduced-blanking=1\n

Why not just allow a value of 2 for the reduced-blanking argument instead
of introducing a new argument? For gtf 1 and 2 mean the same thing, for cvt 1
will use the standard RB and 2 RBv2.

Seems simpler to me. It also means that calc_cvt_modeline doesn't need a new
argument, just that bool reduced_blanking becomes int reduced_blanking.

Other than this it looks good to me.

Regards,

Hans

   or give a fully specified timings:\n
   
 width=width,height=height,interlaced=0/1,\n
   polarities=polarities 
 mask,pixelclock=pixelclock Hz,\n
 @@ -148,6 +151,7 @@ enum timing_opts {
   GTF,
   FPS,
   REDUCED_BLANK,
 + USE_RB_V2,
  };
  
  static int parse_timing_subopt(char **subopt_str, int *value)
 @@ -175,6 +179,7 @@ static int parse_timing_subopt(char **subopt_str, int 
 *value)
   gtf,
   fps,
   reduced-blanking,
 + use-rb-v2,
   NULL
   };
  
 @@ -205,6 +210,7 @@ static void get_cvt_gtf_timings(char *subopt, int 
 standard,
   int fps = 0;
   int r_blank = 0;
   int interlaced = 0;
 + int use_rb_v2 = 0;
  
   bool timings_valid = false;
  
 @@ -231,6 +237,8 @@ static void get_cvt_gtf_timings(char *subopt, int 
 standard,
   case INTERLACED:
   interlaced = opt_val;
   break;
 + case USE_RB_V2:
 + use_rb_v2 = opt_val;
   default:
   break;
   }
 @@ -240,7 +248,8 @@ static void get_cvt_gtf_timings(char *subopt, int 
 standard,
   timings_valid = calc_cvt_modeline(width, height, fps,
 r_blank == 1 ? true : false,
 interlaced == 1 ? true : false,
 -   false, bt);
 +   use_rb_v2 == 1 ? true : false,
 +   bt);
   } else {
   timings_valid = calc_gtf_modeline(width, height, fps,
 r_blank == 1 ? true : false,
 

--
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 v10.1] media: Add registration helpers for V4L2 flash sub-devices

2015-06-19 Thread Jacek Anaszewski
This patch adds helper functions for registering/unregistering
LED Flash class devices as V4L2 sub-devices. The functions should
be called from the LED subsystem device driver. In case the
support for V4L2 Flash sub-devices is disabled in the kernel
config the functions' empty versions will be used.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Sakari Ailus sakari.ai...@iki.fi
Cc: Hans Verkuil hans.verk...@cisco.com
---
- fixed possible NULL fled_cdev pointer dereference
  in the v4l2_flash_init function

 drivers/media/v4l2-core/Kconfig|   11 +
 drivers/media/v4l2-core/Makefile   |2 +
 drivers/media/v4l2-core/v4l2-flash-led-class.c |  710 
 include/media/v4l2-flash-led-class.h   |  148 +
 4 files changed, 871 insertions(+)
 create mode 100644 drivers/media/v4l2-core/v4l2-flash-led-class.c
 create mode 100644 include/media/v4l2-flash-led-class.h

diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index f7a01a7..b4b0229 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -44,6 +44,17 @@ config V4L2_MEM2MEM_DEV
 tristate
 depends on VIDEOBUF2_CORE
 
+# Used by LED subsystem flash drivers
+config V4L2_FLASH_LED_CLASS
+   tristate V4L2 flash API for LED flash class devices
+   depends on VIDEO_V4L2_SUBDEV_API
+   depends on LEDS_CLASS_FLASH
+   ---help---
+ Say Y here to enable V4L2 flash API support for LED flash
+ class drivers.
+
+ When in doubt, say N.
+
 # Used by drivers that need Videobuf modules
 config VIDEOBUF_GEN
tristate
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index 63d29f2..dc3de00 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_VIDEO_TUNER) += tuner.o
 
 obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
 
+obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash-led-class.o
+
 obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o
 obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o
 obj-$(CONFIG_VIDEOBUF_DMA_CONTIG) += videobuf-dma-contig.o
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c 
b/drivers/media/v4l2-core/v4l2-flash-led-class.c
new file mode 100644
index 000..5bdfb8d
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -0,0 +1,710 @@
+/*
+ * V4L2 flash LED sub-device registration helpers.
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd
+ * Author: Jacek Anaszewski j.anaszew...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/led-class-flash.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/of.h
+#include linux/slab.h
+#include linux/types.h
+#include media/v4l2-flash-led-class.h
+
+#define has_flash_op(v4l2_flash, op)   \
+   (v4l2_flash  v4l2_flash-ops-op)
+
+#define call_flash_op(v4l2_flash, op, arg) \
+   (has_flash_op(v4l2_flash, op) ? \
+   v4l2_flash-ops-op(v4l2_flash, arg) :  \
+   -EINVAL)
+
+enum ctrl_init_data_id {
+   LED_MODE,
+   TORCH_INTENSITY,
+   FLASH_INTENSITY,
+   INDICATOR_INTENSITY,
+   FLASH_TIMEOUT,
+   STROBE_SOURCE,
+   /*
+* Only above values are applicable to
+* the 'ctrls' array in the struct v4l2_flash.
+*/
+   FLASH_STROBE,
+   STROBE_STOP,
+   STROBE_STATUS,
+   FLASH_FAULT,
+   NUM_FLASH_CTRLS,
+};
+
+static enum led_brightness __intensity_to_led_brightness(
+   struct v4l2_ctrl *ctrl, s32 intensity)
+{
+   intensity -= ctrl-minimum;
+   intensity /= (u32) ctrl-step;
+
+   /*
+* Indicator LEDs, unlike torch LEDs, are turned on/off basing on
+* the state of V4L2_CID_FLASH_INDICATOR_INTENSITY control only.
+* Therefore it must be possible to set it to 0 level which in
+* the LED subsystem reflects LED_OFF state.
+*/
+   if (ctrl-minimum)
+   ++intensity;
+
+   return intensity;
+}
+
+static s32 __led_brightness_to_intensity(struct v4l2_ctrl *ctrl,
+enum led_brightness brightness)
+{
+   /*
+* Indicator LEDs, unlike torch LEDs, are turned on/off basing on
+* the state of V4L2_CID_FLASH_INDICATOR_INTENSITY control only.
+* Do not decrement brightness read from the LED subsystem for
+* indicator LED as it may equal 0. For torch LEDs this function
+* is called only when V4L2_FLASH_LED_MODE_TORCH is set and the
+* brightness read is guaranteed to be greater than 0. In the mode
+* 

Re: [PATCH] staging: media: lirc: fix coding style error

2015-06-19 Thread Dan Carpenter
On Wed, Jun 17, 2015 at 06:01:32PM +0530, Sunil Shahu wrote:
 Fix code indentation error by replacing tab in place of spaces.
 
 Signed-off-by: Sunil Shahu shsh...@gmail.com
 ---
  drivers/staging/media/lirc/lirc_sasem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/media/lirc/lirc_sasem.c 
 b/drivers/staging/media/lirc/lirc_sasem.c
 index 8ebee96..12aae72 100644
 --- a/drivers/staging/media/lirc/lirc_sasem.c
 +++ b/drivers/staging/media/lirc/lirc_sasem.c
 @@ -185,7 +185,7 @@ static void deregister_from_lirc(struct sasem_context 
 *context)
  __func__, retval);
   else
   dev_info(context-dev-dev,
 -  Deregistered Sasem driver (minor:%d)\n, minor);
 + Deregistered Sasem driver (minor:%d)\n, minor);

Not quite.  The original is:

[tab][tab][space][space][space][space][space][space][space][space][space]Dere...

You have:

[tab][tab][tab]Deregistered Sasem driver ...

It should be:

[tab][tab][tab][space]Deregistered Sasem driver (minor:%d)\n, minor);

regards,
dan carpenter

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


[PATCH] staging: media: lirc: fix coding style error

2015-06-19 Thread Sunil Shahu
Fix code indentation error by replacing tab in place of spaces.

Signed-off-by: Sunil Shahu shsh...@gmail.com
---
 drivers/staging/media/lirc/lirc_sasem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/lirc/lirc_sasem.c 
b/drivers/staging/media/lirc/lirc_sasem.c
index 8ebee96..12aae72 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -185,7 +185,7 @@ static void deregister_from_lirc(struct sasem_context 
*context)
   __func__, retval);
else
dev_info(context-dev-dev,
-Deregistered Sasem driver (minor:%d)\n, minor);
+   Deregistered Sasem driver (minor:%d)\n, minor);
 
 }
 
-- 
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


Re: [PATCH for v4.2] cobalt: set Kconfig default to n

2015-06-19 Thread Mauro Carvalho Chehab
Em Fri, 19 Jun 2015 08:31:05 +0200
Hans Verkuil hverk...@xs4all.nl escreveu:

 Since this board is a Cisco-internal board there is no point in having it 
 compiled
 by default. So set the Kconfig default to n.

This should not change anything. The default for all options that aren't
specified are already 'n'.

 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 
 diff --git a/drivers/media/pci/cobalt/Kconfig 
 b/drivers/media/pci/cobalt/Kconfig
 index 3be1b2c..4d0777a 100644
 --- a/drivers/media/pci/cobalt/Kconfig
 +++ b/drivers/media/pci/cobalt/Kconfig
 @@ -7,6 +7,7 @@ config VIDEO_COBALT
   select VIDEO_ADV7511
   select VIDEO_ADV7842
   select VIDEOBUF2_DMA_SG
 + default n
   ---help---
 This is a video4linux driver for the Cisco PCIe Cobalt card.
  
 --
 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


Re: [PATCH v2] media: i2c: ADV7604: Migrate to regmap

2015-06-19 Thread Lars-Peter Clausen

On 06/16/2015 10:38 AM, Pablo Anton wrote:

This is a preliminary patch in order to add support for ALSA.
It replaces all current i2c access with regmap.


Looks pretty good.


  #define ADV76XX_REG(page, offset) (((page)  8) | (offset))
@@ -633,13 +618,15 @@ static int adv76xx_read_reg(struct v4l2_subdev *sd, 
unsigned int reg)
  {
struct adv76xx_state *state = to_state(sd);
unsigned int page = reg  8;
+   unsigned int val;

if (!(BIT(page)  state-info-page_mask))
return -EINVAL;

reg = 0xff;
+   regmap_read(state-regmap[page], reg, val);


should check return value of regmap_read.



-   return adv_smbus_read_byte_data(state, page, reg);
+   return val;
  }
  #endif



+static int configure_regmap(struct adv76xx_state *state, int region)
+{
+   int err;
+
+   if (!state-i2c_clients[region])
+   return -ENODEV;
+
+   if (!state-regmap[region]) {
+
+   state-regmap[region] =
+   devm_regmap_init_i2c(state-i2c_clients[region],
+adv76xx_regmap_cnf[region]);
+
+   if (IS_ERR(state-regmap[region])) {
+   err = PTR_ERR(state-regmap[region]);
+   v4l_err(state-i2c_clients[region],
+   Error initializing regmap %d with error 
%d\n,
+   region, err);
+   return -EINVAL;
+   }
+   }
+
+   return 0;
+}
+
+static int configure_regmaps(struct adv76xx_state *state)
+{
+   int i, err;
+
+   for (i = 0 ; i  ADV76XX_PAGE_MAX; i++) {


The IO page was already initilaized earlier on, so this should start with i 
= ADV7604_PAGE_AVLINK.



+   err = configure_regmap(state, i);
+   if (err  (err != -ENODEV))
+   return err;
+   }
+   return 0;
+}
+
  static int adv76xx_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
  {
@@ -2683,7 +2815,7 @@ static int adv76xx_probe(struct i2c_client *client,
struct v4l2_ctrl_handler *hdl;
struct v4l2_subdev *sd;
unsigned int i;
-   u16 val;
+   unsigned int val, val2;
int err;

/* Check if the adapter supports the needed features */
@@ -2747,22 +2879,36 @@ static int adv76xx_probe(struct i2c_client *client,
client-addr);
sd-flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;

+   /* Configure IO Regmap region */
+   err = configure_regmap(state, ADV76XX_PAGE_IO);
+
+   if (err) {
+   v4l2_info(sd, Error configuring IO regmap region\n);
+   return -ENODEV;
+   }
+
/*
 * Verify that the chip is present. On ADV7604 the RD_INFO register only
 * identifies the revision, while on ADV7611 it identifies the model as
 * well. Use the HDMI slave address on ADV7604 and RD_INFO on ADV7611.
 */
if (state-info-type == ADV7604) {
-   val = adv_smbus_read_byte_data_check(client, 0xfb, false);
+   regmap_read(state-regmap[ADV76XX_PAGE_IO], 0xfb, val);
if (val != 0x68) {
v4l2_info(sd, not an adv7604 on address 0x%x\n,
client-addr  1);
return -ENODEV;
}
} else {
-   val = (adv_smbus_read_byte_data_check(client, 0xea, false)  8)
-   | (adv_smbus_read_byte_data_check(client, 0xeb, false)  
0);
-   if (val != 0x2051) {
+   regmap_read(state-regmap[ADV76XX_PAGE_IO],
+   0xea,
+   val);
+   val2 = val  8;
+   regmap_read(state-regmap[ADV76XX_PAGE_IO],
+   0xeb,
+   val);


we should check the return value of regmap_read to make sure the device 
responds.



+   val2 |= val;
+   if (val2 != 0x2051) {
v4l2_info(sd, not an adv7611 on address 0x%x\n,
client-addr  1);
return -ENODEV;
@@ -2853,6 +2999,11 @@ static int adv76xx_probe(struct i2c_client *client,
if (err)
goto err_work_queues;

+   /* Configure regmaps */
+   err = configure_regmaps(state);
+   if (err)
+   goto err_entity;
+
err = adv76xx_core_init(sd);
if (err)
goto err_entity;



--
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 PCI Kconfig ANALOG_TV - CAMERA

2015-06-19 Thread Krzysztof Hałasa
Hi,

I noticed certain cards are currently under MEDIA_ANALOG_TV_SUPPORT
but it seems they are frame grabbers (with CVBS, Svideo etc. inputs)
rather than TV receivers (with analog TV tuners).

MEDIA_CAMERA_SUPPORT maybe isn't the best name (only meye driver seems
to drive a real camera in a laptop) but it at least doesn't select the
TUNERs.

Perhaps the following patch would make sense.

Signed-off-by: Krzysztof Hałasa khal...@piap.pl

--- a/drivers/media/pci/Kconfig
+++ b/drivers/media/pci/Kconfig
@@ -11,16 +11,16 @@ if MEDIA_PCI_SUPPORT
 if MEDIA_CAMERA_SUPPORT
comment Media capture support
 source drivers/media/pci/meye/Kconfig
+source drivers/media/pci/solo6x10/Kconfig
 source drivers/media/pci/sta2x11/Kconfig
+source drivers/media/pci/tw68/Kconfig
+source drivers/media/pci/zoran/Kconfig
 endif
 
 if MEDIA_ANALOG_TV_SUPPORT
comment Media capture/analog TV support
 source drivers/media/pci/ivtv/Kconfig
-source drivers/media/pci/zoran/Kconfig
 source drivers/media/pci/saa7146/Kconfig
-source drivers/media/pci/solo6x10/Kconfig
-source drivers/media/pci/tw68/Kconfig
 endif
 
 if MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland
--
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 09/17] staging/lirc_serial: Remove TSC-based timing

2015-06-19 Thread Andy Lutomirski
Hi Mauro, etc:

Are you okay with this change landing in the tip tree?

--Andy

On Fri, Jun 12, 2015 at 4:44 PM, Andy Lutomirski l...@kernel.org wrote:
 It wasn't compiled in by default.  I suspect that the driver was and
 still is broken, though -- it's calling udelay with a parameter
 that's derived from loops_per_jiffy.

 Cc: Jarod Wilson ja...@wilsonet.com
 Cc: de...@driverdev.osuosl.org
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Signed-off-by: Andy Lutomirski l...@kernel.org
 ---
  drivers/staging/media/lirc/lirc_serial.c | 63 
 ++--
  1 file changed, 4 insertions(+), 59 deletions(-)

 diff --git a/drivers/staging/media/lirc/lirc_serial.c 
 b/drivers/staging/media/lirc/lirc_serial.c
 index dc7984455c3a..465796a686c4 100644
 --- a/drivers/staging/media/lirc/lirc_serial.c
 +++ b/drivers/staging/media/lirc/lirc_serial.c
 @@ -327,9 +327,6 @@ static void safe_udelay(unsigned long usecs)
   * time
   */

 -/* So send_pulse can quickly convert microseconds to clocks */
 -static unsigned long conv_us_to_clocks;
 -
  static int init_timing_params(unsigned int new_duty_cycle,
 unsigned int new_freq)
  {
 @@ -344,7 +341,6 @@ static int init_timing_params(unsigned int new_duty_cycle,
 /* How many clocks in a microsecond?, avoiding long long divide */
 work = loops_per_sec;
 work *= 4295;  /* 4295 = 2^32 / 1e6 */
 -   conv_us_to_clocks = work  32;

 /*
  * Carrier period in clocks, approach good up to 32GHz clock,
 @@ -357,10 +353,9 @@ static int init_timing_params(unsigned int 
 new_duty_cycle,
 pulse_width = period * duty_cycle / 100;
 space_width = period - pulse_width;
 dprintk(in init_timing_params, freq=%d, duty_cycle=%d, 
 -   clk/jiffy=%ld, pulse=%ld, space=%ld, 
 -   conv_us_to_clocks=%ld\n,
 +   clk/jiffy=%ld, pulse=%ld, space=%ld\n,
 freq, duty_cycle, __this_cpu_read(cpu_info.loops_per_jiffy),
 -   pulse_width, space_width, conv_us_to_clocks);
 +   pulse_width, space_width);
 return 0;
  }
  #else /* ! USE_RDTSC */
 @@ -431,63 +426,14 @@ static long send_pulse_irdeo(unsigned long length)
 return ret;
  }

 -#ifdef USE_RDTSC
 -/* Version that uses Pentium rdtsc instruction to measure clocks */
 -
 -/*
 - * This version does sub-microsecond timing using rdtsc instruction,
 - * and does away with the fudged LIRC_SERIAL_TRANSMITTER_LATENCY
 - * Implicitly i586 architecture...  - Steve
 - */
 -
 -static long send_pulse_homebrew_softcarrier(unsigned long length)
 -{
 -   int flag;
 -   unsigned long target, start, now;
 -
 -   /* Get going quick as we can */
 -   rdtscl(start);
 -   on();
 -   /* Convert length from microseconds to clocks */
 -   length *= conv_us_to_clocks;
 -   /* And loop till time is up - flipping at right intervals */
 -   now = start;
 -   target = pulse_width;
 -   flag = 1;
 -   /*
 -* FIXME: This looks like a hard busy wait, without even an 
 occasional,
 -* polite, cpu_relax() call.  There's got to be a better way?
 -*
 -* The i2c code has the result of a lot of bit-banging work, I wonder 
 if
 -* there's something there which could be helpful here.
 -*/
 -   while ((now - start)  length) {
 -   /* Delay till flip time */
 -   do {
 -   rdtscl(now);
 -   } while ((now - start)  target);
 -
 -   /* flip */
 -   if (flag) {
 -   rdtscl(now);
 -   off();
 -   target += space_width;
 -   } else {
 -   rdtscl(now); on();
 -   target += pulse_width;
 -   }
 -   flag = !flag;
 -   }
 -   rdtscl(now);
 -   return ((now - start) - length) / conv_us_to_clocks;
 -}
 -#else /* ! USE_RDTSC */
  /* Version using udelay() */

  /*
   * here we use fixed point arithmetic, with 8
   * fractional bits.  that gets us within 0.1% or so of the right average
   * frequency, albeit with some jitter in pulse length - Steve
 + *
 + * This should use ndelay instead.
   */

  /* To match 8 fractional bits used for pulse/space length */
 @@ -520,7 +466,6 @@ static long send_pulse_homebrew_softcarrier(unsigned long 
 length)
 }
 return (actual-length)  8;
  }
 -#endif /* USE_RDTSC */

  static long send_pulse_homebrew(unsigned long length)
  {
 --
 2.4.2




-- 
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line unsubscribe linux-media in