Re: [PATCH 5/5] [media] cxusb: add analog mode support for Medion MD95700

2017-08-12 Thread kbuild test robot
Hi Maciej,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/Add-analog-mode-support-for-Medion-MD95700/20170813-041742
base:   git://linuxtv.org/media_tree.git master
config: tile-allyesconfig (attached as .config)
compiler: tilegx-linux-gcc (GCC) 4.6.2
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=tile 

All warnings (new ones prefixed by >>):

   drivers/media//usb/dvb-usb/cxusb-analog.c: In function 
'cxusb_medion_copy_field':
>> drivers/media//usb/dvb-usb/cxusb-analog.c:359:27: warning: comparison of 
>> distinct pointer types lacks a cast [enabled by default]
>> drivers/media//usb/dvb-usb/cxusb-analog.c:359:27: warning: comparison of 
>> distinct pointer types lacks a cast [enabled by default]

vim +359 drivers/media//usb/dvb-usb/cxusb-analog.c

   198  
   199  static bool cxusb_medion_copy_field(struct dvb_usb_device *dvbdev,
   200  struct cxusb_medion_auxbuf *auxbuf,
   201  struct cxusb_bt656_params *bt656,
   202  bool firstfield,
   203  unsigned int maxlines,
   204  unsigned int maxlinesamples)
   205  {
   206  while (bt656->line < maxlines &&
   207 !cxusb_auxbuf_isend(auxbuf, bt656->pos)) {
   208  
   209  unsigned char val;
   210  
   211  if (!cxusb_auxbuf_copy(auxbuf, bt656->pos, , 1))
   212  return false;
   213  
   214  if ((char)val == CXUSB_BT656_COMMON[0]) {
   215  char buf[3];
   216  
   217  if (!cxusb_auxbuf_copy(auxbuf, bt656->pos + 1,
   218 buf, 3))
   219  return false;
   220  
   221  if (buf[0] != (CXUSB_BT656_COMMON)[1] ||
   222  buf[1] != (CXUSB_BT656_COMMON)[2])
   223  goto normal_sample;
   224  
   225  if (bt656->line != 0 && (!!firstfield !=
   226   ((buf[2] & 
CXUSB_FIELD_MASK)
   227== CXUSB_FIELD_1))) {
   228  if (bt656->fmode == LINE_SAMPLES) {
   229  cxusb_vprintk(dvbdev, BT656,
   230"field %c after 
line %u field change\n",
   231firstfield ? '1' 
: '2',
   232bt656->line);
   233  
   234  if (bt656->buf != NULL &&
   235  maxlinesamples -
   236  bt656->linesamples > 0) 
{
   237  
   238  memset(bt656->buf, 0,
   239  maxlinesamples -
   240  
bt656->linesamples);
   241  
   242  bt656->buf +=
   243  maxlinesamples -
   244  
bt656->linesamples;
   245  
   246  cxusb_vprintk(dvbdev, 
BT656,
   247"field %c 
line %u %u samples still remaining (of %u)\n",
   248
firstfield ?
   249'1' : '2',
   250
bt656->line,
   251
maxlinesamples -
   252bt656->
   253
linesamples,
   254
maxlinesamples);
   255  }
   256  
   257  bt656->line++;
   258  }
   259  
   260  if (maxlines - bt656->line > 0 &&
   261  bt656->buf != NULL) {
   

cron job: media_tree daily build: ERRORS

2017-08-12 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:   Sun Aug 13 05:00:20 CEST 2017
media-tree git hash:ec0c3ec497cabbf3bfa03a9eb5edcc252190a4e0
media_build git hash:   3a2afb881d1efadba33831f9c56321c4bcbe7178
v4l-utils git hash: 5a67da05fded64b5f678033c16196799e134c62c
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.11.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-blackfin-bf561: OK
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: WARNINGS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.67-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.1.33-i686: ERRORS
linux-4.2.8-i686: ERRORS
linux-4.3.6-i686: ERRORS
linux-4.4.22-i686: ERRORS
linux-4.5.7-i686: ERRORS
linux-4.6.7-i686: ERRORS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: WARNINGS
linux-4.9.26-i686: WARNINGS
linux-4.10.14-i686: WARNINGS
linux-4.11-i686: WARNINGS
linux-4.12.1-i686: WARNINGS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.67-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.33-x86_64: ERRORS
linux-4.2.8-x86_64: ERRORS
linux-4.3.6-x86_64: ERRORS
linux-4.4.22-x86_64: ERRORS
linux-4.5.7-x86_64: ERRORS
linux-4.6.7-x86_64: ERRORS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9.26-x86_64: WARNINGS
linux-4.10.14-x86_64: WARNINGS
linux-4.11-x86_64: WARNINGS
linux-4.12.1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html


[linux-next:master 1210/6359] drivers/media//cec/cec-adap.c:167: error: unknown field 'lost_msgs' specified in initializer

2017-08-12 Thread kbuild test robot
Hi Hans,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   91dfed74eabcdae9378131546c446442c29bf769
commit: 6b2bbb08747a56dcf4ee33606a06025eca571260 [1210/6359] media: cec: rework 
the cec event handling
config: x86_64-randconfig-b0-08130946 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 6b2bbb08747a56dcf4ee33606a06025eca571260
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from include/linux/bitmap.h:8,
from include/linux/cpumask.h:11,
from arch/x86/include/asm/cpumask.h:4,
from arch/x86/include/asm/msr.h:10,
from arch/x86/include/asm/processor.h:20,
from arch/x86/include/asm/cpufeature.h:4,
from arch/x86/include/asm/thread_info.h:52,
from include/linux/thread_info.h:37,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:80,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from drivers/media//cec/cec-adap.c:22:
   include/linux/string.h: In function 'strncpy':
   include/linux/string.h:209: warning: '__f' is static but declared in 
inline function 'strncpy' which is not static
   include/linux/string.h:211: warning: '__f' is static but declared in 
inline function 'strncpy' which is not static
   include/linux/string.h: In function 'strcat':
   include/linux/string.h:219: warning: '__f' is static but declared in 
inline function 'strcat' which is not static
   include/linux/string.h:221: warning: '__f' is static but declared in 
inline function 'strcat' which is not static
   include/linux/string.h: In function 'strlen':
   include/linux/string.h:230: warning: '__f' is static but declared in 
inline function 'strlen' which is not static
   include/linux/string.h:233: warning: '__f' is static but declared in 
inline function 'strlen' which is not static
   include/linux/string.h: In function 'strnlen':
   include/linux/string.h:243: warning: '__f' is static but declared in 
inline function 'strnlen' which is not static
   include/linux/string.h: In function 'strlcpy':
   include/linux/string.h:255: warning: '__f' is static but declared in 
inline function 'strlcpy' which is not static
   include/linux/string.h:258: warning: '__f' is static but declared in 
inline function 'strlcpy' which is not static
   include/linux/string.h:260: warning: '__f' is static but declared in 
inline function 'strlcpy' which is not static
   include/linux/string.h:262: warning: '__f' is static but declared in 
inline function 'strlcpy' which is not static
   include/linux/string.h: In function 'strncat':
   include/linux/string.h:276: warning: '__f' is static but declared in 
inline function 'strncat' which is not static
   include/linux/string.h:280: warning: '__f' is static but declared in 
inline function 'strncat' which is not static
   include/linux/string.h: In function 'memset':
   include/linux/string.h:290: warning: '__f' is static but declared in 
inline function 'memset' which is not static
   include/linux/string.h:292: warning: '__f' is static but declared in 
inline function 'memset' which is not static
   include/linux/string.h: In function 'memcpy':
   include/linux/string.h:301: warning: '__f' is static but declared in 
inline function 'memcpy' which is not static
   include/linux/string.h:302: warning: '__f' is static but declared in 
inline function 'memcpy' which is not static
   include/linux/string.h:304: warning: '__f' is static but declared in 
inline function 'memcpy' which is not static
   include/linux/string.h:307: warning: '__f' is static but declared in 
inline function 'memcpy' which is not static
   include/linux/string.h: In function 'memmove':
   include/linux/string.h:316: warning: '__f' is static but declared in 
inline function 'memmove' which is not static
   include/linux/string.h:317: warning: '__f' is static but declared in 
inline function 'memmove' which is not static
   include/linux/string.h:319: warning: '__f' is static but declared in 
inline function 'memmove' which is not static
   include/linux/string.h:322: warning: '__f' is static but declared in 
inline function 'memmove' which is not static
   include/linux/string.h: In function 'memscan':
   include/linux/string.h:331: warning: '__f' is static but declared in 
inline function 'memscan' which is not static
   include/linux/string.h:333: warning: '__f' is static but declared in 
inline 

Re: [PATCH v7] rockchip/rga: v4l2 m2m support

2017-08-12 Thread kbuild test robot
Hi Jacob,

[auto build test ERROR on rockchip/for-next]
[also build test ERROR on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jacob-Chen/rockchip-rga-v4l2-m2m-support/20170803-234713
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git 
for-next
config: s390-allmodconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=s390 

All errors (new ones prefixed by >>):

   drivers/media/platform/rockchip-rga/rga-hw.c: In function 
'rga_cmd_set_trans_info':
   drivers/media/platform/rockchip-rga/rga-hw.c:237:17: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
 if (ctx->op == V4L2_PORTER_DUFF_CLEAR) {
^~
   drivers/media/platform/rockchip-rga/rga-hw.c:237:17: note: each undeclared 
identifier is reported only once for each function it appears in
   drivers/media/platform/rockchip-rga/rga-hw.c: In function 'rga_cmd_set_mode':
   drivers/media/platform/rockchip-rga/rga-hw.c:391:7: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_CLEAR:
  ^~
>> drivers/media/platform/rockchip-rga/rga-hw.c:397:7: error: 
>> 'V4L2_PORTER_DUFF_DST' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DST:
  ^~~~
   drivers/media/platform/rockchip-rga/rga-hw.c:398:7: error: 
'V4L2_PORTER_DUFF_DSTATOP' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTATOP:
  ^~~~
   drivers/media/platform/rockchip-rga/rga-hw.c:399:7: error: 
'V4L2_PORTER_DUFF_DSTIN' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTIN:
  ^~
   drivers/media/platform/rockchip-rga/rga-hw.c:400:7: error: 
'V4L2_PORTER_DUFF_DSTOUT' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTOUT:
  ^~~
>> drivers/media/platform/rockchip-rga/rga-hw.c:401:7: error: 
>> 'V4L2_PORTER_DUFF_DSTOVER' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTOVER:
  ^~~~
   drivers/media/platform/rockchip-rga/rga-hw.c:402:7: error: 
'V4L2_PORTER_DUFF_SRCATOP' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCATOP:
  ^~~~
   drivers/media/platform/rockchip-rga/rga-hw.c:403:7: error: 
'V4L2_PORTER_DUFF_SRCIN' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCIN:
  ^~
   drivers/media/platform/rockchip-rga/rga-hw.c:404:7: error: 
'V4L2_PORTER_DUFF_SRCOUT' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCOUT:
  ^~~
   drivers/media/platform/rockchip-rga/rga-hw.c:405:7: error: 
'V4L2_PORTER_DUFF_SRCOVER' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCOVER:
  ^~~~
   drivers/media/platform/rockchip-rga/rga-hw.c: In function 'rga_cmd_set':
   drivers/media/platform/rockchip-rga/rga-hw.c:623:17: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
 if (ctx->op != V4L2_PORTER_DUFF_CLEAR) {
^~

vim +/V4L2_PORTER_DUFF_DST +397 drivers/media/platform/rockchip-rga/rga-hw.c

   168  
   169  static void rga_cmd_set_trans_info(struct rga_ctx *ctx)
   170  {
   171  struct rockchip_rga *rga = ctx->rga;
   172  u32 *dest = rga->cmdbuf_virt;
   173  unsigned int scale_dst_w, scale_dst_h;
   174  unsigned int src_h, src_w, src_x, src_y, dst_h, dst_w, dst_x, 
dst_y;
   175  union rga_src_info src_info;
   176  union rga_dst_info dst_info;
   177  union rga_src_x_factor x_factor;
   178  union rga_src_y_factor y_factor;
   179  union rga_src_vir_info src_vir_info;
   180  union rga_src_act_info src_act_info;
   181  union rga_dst_vir_info dst_vir_info;
   182  union rga_dst_act_info dst_act_info;
   183  
   184  struct rga_addr_offset *dst_offset;
   185  struct rga_corners_addr_offset offsets;
   186  struct rga_corners_addr_offset src_offsets;
   187  
   188  src_h = ctx->in.crop.height;
   189  src_w = ctx->in.crop.width;
   190  src_x = ctx->in.crop.left;
   191  src_y = ctx->in.crop.top;
   192  dst_h = ctx->out.crop.height;
   193  dst_w = ctx->out.crop.width;
   194  dst_x = ctx->out.crop.left;
   195  dst_y = ctx->out.crop.top;
   196  
   197  src_info.val = 

Re: [PATCH v7] rockchip/rga: v4l2 m2m support

2017-08-12 Thread kbuild test robot
Hi Jacob,

[auto build test ERROR on rockchip/for-next]
[also build test ERROR on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jacob-Chen/rockchip-rga-v4l2-m2m-support/20170803-234713
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git 
for-next
config: openrisc-allyesconfig (attached as .config)
compiler: or1k-linux-gcc (GCC) 5.4.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   drivers/media/platform/rockchip-rga/rga.c: In function 'rga_s_ctrl':
>> drivers/media/platform/rockchip-rga/rga.c:159:7: error: 
>> 'V4L2_CID_PORTER_DUFF_MODE' undeclared (first use in this function)
 case V4L2_CID_PORTER_DUFF_MODE:
  ^
   drivers/media/platform/rockchip-rga/rga.c:159:7: note: each undeclared 
identifier is reported only once for each function it appears in
   drivers/media/platform/rockchip-rga/rga.c: In function 'rga_setup_ctrls':
   drivers/media/platform/rockchip-rga/rga.c:190:11: error: 
'V4L2_CID_PORTER_DUFF_MODE' undeclared (first use in this function)
  V4L2_CID_PORTER_DUFF_MODE,
  ^
   drivers/media/platform/rockchip-rga/rga.c:191:11: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
  V4L2_PORTER_DUFF_CLEAR, 0,
  ^
   drivers/media/platform/rockchip-rga/rga.c:192:11: error: 
'V4L2_PORTER_DUFF_SRC' undeclared (first use in this function)
  V4L2_PORTER_DUFF_SRC);
  ^
   drivers/media/platform/rockchip-rga/rga.c: At top level:
   drivers/media/platform/rockchip-rga/rga.c:742:12: warning: 
'rga_enable_clocks' defined but not used [-Wunused-function]
static int rga_enable_clocks(struct rockchip_rga *rga)
   ^
   drivers/media/platform/rockchip-rga/rga.c:774:13: warning: 
'rga_disable_clocks' defined but not used [-Wunused-function]
static void rga_disable_clocks(struct rockchip_rga *rga)
^
--
   drivers/media/platform/rockchip-rga/rga-hw.c: In function 
'rga_cmd_set_trans_info':
   drivers/media/platform/rockchip-rga/rga-hw.c:237:17: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
 if (ctx->op == V4L2_PORTER_DUFF_CLEAR) {
^
   drivers/media/platform/rockchip-rga/rga-hw.c:237:17: note: each undeclared 
identifier is reported only once for each function it appears in
   drivers/media/platform/rockchip-rga/rga-hw.c: In function 'rga_cmd_set_mode':
   drivers/media/platform/rockchip-rga/rga-hw.c:391:7: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_CLEAR:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c:397:7: error: 
'V4L2_PORTER_DUFF_DST' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DST:
  ^
>> drivers/media/platform/rockchip-rga/rga-hw.c:398:7: error: 
>> 'V4L2_PORTER_DUFF_DSTATOP' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTATOP:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c:399:7: error: 
'V4L2_PORTER_DUFF_DSTIN' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTIN:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c:400:7: error: 
'V4L2_PORTER_DUFF_DSTOUT' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTOUT:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c:401:7: error: 
'V4L2_PORTER_DUFF_DSTOVER' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_DSTOVER:
  ^
>> drivers/media/platform/rockchip-rga/rga-hw.c:402:7: error: 
>> 'V4L2_PORTER_DUFF_SRCATOP' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCATOP:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c:403:7: error: 
'V4L2_PORTER_DUFF_SRCIN' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCIN:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c:404:7: error: 
'V4L2_PORTER_DUFF_SRCOUT' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCOUT:
  ^
>> drivers/media/platform/rockchip-rga/rga-hw.c:405:7: error: 
>> 'V4L2_PORTER_DUFF_SRCOVER' undeclared (first use in this function)
 case V4L2_PORTER_DUFF_SRCOVER:
  ^
   drivers/media/platform/rockchip-rga/rga-hw.c: In function 'rga_cmd_set':
   drivers/media/platform/rockchip-rga/rga-hw.c:623:17: error: 
'V4L2_PORTER_DUFF_CLEAR' undeclared (first use in this function)
 if (ctx->op != V4L2_PORTER_DUFF_CLEAR) {
^

vim +/V4L2_CID_PORTER_DUFF_MODE +159 drivers/media/platform/rockchip-rga/rga.c

   150  
   151  static int rga_s_ctrl(struct v4l2_ctrl *ctrl)
   152  {
   153  struct rga_ctx *ctx 

Re: [PATCH 5/5] [media] cxusb: add analog mode support for Medion MD95700

2017-08-12 Thread kbuild test robot
Hi Maciej,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/Add-analog-mode-support-for-Medion-MD95700/20170813-041742
base:   git://linuxtv.org/media_tree.git master
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


vim +359 drivers/media/usb/dvb-usb/cxusb-analog.c

   198  
   199  static bool cxusb_medion_copy_field(struct dvb_usb_device *dvbdev,
   200  struct cxusb_medion_auxbuf *auxbuf,
   201  struct cxusb_bt656_params *bt656,
   202  bool firstfield,
   203  unsigned int maxlines,
   204  unsigned int maxlinesamples)
   205  {
   206  while (bt656->line < maxlines &&
   207 !cxusb_auxbuf_isend(auxbuf, bt656->pos)) {
   208  
   209  unsigned char val;
   210  
   211  if (!cxusb_auxbuf_copy(auxbuf, bt656->pos, , 1))
   212  return false;
   213  
   214  if ((char)val == CXUSB_BT656_COMMON[0]) {
   215  char buf[3];
   216  
   217  if (!cxusb_auxbuf_copy(auxbuf, bt656->pos + 1,
   218 buf, 3))
   219  return false;
   220  
   221  if (buf[0] != (CXUSB_BT656_COMMON)[1] ||
   222  buf[1] != (CXUSB_BT656_COMMON)[2])
   223  goto normal_sample;
   224  
   225  if (bt656->line != 0 && (!!firstfield !=
   226   ((buf[2] & 
CXUSB_FIELD_MASK)
   227== CXUSB_FIELD_1))) {
   228  if (bt656->fmode == LINE_SAMPLES) {
   229  cxusb_vprintk(dvbdev, BT656,
   230"field %c after 
line %u field change\n",
   231firstfield ? '1' 
: '2',
   232bt656->line);
   233  
   234  if (bt656->buf != NULL &&
   235  maxlinesamples -
   236  bt656->linesamples > 0) 
{
   237  
   238  memset(bt656->buf, 0,
   239  maxlinesamples -
   240  
bt656->linesamples);
   241  
   242  bt656->buf +=
   243  maxlinesamples -
   244  
bt656->linesamples;
   245  
   246  cxusb_vprintk(dvbdev, 
BT656,
   247"field %c 
line %u %u samples still remaining (of %u)\n",
   248
firstfield ?
   249'1' : '2',
   250
bt656->line,
   251
maxlinesamples -
   252bt656->
   253
linesamples,
   254
maxlinesamples);
   255  }
   256  
   257  bt656->line++;
   258  }
   259  
   260  if (maxlines - bt656->line > 0 &&
   261  bt656->buf != NULL) {
   262  memset(bt656->buf, 0,
   263  (maxlines - bt656->line)
   264  * maxlinesamples);
   265  
   266  bt656->buf +=
   267  (maxlines - bt656->line)
   268  * maxlinesamples;
   269  
   270  cxusb_vprintk(dvbdev, BT656,
   271   

Re: [linux-media] Patch notification: 3 patches updated

2017-08-12 Thread Peter Rosin
On 2017-08-09 17:01, Patchwork wrote:
> Hello,
> 
> The following patches (submitted by you) have been updated in patchwork:
> 
>  * linux-media: [2/3,media] cx231xx: drop return value of 
> cx231xx_i2c_unregister
>  - http://patchwork.linuxtv.org/patch/42858/
>  - for: Linux Media kernel patches
> was: Under Review
> now: Superseded
> 
>  * linux-media: [3/3,media] cx231xx: only unregister successfully registered 
> i2c adapters
>  - http://patchwork.linuxtv.org/patch/42857/
>  - for: Linux Media kernel patches
> was: Under Review
> now: Superseded
> 
>  * linux-media: [1/3,media] cx231xx: fail probe if i2c_add_adapter fails
>  - http://patchwork.linuxtv.org/patch/42859/
>  - for: Linux Media kernel patches
> was: Under Review
> now: Superseded
> 
> This email is a notification only - you do not need to respond.

*snip*

> If you think any status change is a mistake, please send an email to the ML.

I think the correct status should be "Accepted", right? Because I got mails
saying all three were queued...

Cheers,
peda


Re: [PATCH 5/5] [media] cxusb: add analog mode support for Medion MD95700

2017-08-12 Thread kbuild test robot
Hi Maciej,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.13-rc4 next-20170811]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/Add-analog-mode-support-for-Medion-MD95700/20170813-041742
base:   git://linuxtv.org/media_tree.git master
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/list.h:8:0,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from drivers/media//usb/dvb-usb/cxusb-analog.c:19:
   drivers/media//usb/dvb-usb/cxusb-analog.c: In function 
'cxusb_medion_copy_field':
   include/linux/kernel.h:772:16: warning: comparison of distinct pointer types 
lacks a cast
 (void) ( == );   \
   ^
   include/linux/kernel.h:761:2: note: in definition of macro '__min'
 t2 min2 = (y); \
 ^~
>> drivers/media//usb/dvb-usb/cxusb-analog.c:359:27: note: in expansion of 
>> macro 'min'
   unsigned int tocheck = min(sizeof(buf),
  ^~~
   include/linux/kernel.h:775:2: note: in expansion of macro '__max'
 __max(typeof(x), typeof(y),   \
 ^
>> drivers/media//usb/dvb-usb/cxusb-analog.c:360:10: note: in expansion of 
>> macro 'max'
 max(sizeof(buf),
 ^~~
   include/linux/kernel.h:772:16: warning: comparison of distinct pointer types 
lacks a cast
 (void) ( == );   \
   ^
   include/linux/kernel.h:761:13: note: in definition of macro '__min'
 t2 min2 = (y); \
^
>> drivers/media//usb/dvb-usb/cxusb-analog.c:359:27: note: in expansion of 
>> macro 'min'
   unsigned int tocheck = min(sizeof(buf),
  ^~~
   include/linux/kernel.h:775:2: note: in expansion of macro '__max'
 __max(typeof(x), typeof(y),   \
 ^
>> drivers/media//usb/dvb-usb/cxusb-analog.c:360:10: note: in expansion of 
>> macro 'max'
 max(sizeof(buf),
 ^~~

vim +/min +359 drivers/media//usb/dvb-usb/cxusb-analog.c

   198  
   199  static bool cxusb_medion_copy_field(struct dvb_usb_device *dvbdev,
   200  struct cxusb_medion_auxbuf *auxbuf,
   201  struct cxusb_bt656_params *bt656,
   202  bool firstfield,
   203  unsigned int maxlines,
   204  unsigned int maxlinesamples)
   205  {
   206  while (bt656->line < maxlines &&
   207 !cxusb_auxbuf_isend(auxbuf, bt656->pos)) {
   208  
   209  unsigned char val;
   210  
   211  if (!cxusb_auxbuf_copy(auxbuf, bt656->pos, , 1))
   212  return false;
   213  
   214  if ((char)val == CXUSB_BT656_COMMON[0]) {
   215  char buf[3];
   216  
   217  if (!cxusb_auxbuf_copy(auxbuf, bt656->pos + 1,
   218 buf, 3))
   219  return false;
   220  
   221  if (buf[0] != (CXUSB_BT656_COMMON)[1] ||
   222  buf[1] != (CXUSB_BT656_COMMON)[2])
   223  goto normal_sample;
   224  
   225  if (bt656->line != 0 && (!!firstfield !=
   226   ((buf[2] & 
CXUSB_FIELD_MASK)
   227== CXUSB_FIELD_1))) {
   228  if (bt656->fmode == LINE_SAMPLES) {
   229  cxusb_vprintk(dvbdev, BT656,
   230"field %c after 
line %u field change\n",
   231firstfield ? '1' 
: '2',
   232bt656->line);
   233  
   234  if (bt656->buf != NULL &&
   235  maxlinesamples -
   236  bt656->linesamples > 0) 
{
   237  
   238  memset(bt656->buf, 0,
   239  maxlinesamples -
   240  
bt656->linesamples);
   241  
   242  

[PATCH] au0828: fix unbalanced lock/unlock in au0828_usb_probe

2017-08-12 Thread Gustavo A. R. Silva
Call mutex_unlock and free dev on failure.

Reported-by: Julia Lawall 
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/media/usb/au0828/au0828-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 739df61..cd363a2 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -628,6 +628,8 @@ static int au0828_usb_probe(struct usb_interface *interface,
if (retval) {
pr_err("%s() au0282_dev_register failed to register on V4L2\n",
__func__);
+   mutex_unlock(>lock);
+   kfree(dev);
goto done;
}
 
-- 
2.5.0



[PATCH] [media] tuners: make tda18271_std_map const

2017-08-12 Thread Bhumika Goyal
Make these const as they are only used during a copy operation.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
 drivers/media/tuners/tda18271-maps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/tda18271-maps.c 
b/drivers/media/tuners/tda18271-maps.c
index 7d11467..9679804 100644
--- a/drivers/media/tuners/tda18271-maps.c
+++ b/drivers/media/tuners/tda18271-maps.c
@@ -1182,7 +1182,7 @@ int tda18271_lookup_map(struct dvb_frontend *fe,
 
 /*-*/
 
-static struct tda18271_std_map tda18271c1_std_map = {
+static const struct tda18271_std_map tda18271c1_std_map = {
.fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0,
  .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */
.atv_b= { .if_freq = 6750, .fm_rfn = 0, .agc_mode = 1, .std = 6,
@@ -1215,7 +1215,7 @@ int tda18271_lookup_map(struct dvb_frontend *fe,
  .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */
 };
 
-static struct tda18271_std_map tda18271c2_std_map = {
+static const struct tda18271_std_map tda18271c2_std_map = {
.fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0,
  .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */
.atv_b= { .if_freq = 6000, .fm_rfn = 0, .agc_mode = 1, .std = 5,
-- 
1.9.1



[PATCH v4 09/11] [media] ddbridge: fix dereference before check

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Both ts_release() and ts_open() can use "output" before check (smatch):

  drivers/media/pci/ddbridge/ddbridge-core.c:816 ts_release() warn: variable 
dereferenced before check 'output' (see line 809)
  drivers/media/pci/ddbridge/ddbridge-core.c:836 ts_open() warn: variable 
dereferenced before check 'output' (see line 828)

Fix by performing checks on those pointers.

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 66b520d131a0..e051a691eb42 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -738,8 +738,13 @@ static unsigned int ts_poll(struct file *file, poll_table 
*wait)
 static int ts_release(struct inode *inode, struct file *file)
 {
struct dvb_device *dvbdev = file->private_data;
-   struct ddb_output *output = dvbdev->priv;
-   struct ddb_input *input = output->port->input[0];
+   struct ddb_output *output = NULL;
+   struct ddb_input *input = NULL;
+
+   if (dvbdev) {
+   output = dvbdev->priv;
+   input = output->port->input[0];
+   }
 
if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (!input)
@@ -757,8 +762,13 @@ static int ts_open(struct inode *inode, struct file *file)
 {
int err;
struct dvb_device *dvbdev = file->private_data;
-   struct ddb_output *output = dvbdev->priv;
-   struct ddb_input *input = output->port->input[0];
+   struct ddb_output *output = NULL;
+   struct ddb_input *input = NULL;
+
+   if (dvbdev) {
+   output = dvbdev->priv;
+   input = output->port->input[0];
+   }
 
if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (!input)
-- 
2.13.0



[PATCH v4 10/11] [media] ddbridge: Kconfig option to control the MSI modparam default

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

It is known that MSI interrupts - while working quite well so far - can
still cause issues on some hardware platforms (causing I2C timeouts due
to unhandled interrupts). The msi variable/option is set to 1 by default.
So, add a Kconfig option prefixed with "EXPERIMENTAL" that will control
the default value of that modparam, defaulting to off for a better
user experience and (guaranteed) stable operation "per default".

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/Kconfig | 15 +++
 drivers/media/pci/ddbridge/ddbridge-main.c | 11 +--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/Kconfig 
b/drivers/media/pci/ddbridge/Kconfig
index c79a58fa5fc3..1330b2ecc72a 100644
--- a/drivers/media/pci/ddbridge/Kconfig
+++ b/drivers/media/pci/ddbridge/Kconfig
@@ -26,3 +26,18 @@ config DVB_DDBRIDGE
  - CineS2 V7/V7A and DuoFlex S2 V4 (ST STV0910-based)
 
  Say Y if you own such a card and want to use it.
+
+config DVB_DDBRIDGE_MSIENABLE
+   bool "Enable Message Signaled Interrupts (MSI) per default 
(EXPERIMENTAL)"
+   depends on DVB_DDBRIDGE
+   depends on PCI_MSI
+   default n
+   ---help---
+ Use PCI MSI (Message Signaled Interrupts) per default. Enabling this
+ might lead to I2C errors originating from the bridge in conjunction
+ with certain SATA controllers, requiring a reload of the ddbridge
+ module. MSI can still be disabled by passing msi=0 as option, as
+ this will just change the msi option default value.
+
+ If you're unsure, concerned about stability and don't want to pass
+ module options in case of troubles, say N.
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 420335f4b7bf..181d5f17fe91 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -47,10 +47,17 @@ MODULE_PARM_DESC(adapter_alloc,
 "0-one adapter per io, 1-one per tab with io, 2-one per tab, 
3-one for all");
 
 #ifdef CONFIG_PCI_MSI
+#ifdef CONFIG_DVB_DDBRIDGE_MSIENABLE
 int msi = 1;
+#else
+int msi;
+#endif
 module_param(msi, int, 0444);
-MODULE_PARM_DESC(msi,
-" Control MSI interrupts: 0-disable, 1-enable (default)");
+#ifdef CONFIG_DVB_DDBRIDGE_MSIENABLE
+MODULE_PARM_DESC(msi, "Control MSI interrupts: 0-disable, 1-enable (default)");
+#else
+MODULE_PARM_DESC(msi, "Control MSI interrupts: 0-disable (default), 1-enable");
+#endif
 #endif
 
 int ci_bitrate = 7;
-- 
2.13.0



[PATCH v4 11/11] [media] MAINTAINERS: add entry for ddbridge

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Signed-off-by: Daniel Scheller 
---
 MAINTAINERS | 8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 931abca006b7..0453a1365c3a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8421,6 +8421,14 @@ T:   git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/dvb-frontends/stv6111*
 
+MEDIA DRIVERS FOR DIGITAL DEVICES PCIE DEVICES
+M: Daniel Scheller 
+L: linux-media@vger.kernel.org
+W: https://linuxtv.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/pci/ddbridge/*
+
 MEDIA INPUT INFRASTRUCTURE (V4L/DVB)
 M: Mauro Carvalho Chehab 
 M: Mauro Carvalho Chehab 
-- 
2.13.0



[PATCH v4 04/11] [media] ddbridge: check pointers before dereferencing

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Fixes two warnings reported by smatch:

  drivers/media/pci/ddbridge/ddbridge-core.c:240 ddb_redirect() warn: variable 
dereferenced before check 'idev' (see line 238)
  drivers/media/pci/ddbridge/ddbridge-core.c:240 ddb_redirect() warn: variable 
dereferenced before check 'pdev' (see line 238)

Fixed by moving the existing checks up before accessing members.

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index bbd8d556175b..d7bf01f38d98 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -170,10 +170,10 @@ static int ddb_redirect(u32 i, u32 p)
struct ddb *pdev = ddbs[(p >> 4) & 0x3f];
struct ddb_port *port;
 
-   if (!idev->has_dma || !pdev->has_dma)
-   return -EINVAL;
if (!idev || !pdev)
return -EINVAL;
+   if (!idev->has_dma || !pdev->has_dma)
+   return -EINVAL;
 
port = >port[p & 0x0f];
if (!port->output)
-- 
2.13.0



[PATCH v4 07/11] [media] ddbridge: remove unreachable code

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

>From smatch:

  drivers/media/pci/ddbridge/ddbridge-core.c:3490 snr_store() info: ignoring 
unreachable code.

In fact, the function immediately returns zero, so remove it and update
ddb_attrs_snr[] to not reference it anymore.

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 27 ---
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 5df942f4e388..747f3b317fb9 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -3092,25 +3092,6 @@ static ssize_t snr_show(struct device *device,
return sprintf(buf, "%s\n", snr);
 }
 
-
-static ssize_t snr_store(struct device *device, struct device_attribute *attr,
-const char *buf, size_t count)
-{
-   struct ddb *dev = dev_get_drvdata(device);
-   int num = attr->attr.name[3] - 0x30;
-   u8 snr[34] = { 0x01, 0x00 };
-
-   return 0; /* NOE: remove completely? */
-   if (count > 31)
-   return -EINVAL;
-   if (dev->port[num].type >= DDB_TUNER_XO2)
-   return -EINVAL;
-   memcpy(snr + 2, buf, count);
-   i2c_write(>i2c[num].adap, 0x57, snr, 34);
-   i2c_write(>i2c[num].adap, 0x50, snr, 34);
-   return count;
-}
-
 static ssize_t bsnr_show(struct device *device,
 struct device_attribute *attr, char *buf)
 {
@@ -3250,10 +3231,10 @@ static struct device_attribute ddb_attrs_fan[] = {
 };
 
 static struct device_attribute ddb_attrs_snr[] = {
-   __ATTR(snr0, 0664, snr_show, snr_store),
-   __ATTR(snr1, 0664, snr_show, snr_store),
-   __ATTR(snr2, 0664, snr_show, snr_store),
-   __ATTR(snr3, 0664, snr_show, snr_store),
+   __ATTR_MRO(snr0, snr_show),
+   __ATTR_MRO(snr1, snr_show),
+   __ATTR_MRO(snr2, snr_show),
+   __ATTR_MRO(snr3, snr_show),
 };
 
 static struct device_attribute ddb_attrs_ctemp[] = {
-- 
2.13.0



[PATCH v4 06/11] [media] ddbridge: fix possible buffer overflow in ddb_ports_init()

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Report from smatch:

  drivers/media/pci/ddbridge/ddbridge-core.c:2659 ddb_ports_init() error: 
buffer overflow 'dev->port' 32 <= u32max

Fix by making sure "p" is greater than zero before checking for
"dev->port[].type == DDB_CI_EXTERNAL_XO2".

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 759a53e82252..5df942f4e388 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2551,7 +2551,7 @@ void ddb_ports_init(struct ddb *dev)
port->dvb[0].adap = >adap[2 * p];
port->dvb[1].adap = >adap[2 * p + 1];
 
-   if ((port->class == DDB_PORT_NONE) && i &&
+   if ((port->class == DDB_PORT_NONE) && i && p &&
dev->port[p - 1].type == DDB_CI_EXTERNAL_XO2) {
port->class = DDB_PORT_CI;
port->type = DDB_CI_EXTERNAL_XO2_B;
-- 
2.13.0



[PATCH v4 08/11] [media] ddbridge: fix impossible condition warning

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Smatch and gcc complained:

  drivers/media/pci/ddbridge/ddbridge-core.c:3491 bpsnr_show() warn: impossible 
condition '(snr[0] == 255) => ((-128)-127 == 255)'

  drivers/media/pci/ddbridge/ddbridge-core.c: In function ‘bpsnr_show’:
  drivers/media/pci/ddbridge/ddbridge-core.c:3491:13: warning: comparison is 
always false due to limited range of data type [-Wtype-limits]

Fix this by changing the type of snr to unsigned char.

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 747f3b317fb9..66b520d131a0 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -3107,7 +3107,7 @@ static ssize_t bpsnr_show(struct device *device,
 struct device_attribute *attr, char *buf)
 {
struct ddb *dev = dev_get_drvdata(device);
-   char snr[32];
+   unsigned char snr[32];
 
if (!dev->i2c_num)
return 0;
-- 
2.13.0



[PATCH v4 02/11] [media] ddbridge: split I/O related functions off from ddbridge.h

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

While it seems valid that headers can carry simple oneline static inline
annotated functions, move them into their own header file to have the
overall code more readable. Also, keep them as header (and don't put in
a separate object) and static inline to help the compiler avoid
generating function calls.

(Thanks to Jasmin J.  for valuable input on this!)

Cc: Jasmin J. 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c |  1 +
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |  1 +
 drivers/media/pci/ddbridge/ddbridge-io.h   | 71 ++
 drivers/media/pci/ddbridge/ddbridge-main.c |  1 +
 drivers/media/pci/ddbridge/ddbridge.h  | 43 --
 5 files changed, 74 insertions(+), 43 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-io.h

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 6cda798a80a4..de73b74a7afc 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -37,6 +37,7 @@
 #include "ddbridge.h"
 #include "ddbridge-i2c.h"
 #include "ddbridge-regs.h"
+#include "ddbridge-io.h"
 
 #include "tda18271c2dd.h"
 #include "stv6110x.h"
diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c 
b/drivers/media/pci/ddbridge/ddbridge-i2c.c
index 376d8a7ca0b9..3d4fafb5db27 100644
--- a/drivers/media/pci/ddbridge/ddbridge-i2c.c
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c
@@ -33,6 +33,7 @@
 #include "ddbridge.h"
 #include "ddbridge-i2c.h"
 #include "ddbridge-regs.h"
+#include "ddbridge-io.h"
 
 
/**/
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-io.h 
b/drivers/media/pci/ddbridge/ddbridge-io.h
new file mode 100644
index ..ce92e9484075
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-io.h
@@ -0,0 +1,71 @@
+/*
+ * ddbridge-io.h: Digital Devices bridge I/O inline functions
+ *
+ * Copyright (C) 2010-2017 Digital Devices GmbH
+ * Ralph Metzler 
+ * Marcus Metzler 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 only, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __DDBRIDGE_IO_H__
+#define __DDBRIDGE_IO_H__
+
+#include 
+
+#include "ddbridge.h"
+
+/**/
+
+static inline u32 ddblreadl(struct ddb_link *link, u32 adr)
+{
+   return readl((char *) (link->dev->regs + (adr)));
+}
+
+static inline void ddblwritel(struct ddb_link *link, u32 val, u32 adr)
+{
+   writel(val, (char *) (link->dev->regs + (adr)));
+}
+
+static inline u32 ddbreadl(struct ddb *dev, u32 adr)
+{
+   return readl((char *) (dev->regs + (adr)));
+}
+
+static inline void ddbwritel(struct ddb *dev, u32 val, u32 adr)
+{
+   writel(val, (char *) (dev->regs + (adr)));
+}
+
+static inline void ddbcpyto(struct ddb *dev, u32 adr, void *src, long count)
+{
+   return memcpy_toio((char *) (dev->regs + adr), src, count);
+}
+
+static inline void ddbcpyfrom(struct ddb *dev, void *dst, u32 adr, long count)
+{
+   return memcpy_fromio(dst, (char *) (dev->regs + adr), count);
+}
+
+static inline u32 safe_ddbreadl(struct ddb *dev, u32 adr)
+{
+   u32 val = ddbreadl(dev, adr);
+
+   /* (ddb)readl returns (uint)-1 (all bits set) on failure, catch that */
+   if (val == ~0) {
+   dev_err(>pdev->dev, "ddbreadl failure, adr=%08x\n", adr);
+   return 0;
+   }
+
+   return val;
+}
+
+#endif /* __DDBRIDGE_IO_H__ */
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 73b041118bbf..d06543bbc393 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -35,6 +35,7 @@
 #include "ddbridge.h"
 #include "ddbridge-i2c.h"
 #include "ddbridge-regs.h"
+#include "ddbridge-io.h"
 
 //
 /* module parameters */
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 65b3f6b38bd7..4b78b01cc0a8 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -349,49 +349,6 @@ 

[PATCH v4 05/11] [media] ddbridge: only register frontends in fe2 if fe is not NULL

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Smatch reported:

  drivers/media/pci/ddbridge/ddbridge-core.c:1602 dvb_input_attach() error: we 
previously assumed 'dvb->fe' could be null (see line 1595)

dvb->fe2 will ever only be populated when dvb->fe is set. So only handle
registration of dvb->fe2 when dvb->fe got set beforehand by moving the
registration into the "if (dvb->fe)" conditional.

Cc: Ralph Metzler 
Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index d7bf01f38d98..759a53e82252 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1506,23 +1506,25 @@ static int dvb_input_attach(struct ddb_input *input)
return 0;
}
dvb->attached = 0x30;
+
if (dvb->fe) {
if (dvb_register_frontend(adap, dvb->fe) < 0)
return -ENODEV;
+
+   if (dvb->fe2) {
+   if (dvb_register_frontend(adap, dvb->fe2) < 0)
+   return -ENODEV;
+   dvb->fe2->tuner_priv = dvb->fe->tuner_priv;
+   memcpy(>fe2->ops.tuner_ops,
+  >fe->ops.tuner_ops,
+  sizeof(struct dvb_tuner_ops));
+   }
}
-   if (dvb->fe2) {
-   if (dvb_register_frontend(adap, dvb->fe2) < 0)
-   return -ENODEV;
-   dvb->fe2->tuner_priv = dvb->fe->tuner_priv;
-   memcpy(>fe2->ops.tuner_ops,
-  >fe->ops.tuner_ops,
-  sizeof(struct dvb_tuner_ops));
-   }
+
dvb->attached = 0x31;
return 0;
 }
 
-
 static int port_has_encti(struct ddb_port *port)
 {
struct device *dev = port->dev->dev;
-- 
2.13.0



[PATCH v4 03/11] [media] ddbridge: split off hardware definitions and mappings

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Further cleanup of ddbridge-core and ddbridge-main, and moves all such
hw definitions into one single place, making things easier to maintain.

Signed-off-by: Daniel Scheller 
Tested-by: Richard Scobie 
Tested-by: Jasmin Jessich 
Tested-by: Dietmar Spingler 
Tested-by: Manfred Knick 
---
 drivers/media/pci/ddbridge/Makefile|   3 +-
 drivers/media/pci/ddbridge/ddbridge-core.c |  68 ---
 drivers/media/pci/ddbridge/ddbridge-hw.c   | 299 +
 drivers/media/pci/ddbridge/ddbridge-hw.h   |  52 +
 drivers/media/pci/ddbridge/ddbridge-main.c | 217 +
 drivers/media/pci/ddbridge/ddbridge.h  |   1 -
 6 files changed, 354 insertions(+), 286 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-hw.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-hw.h

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index fe8ff0c681ad..3ef3048a89ac 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -2,7 +2,8 @@
 # Makefile for the ddbridge device driver
 #
 
-ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-i2c.o
+ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-hw.o \
+   ddbridge-i2c.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index de73b74a7afc..bbd8d556175b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -67,74 +67,6 @@ static struct ddb *ddbs[DDB_MAX_ADAPTER];
 //
 //
 
-static struct ddb_regset octopus_input = {
-   .base = 0x200,
-   .num  = 0x08,
-   .size = 0x10,
-};
-
-static struct ddb_regset octopus_output = {
-   .base = 0x280,
-   .num  = 0x08,
-   .size = 0x10,
-};
-
-static struct ddb_regset octopus_idma = {
-   .base = 0x300,
-   .num  = 0x08,
-   .size = 0x10,
-};
-
-static struct ddb_regset octopus_idma_buf = {
-   .base = 0x2000,
-   .num  = 0x08,
-   .size = 0x100,
-};
-
-static struct ddb_regset octopus_odma = {
-   .base = 0x380,
-   .num  = 0x04,
-   .size = 0x10,
-};
-
-static struct ddb_regset octopus_odma_buf = {
-   .base = 0x2800,
-   .num  = 0x04,
-   .size = 0x100,
-};
-
-static struct ddb_regset octopus_i2c = {
-   .base = 0x80,
-   .num  = 0x04,
-   .size = 0x20,
-};
-
-static struct ddb_regset octopus_i2c_buf = {
-   .base = 0x1000,
-   .num  = 0x04,
-   .size = 0x200,
-};
-
-//
-
-struct ddb_regmap octopus_map = {
-   .irq_base_i2c = 0,
-   .irq_base_idma = 8,
-   .irq_base_odma = 16,
-   .i2c = _i2c,
-   .i2c_buf = _i2c_buf,
-   .idma = _idma,
-   .idma_buf = _idma_buf,
-   .odma = _odma,
-   .odma_buf = _odma_buf,
-   .input = _input,
-   .output = _output,
-};
-
-//
-//
-//
-
 static void ddb_set_dma_table(struct ddb_io *io)
 {
struct ddb *dev = io->port->dev;
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c 
b/drivers/media/pci/ddbridge/ddbridge-hw.c
new file mode 100644
index ..e35b41e8d860
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -0,0 +1,299 @@
+/*
+ * ddbridge-hw.c: Digital Devices bridge hardware maps
+ *
+ * Copyright (C) 2010-2017 Digital Devices GmbH
+ * Ralph Metzler 
+ * Marcus Metzler 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 only, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include "ddbridge.h"
+
+/**/
+
+static struct ddb_regset octopus_input = {
+   .base = 0x200,
+   .num  = 0x08,
+   .size = 0x10,
+};
+
+static struct ddb_regset octopus_output = {
+   .base = 0x280,
+   .num  = 0x08,
+   .size = 0x10,
+};
+
+static struct ddb_regset octopus_idma = {
+   .base = 0x300,
+   .num  = 

[PATCH v4 00/11] ddbridge: bump to ddbridge-0.9.29

2017-08-12 Thread Daniel Scheller
From: Daniel Scheller 

Still, target: 4.14.

Changes from v3 to v4:
* IRQ handler splitoff removed
* Prefixed irq_handler{,0,1} with ddb_ to avoid potential conflicts in
  the global namespace wrt things like allyesconfig due to very generic
  function naming
* Removed MSI_IRQHANDLERS #ifdef'ery

Changes from v2 to v3:
* (private) IOCTLs (temporarily) removed. Proper implementation via
  UAPI and some documentation will be (re)added with a separate patch.
  Even with this functionality removed (which most prominently is used
  to update the card FPGA) everything is still working as intended.
  With this, also temporarily removed the existing FLASHIO IOCTL.
* Code move/split already merged thus no longer part of the series

Changes from v1 to v2:
* I2C access functions (ie. i2c_read() et al) refactored from
  ddbridge-i2c.c into ddbridge-i2c.h and declared static, and needed
  include added to all .c files making use of them. This fixes symbol
  conflicts in the global namespace with other drivers (kbuild test
  robot reported a conflict with an infiniband driver) when compiling
  into the kernel blob. While at it, code style has been made proper
  (in ddbridge-i2c.h) and the 0.9.29 code bump patch was updated to
  re-use the "plural" functions from their "singular" equivalents.
* The IRQ_HANDLE_BYTE() macro was removed. It is used nowhere, even
  in the unmodified/unstripped upstream driver.
* Shortened the buffer overflow fix in ddb_ports_init() from checking
  "p > 0" to only check "p".

Changes from original series to the resend:
* rebased on latest mediatree-master wrt
commit 618e8aac3d7c ("media: ddbridge: constify i2c_algorithm structure")
* build error in ddbridge-core.c fixed wrt
commit dcda9b04713c ("mm, tree wide: replace __GFP_REPEAT by 
__GFP_RETRY_MAYFAIL with more useful semantic")
* useless return removed from void calc_con()
* UTF8 in ddbridge-regs.h removed
* Tested-by's added to commit messages

Previous Tested-by testimonials still apply. v4 only has structural
changes which were build and runtime tested (built from the full tree and
via media_build).

Unless any important changes are neccessary, I consider this v4 the final
version. IOCTL refactor/rework won't be part of the code bump but will
be done as separate patch instead.

Note: DD have already picked up most of the changes that were introduced
during cleanup of the ddbridge driver so both versions are quite on par
in this regard. DD already released a 0.9.31, patches to bump this 0.9.29
to 0.9.31 are in preparation and even partly finished to get things fully
synced after this series hits media_tree.

>From previous cover letters:

Mauro/Media maintainers, this updates drivers/media/pci/ddbridge to the
very latest code that DD carry in their vendor driver package as of
version 0.9.29, in the "once, the big-bang-way is ok" way as discussed at
[2] (compared to the incremental, awkward to do variant since that
involves dissecting all available release archives and having to - try
to - build proper commits out of this, which will always be inaccurate;
a start was done at [3], however - and please understand - I definitely
don't want to continue doing that...)

In the last patch, I add myself to MAINTAINERS. This means I will care
about getting driver updates as they're released by DD into mainline,
starting from this (0.9.29) version, which is definitely doable in an
incremental way. So, I'll make sure the in-kernel driver won't bit-rot
again, and it will receive new hardware support as it becomes available
in a timely manner.

While the driver code bump looks massive, judging from the diff, there's
mostly a whole lot of refactoring and restructuring of variables, port/
link management and all such stuff in it. Feature-wise, this is most
notable:

 - Support for all (PCIe) CI (single/duo) cards and Flex addons
 - Support for MSI (Message Signaled Interrupts), though disabled by
   default since there were still reports of problems with this
 - TS Loopback support (set up ports to behave as if a CI is connected,
   without decryption of course)
 - As mentioned: Heavy code reordering, and split up into multiple files

Stripped functionality compared to dddvb:

 - DVB-C modulator card support removed (requires DVB core API)
 - OctoNET SAT>IP server/box support removed (requires API aswell)
 - with this, GT link support was removed (only on OctoNET hardware)
 - MaxS8 4/8 DVB-S/S2 card support (temporarily) removed (requires an
   additional Demod driver; subject for another, later, series)
 - (temp) driver IOCTLs/API removed and subject for readdition.

A note on the patches:

The bump starts by aligning the code "order-wise" to the updated driver,
to keep the diff a bit cleaner. Next, the code split is applied, without
actually changing any functionality. Compared to upstream, this isn't done
by moving functions into different C files and then do an include on them,
but we're handling them with the 

Re: [PATCH 4/4] drm: adv7511/33: add HDMI CEC support

2017-08-12 Thread Hans Verkuil
On 12/08/17 11:53, Hans Verkuil wrote:
> On 10/08/17 10:49, Archit Taneja wrote:
>>
>>
>> On 07/30/2017 06:37 PM, Hans Verkuil wrote:
>>> From: Hans Verkuil 
>>>
>>> Add support for HDMI CEC to the drm adv7511/adv7533 drivers.
>>>
>>> The CEC registers that we need to use are identical for both drivers,
>>> but they appear at different offsets in the register map.
>>
>> Thanks for the patch. Some minor comments below.
>>
>>>
>>> Signed-off-by: Hans Verkuil 
>>> ---
>>>   drivers/gpu/drm/bridge/adv7511/Kconfig   |   8 +
>>>   drivers/gpu/drm/bridge/adv7511/Makefile  |   1 +
>>>   drivers/gpu/drm/bridge/adv7511/adv7511.h |  45 +++-
>>>   drivers/gpu/drm/bridge/adv7511/adv7511_cec.c | 314 
>>> +++
>>>   drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 152 +++--
>>>   drivers/gpu/drm/bridge/adv7511/adv7533.c |  30 +--
>>>   6 files changed, 500 insertions(+), 50 deletions(-)
>>>   create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>>



>>>   +static bool adv7533_cec_register_volatile(struct device *dev, unsigned 
>>> int reg)
>>> +{
>>> +switch (reg) {
>>> +case ADV7511_REG_CEC_RX_FRAME_HDR + ADV7533_REG_CEC_OFFSET:
>>> +case ADV7511_REG_CEC_RX_FRAME_DATA0 + ADV7533_REG_CEC_OFFSET...
>>> +ADV7511_REG_CEC_RX_FRAME_DATA0 + ADV7533_REG_CEC_OFFSET + 14:
>>> +case ADV7511_REG_CEC_RX_FRAME_LEN + ADV7533_REG_CEC_OFFSET:
>>> +case ADV7511_REG_CEC_RX_BUFFERS + ADV7533_REG_CEC_OFFSET:
>>> +case ADV7511_REG_CEC_TX_LOW_DRV_CNT + ADV7533_REG_CEC_OFFSET:
>>> +return true;
>>> +}
>>> +
>>> +return false;
>>> +}
>>> +
>>> +static const struct regmap_config adv7533_cec_regmap_config = {
>>> +.reg_bits = 8,
>>> +.val_bits = 8,
>>> +
>>> +.max_register = 0xff,
>>> +.cache_type = REGCACHE_RBTREE,
>>> +.volatile_reg = adv7533_cec_register_volatile,
>>> +};
>>> +
>>> +static bool adv7511_cec_register_volatile(struct device *dev, unsigned int 
>>> reg)
>>> +{
>>
>> Maybe we could combine the two register_volatile() funcs and the 
>> remap_config structs
>> for adv7511 and adv7533 by passing (reg + offset) to switch?
> 
> How? How would I know in the volatile function whether it is an adv7511 or 
> adv7533?
> Is there an easy way to go from the struct device to a struct adv7511?

Never mind, I figured it out.

Implemented.

Regards,

Hans



[PATCH v3] media: v4l2-ctrls.h: better document the arguments for v4l2_ctrl_fill

2017-08-12 Thread Mauro Carvalho Chehab
The arguments for this function are pointers. Make it clear at
its documentation.

Signed-off-by: Mauro Carvalho Chehab 
---

Hans,

Feel free to pick this patch on your tree, if you're ok with it. Your approach 
for
using v4l_queryctl() sounds better,  as it covers private controls too.
So I'm not submitting the other patches that used to be in this series. Yet,
I think it doesn't hurt to make the documentation clearer about the
pointers.

 include/media/v4l2-ctrls.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 2d2aed56922f..dacfe54057f8 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -340,17 +340,17 @@ struct v4l2_ctrl_config {
  * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
  *
  * @id: ID of the control
- * @name: name of the control
- * @type: type of the control
- * @min: minimum value for the control
- * @max: maximum value for the control
- * @step: control step
- * @def: default value for the control
- * @flags: flags to be used on the control
+ * @name: pointer to be filled with a string with the name of the control
+ * @type: pointer for storing the type of the control
+ * @min: pointer for storing the minimum value for the control
+ * @max: pointer for storing the maximum value for the control
+ * @step: pointer for storing the control step
+ * @def: pointer for storing the default value for the control
+ * @flags: pointer for storing the flags to be used on the control
  *
  * This works for all standard V4L2 controls.
  * For non-standard controls it will only fill in the given arguments
- * and @name will be %NULL.
+ * and @name content will be set to %NULL.
  *
  * This function will overwrite the contents of @name, @type and @flags.
  * The contents of @min, @max, @step and @def may be modified depending on
-- 
2.13.3




Re: [PATCH 4/4] drm: adv7511/33: add HDMI CEC support

2017-08-12 Thread Hans Verkuil
On 10/08/17 10:49, Archit Taneja wrote:
> 
> 
> On 07/30/2017 06:37 PM, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> Add support for HDMI CEC to the drm adv7511/adv7533 drivers.
>>
>> The CEC registers that we need to use are identical for both drivers,
>> but they appear at different offsets in the register map.
> 
> Thanks for the patch. Some minor comments below.
> 
>>
>> Signed-off-by: Hans Verkuil 
>> ---
>>   drivers/gpu/drm/bridge/adv7511/Kconfig   |   8 +
>>   drivers/gpu/drm/bridge/adv7511/Makefile  |   1 +
>>   drivers/gpu/drm/bridge/adv7511/adv7511.h |  45 +++-
>>   drivers/gpu/drm/bridge/adv7511/adv7511_cec.c | 314 
>> +++
>>   drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 152 +++--
>>   drivers/gpu/drm/bridge/adv7511/adv7533.c |  30 +--
>>   6 files changed, 500 insertions(+), 50 deletions(-)
>>   create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
>>
>> diff --git a/drivers/gpu/drm/bridge/adv7511/Kconfig 
>> b/drivers/gpu/drm/bridge/adv7511/Kconfig
>> index 2fed567f9943..592b9d2ec034 100644
>> --- a/drivers/gpu/drm/bridge/adv7511/Kconfig
>> +++ b/drivers/gpu/drm/bridge/adv7511/Kconfig
>> @@ -21,3 +21,11 @@ config DRM_I2C_ADV7533
>>   default y
>>   help
>> Support for the Analog Devices ADV7533 DSI to HDMI encoder.
>> +
>> +config DRM_I2C_ADV7511_CEC
>> +bool "ADV7511/33 HDMI CEC driver"
>> +depends on DRM_I2C_ADV7511
>> +select CEC_CORE
>> +default y
>> +help
>> +  When selected the HDMI transmitter will support the CEC feature.
>> diff --git a/drivers/gpu/drm/bridge/adv7511/Makefile 
>> b/drivers/gpu/drm/bridge/adv7511/Makefile
>> index 5ba675534f6e..5bb384938a71 100644
>> --- a/drivers/gpu/drm/bridge/adv7511/Makefile
>> +++ b/drivers/gpu/drm/bridge/adv7511/Makefile
>> @@ -1,4 +1,5 @@
>>   adv7511-y := adv7511_drv.o
>>   adv7511-$(CONFIG_DRM_I2C_ADV7511_AUDIO) += adv7511_audio.o
>> +adv7511-$(CONFIG_DRM_I2C_ADV7511_CEC) += adv7511_cec.o
>>   adv7511-$(CONFIG_DRM_I2C_ADV7533) += adv7533.o
>>   obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511.o
>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
>> b/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> index fe18a5d2d84b..4fd7b14f619b 100644
>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
>> @@ -195,6 +195,25 @@
>>   #define ADV7511_PACKET_GM(x)ADV7511_PACKET(5, x)
>>   #define ADV7511_PACKET_SPARE(x)ADV7511_PACKET(6, x)
>>   +#define ADV7511_REG_CEC_TX_FRAME_HDR0x00
>> +#define ADV7511_REG_CEC_TX_FRAME_DATA00x01
>> +#define ADV7511_REG_CEC_TX_FRAME_LEN0x10
>> +#define ADV7511_REG_CEC_TX_ENABLE0x11
>> +#define ADV7511_REG_CEC_TX_RETRY0x12
>> +#define ADV7511_REG_CEC_TX_LOW_DRV_CNT0x14
>> +#define ADV7511_REG_CEC_RX_FRAME_HDR0x15
>> +#define ADV7511_REG_CEC_RX_FRAME_DATA00x16
>> +#define ADV7511_REG_CEC_RX_FRAME_LEN0x25
>> +#define ADV7511_REG_CEC_RX_ENABLE0x26
>> +#define ADV7511_REG_CEC_RX_BUFFERS0x4a
>> +#define ADV7511_REG_CEC_LOG_ADDR_MASK0x4b
>> +#define ADV7511_REG_CEC_LOG_ADDR_0_10x4c
>> +#define ADV7511_REG_CEC_LOG_ADDR_20x4d
>> +#define ADV7511_REG_CEC_CLK_DIV0x4e
>> +#define ADV7511_REG_CEC_SOFT_RESET0x50
>> +
>> +#define ADV7533_REG_CEC_OFFSET0x70
>> +
>>   enum adv7511_input_clock {
>>   ADV7511_INPUT_CLOCK_1X,
>>   ADV7511_INPUT_CLOCK_2X,
>> @@ -297,6 +316,8 @@ enum adv7511_type {
>>   ADV7533,
>>   };
>>   +#define ADV7511_MAX_ADDRS 3
>> +
>>   struct adv7511 {
>>   struct i2c_client *i2c_main;
>>   struct i2c_client *i2c_edid;
>> @@ -343,15 +364,29 @@ struct adv7511 {
>> enum adv7511_type type;
>>   struct platform_device *audio_pdev;
>> +
>> +struct cec_adapter *cec_adap;
>> +u8   cec_addr[ADV7511_MAX_ADDRS];
>> +u8   cec_valid_addrs;
>> +bool cec_enabled_adap;
>> +struct clk *cec_clk;
>> +u32 cec_clk_freq;
>>   };
>>   +#ifdef CONFIG_DRM_I2C_ADV7511_CEC
>> +extern const struct cec_adap_ops adv7511_cec_adap_ops;
>> +
>> +void adv7511_cec_init(struct adv7511 *adv7511, unsigned int offset);
>> +int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511);
>> +void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1);
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_I2C_ADV7533
>>   void adv7533_dsi_power_on(struct adv7511 *adv);
>>   void adv7533_dsi_power_off(struct adv7511 *adv);
>>   void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode);
>>   int adv7533_patch_registers(struct adv7511 *adv);
>> -void adv7533_uninit_cec(struct adv7511 *adv);
>> -int adv7533_init_cec(struct adv7511 *adv);
>> +int adv7533_patch_cec_registers(struct adv7511 *adv);
>>   int adv7533_attach_dsi(struct adv7511 *adv);
>>   void adv7533_detach_dsi(struct adv7511 *adv);
>>   int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv);
>> @@ -374,11 +409,7 @@ static inline int 

Re: [PATCH] v4l2-compat-ioctl32.c: make ctrl_is_pointer generic

2017-08-12 Thread Mauro Carvalho Chehab
Em Sat, 12 Aug 2017 10:22:07 +0200
Hans Verkuil  escreveu:

> On 11/08/17 23:08, Mauro Carvalho Chehab wrote:
> > Em Fri, 11 Aug 2017 15:26:03 +0200
> > Hans Verkuil  escreveu:
> >   
> >> The ctrl_is_pointer used a hard-coded list of control IDs that besides 
> >> being
> >> outdated also wouldn't work for custom driver controls.
> >>
> >> Replaced by calling queryctrl and checking if the 
> >> V4L2_CTRL_FLAG_HAS_PAYLOAD
> >> flag was set.
> >>
> >> Note that get_v4l2_ext_controls32() will set the v4l2_ext_control 'size' 
> >> field
> >> to 0 if the control has no payload before passing it to the kernel. This
> >> helps in put_v4l2_ext_controls32() since that function can just look at the
> >> 'size' field instead of having to call queryctrl again. The reason we set
> >> 'size' explicitly for non-pointer controls is that 'size' is ignored by the
> >> kernel in that case. That makes 'size' useless as an indicator of a pointer
> >> type in the put function since it can be any value. But setting it to 0 
> >> here
> >> turns it into a useful indicator.
> >>
> >> Also added proper checks for the compat_alloc_user_space return value which
> >> can be NULL, this was never done for some reason.  
> > 
> > On a quick preview, please split those extra checks you added on
> > a separate patch.
> > 
> > The logic for the remaining parts of this patch is not trivial. I'll look 
> > into it later.
> >   
> >>
> >> Tested with a 32-bit build of v4l2-ctl and the vivid driver.
> >>
> >> Signed-off-by: Hans Verkuil 
> >> ---
> >> diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
> >> b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> >> index af8b4c5b0efa..a16338cc216e 100644
> >> --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> >> +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c  
> 
> 
> 
> >> -/* The following function really belong in v4l2-common, but that causes
> >> -   a circular dependency between modules. We need to think about this, but
> >> -   for now this will do. */
> >>
> >> -/* Return non-zero if this control is a pointer type. Currently only
> >> -   type STRING is a pointer type. */
> >> -static inline int ctrl_is_pointer(u32 id)
> >> +/* Return non-zero if this control is a pointer type. */
> >> +static inline int ctrl_is_pointer(struct file *file, u32 id)
> >>  {
> >> -  switch (id) {
> >> -  case V4L2_CID_RDS_TX_PS_NAME:
> >> -  case V4L2_CID_RDS_TX_RADIO_TEXT:
> >> -  return 1;
> >> -  default:
> >> +  struct video_device *vfd = video_devdata(file);
> >> +  const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
> >> +  void *fh = file->private_data;
> >> +  struct v4l2_fh *vfh =
> >> +  test_bit(V4L2_FL_USES_V4L2_FH, >flags) ? fh : NULL;
> >> +  struct v4l2_queryctrl qctrl = { id };
> >> +  int err;
> >> +
> >> +  if (!test_bit(_IOC_NR(VIDIOC_QUERYCTRL), vfd->valid_ioctls))
> >> +  err = -ENOTTY;
> >> +  else if (vfh && vfh->ctrl_handler)
> >> +  err = v4l2_queryctrl(vfh->ctrl_handler, );
> >> +  else if (vfd->ctrl_handler)
> >> +  err = v4l2_queryctrl(vfd->ctrl_handler, );
> >> +  else if (ops->vidioc_queryctrl)
> >> +  err = ops->vidioc_queryctrl(file, fh, );
> >> +  else
> >> +  err = -ENOTTY;
> >> +
> >> +  if (err)
> >>return 0;
> >> -  }
> >> +
> >> +  return qctrl.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD;
> >>  }  
> 
> Mauro,
> 
> I'd like your opinion on something: the code to call queryctrl is identical to
> the v4l_queryctrl() function in v4l2-ioctl.c. I have been debating with myself
> whether or not to drop the 'static' from that v4l2-ioctl.c function and call
> it from here. It's a bit unexpected to have this source calling a function in
> v4l2-ioctl.c, but on the other hand it avoids having a copy of that function.
> 
> I'm leaning towards calling v4l_queryctrl from here, but I wonder what you
> think.

I would drop "static" from the function and call it directly here.

On my quick look on this patch yesterday, it came to my mind that
there is a lot of things there that, IMHO, doesn't belong to the
compat code (as it shouldn't know the dirty details about control
handling).

As both v4l2-ioctl and v4l2-compat-ioctl32 belongs to the same module
(videodev), you don't even need to make it exportable. 

IMHO, doing it let the code more clear and easier to review. As a side
effect, it prevents us to change both codes if the implementation of
v4l_queryctrl() changes.

Regards,
Mauro


Re: [PATCHv2 0/9] omapdrm: hdmi4: add CEC support

2017-08-12 Thread Hans Verkuil
On 11/08/17 12:57, Tomi Valkeinen wrote:
> Hi Hans,
> 
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> On 02/08/17 11:53, Hans Verkuil wrote:
>> From: Hans Verkuil 
>>
>> This patch series adds CEC support for the omap4. It is based on
>> the 4.13-rc2 kernel with this patch series applied:
>>
>> http://www.spinics.net/lists/dri-devel/msg143440.html
>>
>> It is virtually identical to the first patch series posted in
>> April:
>>
>> http://www.spinics.net/lists/dri-devel/msg138950.html
>>
>> The only two changes are in the Kconfig due to CEC Kconfig
>> changes in 4.13 (it now selects CEC_CORE instead of depending on
>> CEC_CORE) and a final patch was added adding a lost_hotplug op
>> since for proper CEC support I have to know when the hotplug
>> signal goes away.
>>
>> Tested with my Pandaboard.
> 
> I'm doing some testing with this series on my panda. One issue I see is
> that when I unload the display modules, I get:
> 
> [   75.180206] platform 58006000.encoder: enabled after unload, idling
> [   75.187896] platform 58001000.dispc: enabled after unload, idling
> [   75.198242] platform 5800.dss: enabled after unload, idling
> 
> So I think something is left enabled, most likely in the HDMI driver. I
> haven't debugged this yet.
> 
> The first time I loaded the modules I also got "operation stopped when
> reading edid", but I haven't seen that since. Possibly not related to
> this series.
> 
> Are there some simple ways to test the CEC? My buildroot fs has
> cec-compliance, cec-ctl and cec-follower commands. Are you familiar with
> those? Can they be used?

I'm very familiar with them since I wrote them :-)

The latest version of those utilities are maintained here:

https://git.linuxtv.org/v4l-utils.git/

But the ones from buildroot should be fine.

To use:

cec-ctl --playback  # configure the CEC adapter as a playback device
cec-ctl -S  # Detect and show all CEC devices

Note: all cec utilities use /dev/cec0 as the default device node. Use the
-d option to specify another device node.

So assuming you have the panda connected to a CEC-capable TV you should see
the TV in that list.

You can use cec-compliance to check the CEC compliance of devices:

cec-ctl --playback
cec-follower# emulate a CEC playback device follower functionality

In another shell run:

cec-compliance -r0  # Test remote CEC device with logical address 0 (== TV)

Regards,

Hans


Re: [GIT PULL FOR v4.14] RC changes (part #2)

2017-08-12 Thread Hans Verkuil
On 11/08/17 15:59, Sean Young wrote:
> Hi Mauro,
> 
> Please apply for-v4.14a before this pull request. This pull request includes
> a cec fix from Hans, to prevent merge conflicts.
> 
> The last patch is fairly large, and its purpose is get rid of the ugly
> RC_TYPE_ and RC_BIT_ names. I realise this is both invasive and
> controversial, so I've re-ordered the patches so this patch can be droppped
> easily.

Just to give my 5 cents on this topic: I really hope this rename can be
merged. It was a very confusing prefix and making clear that these defines
are about RC protocols is a major improvement. Speaking as a newbie here who
had to dip his toe for the first time in RC waters :-)

Regards,

Hans

> 
> As always I'm open to suggestions.
> 
> Thanks,
> 
> Sean
> 
> The following changes since commit 7af1952a935c062490dd697cd2cf7c65ee75dc19:
> 
>   [media] winbond-cir: buffer overrun during transmit (2017-08-04 15:59:50 
> +0100)
> 
> are available in the git repository at:
> 
>   git://linuxtv.org/syoung/media_tree.git for-v4.14b
> 
> for you to fetch changes up to d4ee680ebd231bfe791975194073c62081cb217e:
> 
>   [media] rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_* 
> (2017-08-11 13:55:20 +0100)
> 
> 
> Hans Verkuil (1):
>   [media] cec: fix remote control passthrough
> 
> Sean Young (7):
>   [media] rc-core: improve ir_raw_store_edge() handling
>   [media] rc: saa7134: add trailing space for timely decoding
>   [media] rc: simplify ir_raw_event_store_edge()
>   [media] rc: ensure we do not read out of bounds
>   [media] rc: saa7134: raw decoder can support any protocol
>   [media] rc: per-protocol repeat period
>   [media] rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to 
> RC_PROTO_BIT_*
> 
>  drivers/hid/hid-picolcd_cir.c  |   2 +-
>  drivers/media/cec/cec-adap.c   |  56 -
>  drivers/media/cec/cec-core.c   |  15 +-
>  drivers/media/common/siano/smsir.c |   2 +-
>  drivers/media/i2c/ir-kbd-i2c.c |  57 ++---
>  drivers/media/pci/bt8xx/bttv-input.c   |  16 +-
>  drivers/media/pci/cx18/cx18-i2c.c  |   4 +-
>  drivers/media/pci/cx23885/cx23885-input.c  |  14 +-
>  drivers/media/pci/cx88/cx88-input.c|  28 +--
>  drivers/media/pci/dm1105/dm1105.c  |   2 +-
>  drivers/media/pci/ivtv/ivtv-i2c.c  |  14 +-
>  drivers/media/pci/mantis/mantis_input.c|   2 +-
>  drivers/media/pci/saa7134/saa7134-input.c  |  79 +++
>  drivers/media/pci/smipcie/smipcie-ir.c |   2 +-
>  drivers/media/pci/ttpci/budget-ci.c|   5 +-
>  drivers/media/rc/ati_remote.c  |   5 +-
>  drivers/media/rc/ene_ir.c  |   2 +-
>  drivers/media/rc/fintek-cir.c  |   2 +-
>  drivers/media/rc/gpio-ir-recv.c|  29 +--
>  drivers/media/rc/igorplugusb.c |   9 +-
>  drivers/media/rc/iguanair.c|   2 +-
>  drivers/media/rc/img-ir/img-ir-hw.c|   4 +-
>  drivers/media/rc/img-ir/img-ir-hw.h|   4 +-
>  drivers/media/rc/img-ir/img-ir-jvc.c   |   4 +-
>  drivers/media/rc/img-ir/img-ir-nec.c   |  20 +-
>  drivers/media/rc/img-ir/img-ir-raw.c   |   4 +-
>  drivers/media/rc/img-ir/img-ir-rc5.c   |   4 +-
>  drivers/media/rc/img-ir/img-ir-rc6.c   |   4 +-
>  drivers/media/rc/img-ir/img-ir-sanyo.c |   4 +-
>  drivers/media/rc/img-ir/img-ir-sharp.c |   4 +-
>  drivers/media/rc/img-ir/img-ir-sony.c  |  27 +--
>  drivers/media/rc/imon.c|  49 +++--
>  drivers/media/rc/ir-hix5hd2.c  |   2 +-
>  drivers/media/rc/ir-jvc-decoder.c  |   6 +-
>  drivers/media/rc/ir-mce_kbd-decoder.c  |   6 +-
>  drivers/media/rc/ir-nec-decoder.c  |  17 +-
>  drivers/media/rc/ir-rc5-decoder.c  |  25 ++-
>  drivers/media/rc/ir-rc6-decoder.c  |  30 +--
>  drivers/media/rc/ir-sanyo-decoder.c|   6 +-
>  drivers/media/rc/ir-sharp-decoder.c|   6 +-
>  drivers/media/rc/ir-sony-decoder.c |  23 +-
>  drivers/media/rc/ir-xmp-decoder.c  |   4 +-
>  drivers/media/rc/ite-cir.c |   2 +-
>  drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c|   8 +-
>  drivers/media/rc/keymaps/rc-alink-dtu-m.c  |   8 +-
>  drivers/media/rc/keymaps/rc-anysee.c   |   8 +-
>  drivers/media/rc/keymaps/rc-apac-viewcomp.c|   8 +-
>  drivers/media/rc/keymaps/rc-asus-pc39.c|   8 +-
>  drivers/media/rc/keymaps/rc-asus-ps3-100.c |   8 +-
>  

[PATCHv2 1/3] drm: add support for DisplayPort CEC-Tunneling-over-AUX

2017-08-12 Thread Hans Verkuil
From: Hans Verkuil 

This adds support for the DisplayPort CEC-Tunneling-over-AUX
feature that is part of the DisplayPort 1.3 standard.

Unfortunately, not all DisplayPort/USB-C to HDMI adapters with a
chip that has this capability actually hook up the CEC pin, so
even though a CEC device is created, it may not actually work.

Signed-off-by: Hans Verkuil 
---
 drivers/gpu/drm/Kconfig  |  10 ++
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/drm_dp_cec.c | 302 +++
 include/drm/drm_dp_helper.h  |  24 
 4 files changed, 337 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_dp_cec.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 83cb2a88c204..1f2708df5c4e 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -120,6 +120,16 @@ config DRM_LOAD_EDID_FIRMWARE
  default case is N. Details and instructions how to build your own
  EDID data are given in Documentation/EDID/HOWTO.txt.
 
+config DRM_DP_CEC
+   bool "Enable DisplayPort CEC-Tunneling-over-AUX HDMI support"
+   select CEC_CORE
+   help
+ Choose this option if you want to enable HDMI CEC support for
+ DisplayPort/USB-C to HDMI adapters.
+
+ Note: not all adapters support this feature, and even for those
+ that do support this they often do not hook up the CEC pin.
+
 config DRM_TTM
tristate
depends on DRM && MMU
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 24a066e1841c..c6552c62049e 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -40,6 +40,7 @@ drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += 
drm_edid_load.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
 drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
 drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o
+drm_kms_helper-$(CONFIG_DRM_DP_CEC) += drm_dp_cec.o
 
 obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 obj-$(CONFIG_DRM_DEBUG_MM_SELFTEST) += selftests/
diff --git a/drivers/gpu/drm/drm_dp_cec.c b/drivers/gpu/drm/drm_dp_cec.c
new file mode 100644
index ..7f669900f5c1
--- /dev/null
+++ b/drivers/gpu/drm/drm_dp_cec.c
@@ -0,0 +1,302 @@
+/*
+ * DisplayPort CEC-Tunneling-over-AUX support
+ *
+ * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Unfortunately it turns out that we have a chicken-and-egg situation
+ * here. Quite a few active (mini-)DP-to-HDMI or USB-C-to-HDMI adapters
+ * have a converter chip that supports CEC-Tunneling-over-AUX (usually the
+ * Parade PS176), but they do not wire up the CEC pin, thus making CEC
+ * useless.
+ *
+ * Sadly there is no way for this driver to know this. What happens is
+ * that a /dev/cecX device is created that is isolated and unable to see
+ * any of the other CEC devices. Quite literally the CEC wire is cut
+ * (or in this case, never connected in the first place).
+ *
+ * I suspect that the reason so few adapters support this is that this
+ * tunneling protocol was never supported by any OS. So there was no
+ * easy way of testing it, and no incentive to correctly wire up the
+ * CEC pin.
+ *
+ * Hopefully by creating this driver it will be easier for vendors to
+ * finally fix their adapters and test the CEC functionality.
+ *
+ * I keep a list of known working adapters here:
+ *
+ * https://hverkuil.home.xs4all.nl/cec-status.txt
+ *
+ * Please mail me (hverk...@xs4all.nl) if you find an adapter that works
+ * and is not yet listed there.
+ */
+
+/**
+ * DOC: dp cec helpers
+ *
+ * These functions take care of supporting the CEC-Tunneling-over-AUX
+ * feature of DisplayPort-to-HDMI adapters.
+ */
+
+static int drm_dp_cec_adap_enable(struct cec_adapter *adap, bool enable)
+{
+   struct drm_dp_aux *aux = cec_get_drvdata(adap);
+   u32 val = enable ? DP_CEC_TUNNELING_ENABLE : 0;
+   ssize_t err = 0;
+
+   err = drm_dp_dpcd_writeb(aux, DP_CEC_TUNNELING_CONTROL, val);
+   return (enable && err < 0) ? err : 0;
+}
+
+static int drm_dp_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
+{
+   struct drm_dp_aux *aux = 

[PATCHv2 3/3] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

2017-08-12 Thread Hans Verkuil
From: Hans Verkuil 

Implement support for this DisplayPort feature.

The cec device is created whenever it detects an adapter that
has this feature. It is only removed when a new adapter is connected
that does not support this. If a new adapter is connected that has
different properties than the previous one, then the old cec device is
unregistered and a new one is registered to replace the old one.

Signed-off-by: Hans Verkuil 
---
 drivers/gpu/drm/i915/intel_dp.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 64fa774c855b..fdb853d2c458 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1449,6 +1450,7 @@ static void intel_aux_reg_init(struct intel_dp *intel_dp)
 static void
 intel_dp_aux_fini(struct intel_dp *intel_dp)
 {
+   cec_unregister_adapter(intel_dp->aux.cec_adap);
kfree(intel_dp->aux.name);
 }
 
@@ -4587,6 +4589,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp)
intel_connector->detect_edid = edid;
 
intel_dp->has_audio = drm_detect_monitor_audio(edid);
+   cec_s_phys_addr_from_edid(intel_dp->aux.cec_adap, edid);
 }
 
 static void
@@ -4596,6 +4599,7 @@ intel_dp_unset_edid(struct intel_dp *intel_dp)
 
kfree(intel_connector->detect_edid);
intel_connector->detect_edid = NULL;
+   cec_phys_addr_invalidate(intel_dp->aux.cec_adap);
 
intel_dp->has_audio = false;
 }
@@ -4616,13 +4620,17 @@ intel_dp_long_pulse(struct intel_connector 
*intel_connector)
intel_display_power_get(to_i915(dev), intel_dp->aux_power_domain);
 
/* Can't disconnect eDP, but you can close the lid... */
-   if (is_edp(intel_dp))
+   if (is_edp(intel_dp)) {
status = edp_detect(intel_dp);
-   else if (intel_digital_port_connected(to_i915(dev),
- dp_to_dig_port(intel_dp)))
+   } else if (intel_digital_port_connected(to_i915(dev),
+   dp_to_dig_port(intel_dp))) {
status = intel_dp_detect_dpcd(intel_dp);
-   else
+   if (status == connector_status_connected)
+   drm_dp_cec_configure_adapter(_dp->aux,
+intel_dp->aux.name, dev->dev);
+   } else {
status = connector_status_disconnected;
+   }
 
if (status == connector_status_disconnected) {
memset(_dp->compliance, 0, sizeof(intel_dp->compliance));
@@ -5011,6 +5019,8 @@ intel_dp_hpd_pulse(struct intel_digital_port 
*intel_dig_port, bool long_hpd)
 
intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
 
+   drm_dp_cec_irq(_dp->aux);
+
if (intel_dp->is_mst) {
if (intel_dp_check_mst_status(intel_dp) == -EINVAL) {
/*
-- 
2.13.2



[PATCHv2 2/3] drm-kms-helpers.rst: document the DP CEC helpers

2017-08-12 Thread Hans Verkuil
From: Hans Verkuil 

Document the Display Port CEC helper functions.

Signed-off-by: Hans Verkuil 
---
 Documentation/gpu/drm-kms-helpers.rst | 9 +
 1 file changed, 9 insertions(+)

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index 7c5e2549a58a..0d2fa879edd1 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -175,6 +175,15 @@ Display Port Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_dp_helper.c
:export:
 
+Display Port CEC Helper Functions Reference
+===
+
+.. kernel-doc:: drivers/gpu/drm/drm_dp_cec.c
+   :doc: dp cec helpers
+
+.. kernel-doc:: drivers/gpu/drm/drm_dp_cec.c
+   :export:
+
 Display Port Dual Mode Adaptor Helper Functions Reference
 =
 
-- 
2.13.2



[PATCHv2 0/3] drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

2017-08-12 Thread Hans Verkuil
From: Hans Verkuil 

This patch series adds support for the DisplayPort CEC-Tunneling-over-AUX
feature. This patch series is based on 4.13-rc4 which has all the needed cec
and drm 4.13 patches merged.

This patch series has been tested with my NUC7i5BNK and a Samsung USB-C to 
HDMI adapter.

Please note this comment at the start of drm_dp_cec.c:

--
Unfortunately it turns out that we have a chicken-and-egg situation
here. Quite a few active (mini-)DP-to-HDMI or USB-C-to-HDMI adapters
have a converter chip that supports CEC-Tunneling-over-AUX (usually the
Parade PS176), but they do not wire up the CEC pin, thus making CEC
useless.

Sadly there is no way for this driver to know this. What happens is 
that a /dev/cecX device is created that is isolated and unable to see
any of the other CEC devices. Quite literally the CEC wire is cut
(or in this case, never connected in the first place).

I suspect that the reason so few adapters support this is that this
tunneling protocol was never supported by any OS. So there was no 
easy way of testing it, and no incentive to correctly wire up the
CEC pin.

Hopefully by creating this driver it will be easier for vendors to 
finally fix their adapters and test the CEC functionality.

I keep a list of known working adapters here:

https://hverkuil.home.xs4all.nl/cec-status.txt

Please mail me (hverk...@xs4all.nl) if you find an adapter that works
and is not yet listed there.
--

I really hope that this work will provide an incentive for vendors to
finally connect the CEC pin. It's a shame that there are so few adapters
that work (I found only two USB-C to HDMI adapters that work, and no
(mini-)DP to HDMI adapters at all).

Note that a colleague who actually knows his way around a soldering iron
modified an UpTab DisplayPort-to-HDMI adapter for me, hooking up the CEC
pin. And after that change it worked. I also received confirmation that
this really is a chicken-and-egg situation: it is because there is no CEC
support for this feature in any OS that they do not hook up the CEC pin.

So hopefully if this gets merged there will be an incentive for vendors
to make adapters where this actually works. It is a very nice feature
for HTPC boxes.

Changes since v1:

- Incorporated Sean's review comments in patch 1/3.

Regards,

Hans

Hans Verkuil (3):
  drm: add support for DisplayPort CEC-Tunneling-over-AUX
  drm-kms-helpers.rst: document the DP CEC helpers
  drm/i915: add DisplayPort CEC-Tunneling-over-AUX support

 Documentation/gpu/drm-kms-helpers.rst |   9 +
 drivers/gpu/drm/Kconfig   |  10 ++
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/drm_dp_cec.c  | 302 ++
 drivers/gpu/drm/i915/intel_dp.c   |  18 +-
 include/drm/drm_dp_helper.h   |  24 +++
 6 files changed, 360 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_dp_cec.c

-- 
2.13.2



Re: [PATCH] v4l2-compat-ioctl32.c: make ctrl_is_pointer generic

2017-08-12 Thread Hans Verkuil
On 11/08/17 23:08, Mauro Carvalho Chehab wrote:
> Em Fri, 11 Aug 2017 15:26:03 +0200
> Hans Verkuil  escreveu:
> 
>> The ctrl_is_pointer used a hard-coded list of control IDs that besides being
>> outdated also wouldn't work for custom driver controls.
>>
>> Replaced by calling queryctrl and checking if the V4L2_CTRL_FLAG_HAS_PAYLOAD
>> flag was set.
>>
>> Note that get_v4l2_ext_controls32() will set the v4l2_ext_control 'size' 
>> field
>> to 0 if the control has no payload before passing it to the kernel. This
>> helps in put_v4l2_ext_controls32() since that function can just look at the
>> 'size' field instead of having to call queryctrl again. The reason we set
>> 'size' explicitly for non-pointer controls is that 'size' is ignored by the
>> kernel in that case. That makes 'size' useless as an indicator of a pointer
>> type in the put function since it can be any value. But setting it to 0 here
>> turns it into a useful indicator.
>>
>> Also added proper checks for the compat_alloc_user_space return value which
>> can be NULL, this was never done for some reason.
> 
> On a quick preview, please split those extra checks you added on
> a separate patch.
> 
> The logic for the remaining parts of this patch is not trivial. I'll look 
> into it later.
> 
>>
>> Tested with a 32-bit build of v4l2-ctl and the vivid driver.
>>
>> Signed-off-by: Hans Verkuil 
>> ---
>> diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
>> b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
>> index af8b4c5b0efa..a16338cc216e 100644
>> --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
>> +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c



>> -/* The following function really belong in v4l2-common, but that causes
>> -   a circular dependency between modules. We need to think about this, but
>> -   for now this will do. */
>>
>> -/* Return non-zero if this control is a pointer type. Currently only
>> -   type STRING is a pointer type. */
>> -static inline int ctrl_is_pointer(u32 id)
>> +/* Return non-zero if this control is a pointer type. */
>> +static inline int ctrl_is_pointer(struct file *file, u32 id)
>>  {
>> -switch (id) {
>> -case V4L2_CID_RDS_TX_PS_NAME:
>> -case V4L2_CID_RDS_TX_RADIO_TEXT:
>> -return 1;
>> -default:
>> +struct video_device *vfd = video_devdata(file);
>> +const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
>> +void *fh = file->private_data;
>> +struct v4l2_fh *vfh =
>> +test_bit(V4L2_FL_USES_V4L2_FH, >flags) ? fh : NULL;
>> +struct v4l2_queryctrl qctrl = { id };
>> +int err;
>> +
>> +if (!test_bit(_IOC_NR(VIDIOC_QUERYCTRL), vfd->valid_ioctls))
>> +err = -ENOTTY;
>> +else if (vfh && vfh->ctrl_handler)
>> +err = v4l2_queryctrl(vfh->ctrl_handler, );
>> +else if (vfd->ctrl_handler)
>> +err = v4l2_queryctrl(vfd->ctrl_handler, );
>> +else if (ops->vidioc_queryctrl)
>> +err = ops->vidioc_queryctrl(file, fh, );
>> +else
>> +err = -ENOTTY;
>> +
>> +if (err)
>>  return 0;
>> -}
>> +
>> +return qctrl.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD;
>>  }

Mauro,

I'd like your opinion on something: the code to call queryctrl is identical to
the v4l_queryctrl() function in v4l2-ioctl.c. I have been debating with myself
whether or not to drop the 'static' from that v4l2-ioctl.c function and call
it from here. It's a bit unexpected to have this source calling a function in
v4l2-ioctl.c, but on the other hand it avoids having a copy of that function.

I'm leaning towards calling v4l_queryctrl from here, but I wonder what you
think.

Regards,

Hans