Re: [PATCH 2/5] media: Add support for CXD2880 SPI I/F

2017-04-09 Thread Mauro Carvalho Chehab
Em Fri, 7 Apr 2017 08:19:58 +
"Takiguchi, Yasunari" <yasunari.takigu...@sony.com> escreveu:

> Dear All
> 
> Our patches consists of the following items.
>   [PATCH 1/5] dt-bindings: media: Add document file for CXD2880 SPI I/F
>   [PATCH 2/5] media: Add support for CXD2880 SPI I/F
>   [PATCH 3/5] media: Add suppurt for CXD2880
>   [PATCH 4/5] media: Add suppurt for CXD2880 DVB-T2/T functions
>   [PATCH 5/5] media: Update MAINTAINERS file for CXD2880

Didn't review your patch series yet. It should take a while to
review 14K lines ;)

> It is necessary to apply all patches before compiling kernel with our code.
> 
> Could you re-compile after applying above the patches.

The kbuild test robot is... a machine. It won't read or answer to
your reply :-)

It automatically tests all patches sent to the ML and apply them at the 
order the patches are found at the tree, one by one.

The rule is that no patch can cause compilation breakages, as
this breaks Kernel bisectability.

So, you have to ensure, when sending a patch series, that every single
patch is compilable, and won't cause runtime issues.

In the specific case of this patch:

> > drivers/media/spi/Kconfig   |   14 +
> > drivers/media/spi/Makefile  |5 +
> > drivers/media/spi/cxd2880-spi.c |  727 
> > +++
> > 3 files changed, 746 insertions(+)
> > create mode 100644 drivers/media/spi/cxd2880-spi.c

If cxd2880-spi.c need something else in order to be built, you
should not add it at Kconfig/Makefile yet. Just add the files, 
using an order that makes it easier to be reviewed. In this
particular case, if it needs a header file, the patch containing
the header file should ideally be sent together with it
(or a previous patch, if adding it together wouldn't work).

Also, what I usually do when submitting drivers is that I don't
touch Kconfig/Makefile too early, putting such changes by the end
of the patch series.

E. g. you could break this patch on two separate patches, where the
first one would be just adding the cxd2880-spi.c (and cxd2880.h). Another
possibility would be to move this patch to the end, if the other patches
don't break git bisect (e. g. if they all compile without problems) and if
they're good enough to be reviewed by someone using the patch order.


Thanks,
Mauro


RE: [PATCH 2/5] media: Add support for CXD2880 SPI I/F

2017-04-07 Thread Takiguchi, Yasunari
Dear All

Our patches consists of the following items.
  [PATCH 1/5] dt-bindings: media: Add document file for CXD2880 SPI I/F
  [PATCH 2/5] media: Add support for CXD2880 SPI I/F
  [PATCH 3/5] media: Add suppurt for CXD2880
  [PATCH 4/5] media: Add suppurt for CXD2880 DVB-T2/T functions
  [PATCH 5/5] media: Update MAINTAINERS file for CXD2880

It is necessary to apply all patches before compiling kernel with our code.

Could you re-compile after applying above the patches.

Best Regards,
Takiguchci



Re: [PATCH 2/5] media: Add support for CXD2880 SPI I/F

2017-04-07 Thread kbuild test robot
Hi Yasunari,

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.11-rc5 next-20170406]
[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/Yasunari-Takiguchi-sony-com/dt-bindings-media-Add-document-file-and-driver/20170407-064503
base:   git://linuxtv.org/media_tree.git master
config: x86_64-acpi-redef (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: the 
linux-review/Yasunari-Takiguchi-sony-com/dt-bindings-media-Add-document-file-and-driver/20170407-064503
 HEAD 9a65bc5ba5fc3ec361e835324009bf7097391121 builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> drivers/media//spi/cxd2880-spi.c:32:21: fatal error: cxd2880.h: No such file 
>> or directory
#include "cxd2880.h"
^
   compilation terminated.

vim +32 drivers/media//spi/cxd2880-spi.c

16   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT
17   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
ON
19   * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
TORT
20   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE OF
21   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22   *
23   * You should have received a copy of the GNU General Public License 
along
24   * with this program; if not, see .
25   */
26  
27  #include 
28  
29  #include "dvb_demux.h"
30  #include "dmxdev.h"
31  #include "dvb_frontend.h"
  > 32  #include "cxd2880.h"
33  
34  #define CXD2880_MAX_FILTER_SIZE 32
35  #define BURST_WRITE_MAX 128
36  #define MAX_TRANS_PACKET 300
37  
38  struct cxd2880_ts_buf_info {
39  u8 read_ready;
40  u8 almost_full;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 2/5] media: Add support for CXD2880 SPI I/F

2017-04-06 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator.
It contains the SPI adapter part of the driver.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/spi/Kconfig   |   14 +
 drivers/media/spi/Makefile  |5 +
 drivers/media/spi/cxd2880-spi.c |  727 +++
 3 files changed, 746 insertions(+)
 create mode 100644 drivers/media/spi/cxd2880-spi.c

diff --git a/drivers/media/spi/Kconfig b/drivers/media/spi/Kconfig
index a21f5a3..b07ac86 100644
--- a/drivers/media/spi/Kconfig
+++ b/drivers/media/spi/Kconfig
@@ -12,3 +12,17 @@ config VIDEO_GS1662
 endmenu
 
 endif
+
+if SPI
+menu "Media SPI Adapters"
+
+config CXD2880_SPI_DRV
+   tristate "Sony CXD2880 SPI support"
+   depends on DVB_CORE && SPI
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Choose if you would like to have SPI interface support for Sony 
CXD2880.
+
+endmenu
+
+endif
diff --git a/drivers/media/spi/Makefile b/drivers/media/spi/Makefile
index ea64013..40e0f88 100644
--- a/drivers/media/spi/Makefile
+++ b/drivers/media/spi/Makefile
@@ -1 +1,6 @@
 obj-$(CONFIG_VIDEO_GS1662) += gs1662.o
+obj-$(CONFIG_CXD2880_SPI_DRV) += cxd2880-spi.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/dvb-frontends/cxd2880
\ No newline at end of file
diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
new file mode 100644
index 000..7ba0ed8
--- /dev/null
+++ b/drivers/media/spi/cxd2880-spi.c
@@ -0,0 +1,727 @@
+/*
+ * cxd2880-spi.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * SPI adapter
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include 
+
+#include "dvb_demux.h"
+#include "dmxdev.h"
+#include "dvb_frontend.h"
+#include "cxd2880.h"
+
+#define CXD2880_MAX_FILTER_SIZE 32
+#define BURST_WRITE_MAX 128
+#define MAX_TRANS_PACKET 300
+
+struct cxd2880_ts_buf_info {
+   u8 read_ready;
+   u8 almost_full;
+   u8 almost_empty;
+   u8 overflow;
+   u8 underflow;
+   u16 packet_num;
+};
+
+struct cxd2880_pid_config {
+   u8 is_enable;
+   u16 pid;
+};
+
+struct cxd2880_pid_filter_config {
+   u8 is_negative;
+   struct cxd2880_pid_config pid_config[CXD2880_MAX_FILTER_SIZE];
+};
+
+struct cxd2880_dvb_spi {
+   struct dvb_frontend dvb_fe;
+   struct dvb_adapter adapter;
+   struct dvb_demux demux;
+   struct dmxdev dmxdev;
+   struct dmx_frontend dmx_fe;
+   struct task_struct *cxd2880_ts_read_thread;
+   struct spi_device *spi;
+   struct mutex spi_mutex; /* For SPI access exclusive control */
+   int feed_count;
+   int all_pid_feed_count;
+   u8 *ts_buf;
+   struct cxd2880_pid_filter_config filter_config;
+};
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static int cxd2880_write_spi(struct spi_device *spi, u8 *data, u32 size)
+{
+   struct spi_message msg;
+   struct spi_transfer tx;
+   int ret = 0;
+
+   if ((!spi) || (!data)) {
+   pr_err("%s: invalid arg\n", __func__);
+   return -EINVAL;
+   }
+
+   memset(, 0, sizeof(tx));
+   tx.tx_buf = data;
+   tx.len = size;
+
+   spi_message_init();
+   spi_message_add_tail(, );
+   ret = spi_sync(spi, );
+
+   return ret;
+}
+
+static int cxd2880_write_reg(struct spi_device *spi,
+   u8 subAddress, const u8 *data, u32 size)
+{
+   u8 send_data[BURST_WRITE_MAX +