Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-30 Thread Christopher Li
On Fri, Mar 28, 2014 at 3:50 AM, Hans Verkuil hverk...@xs4all.nl wrote:
 Is there any chance that the three issues I reported will be fixed? If not,
 then I'll work around it in the kernel code.


Most likely it is a sparse issue. Can you generate a minimal stand alone
test case that expose this bug? I try to simplify it as following, but
it does not
reproduce the error.


#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

static const char *v4l2_type_names[] = {
[1]= mmap,
[9] = userptr,
[2] = overlay,
[3] = dmabuf,
};

#define prt_names(a, arr) (((unsigned)(a))  ARRAY_SIZE(arr) ? arr[a]
: unknown)


extern void prt(const char *name);

static void v4l_print_requestbuffers(const void *arg, int write_only)
{
const struct v4l2_requestbuffers *p = arg;

prt(prt_names(3, v4l2_type_names));
}


If you have the test case, you are welcome to submit a patch to
add the test case.

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


All that glitters on your wrist

2014-03-30 Thread Linux fsdevel
Designer branded watches available at clearance prices
http://bhp-trade.home.pl/bwjobii.php



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


Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-30 Thread Hans Verkuil
Hi Chris,

On 03/30/2014 08:10 AM, Christopher Li wrote:
 On Fri, Mar 28, 2014 at 3:50 AM, Hans Verkuil hverk...@xs4all.nl wrote:
 Is there any chance that the three issues I reported will be fixed? If not,
 then I'll work around it in the kernel code.

 
 Most likely it is a sparse issue. Can you generate a minimal stand alone
 test case that expose this bug? I try to simplify it as following, but
 it does not
 reproduce the error.
 
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
 static const char *v4l2_type_names[] = {
 [1]= mmap,
 [9] = userptr,
 [2] = overlay,
 [3] = dmabuf,
 };
 
 #define prt_names(a, arr) (((unsigned)(a))  ARRAY_SIZE(arr) ? arr[a]
 : unknown)
 
 
 extern void prt(const char *name);
 
 static void v4l_print_requestbuffers(const void *arg, int write_only)
 {
 const struct v4l2_requestbuffers *p = arg;
 
 prt(prt_names(3, v4l2_type_names));
 }
 
 
 If you have the test case, you are welcome to submit a patch to
 add the test case.

I experimented a bit more and it turned out that the use of EXPORT_SYMBOL
for the array is what causes the problem. Reproducible with this:

#include linux/kernel.h

#define prt_names(a, arr) (((unsigned)(a))  ARRAY_SIZE(arr) ? arr[a] : 
unknown)

extern const char *v4l2_names[];

const char *v4l2_names[] = {
[1]= mmap,
[9] = userptr,
[2] = overlay,
[3] = dmabuf,
};
EXPORT_SYMBOL(v4l2_names);

extern void prt(const char *name);

static void v4l_print_requestbuffers(const void *arg, int write_only)
{
prt(prt_names(3, v4l2_names));
}


And with this sparse command:

sparse  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include 
-Iarch/x86/include -Iarch/x86/include/generated  -Iinclude 
-Iarch/x86/include/uapi -Iarch/x86/include/generated/uapi -Iinclude/uapi 
-Iinclude/generated/uapi -include include/linux/kconfig.h -D__KERNEL__ x.c

If I remove EXPORT_SYMBOL all is well. EXPORT_SYMBOL expands to this:

extern typeof(v4l2_names) v4l2_names;
extern __attribute__((externally_visible)) void *__crc_v4l2_names 
__attribute__((weak));
static const unsigned long __kcrctab_v4l2_names __attribute__((__used__)) 
__attribute__((section(___kcrctab  + v4l2_names), unused)) = (unsigned 
long) __crc_v4l2_names;
static const char __kstrtab_v4l2_names[] 
__attribute__((section(__ksymtab_strings), aligned(1))) = v4l2_names;
extern const struct kernel_symbol __ksymtab_v4l2_names;
__attribute__((externally_visible)) const struct kernel_symbol 
__ksymtab_v4l2_names __attribute__((__used__)) 
__attribute__((section(___ksymtab  + v4l2_names), unused)) = { 
(unsigned long)v4l2_names, __kstrtab_v4l2_names };

I did some more research and the key is the first line: 

extern typeof(v4l2_names) v4l2_names;

If I add that to your test case:

static const char *v4l2_type_names[] = {
[1]= mmap,
[9] = userptr,
[2] = overlay,
[3] = dmabuf,
};
extern typeof(v4l2_type_names) v4l2_type_names;

Then I get the same error with your test case.

The smallest test case I can make is this:

== extern-array.c ==
extern const char *v4l2_type_names[];
const char *v4l2_type_names[] = {
test
};
extern const char *v4l2_type_names[];

static void test(void)
{
unsigned sz = sizeof(v4l2_type_names);
}
/*
 * check-name: duplicate extern array
 *
 * check-error-start
 * check-error-end
 */
== extern-array.c ==

If I leave out the both 'extern' declarations I get:

warning: symbol 'v4l2_type_names' was not declared. Should it be static?

Which is a correct warning.

If I leave out the second 'extern' only, then all is fine. If I add both
'extern' declarations, then I get:

error: cannot size expression

which is clearly a sparse bug somewhere.

Regards,

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


[PATCH 1/8] libdvbv5: cleanup printing tables and descriptors

2014-03-30 Thread André Roth
- log hex values where appropriate
- cleanup indents

Signed-off-by: André Roth neol...@gmail.com
---
 lib/libdvbv5/descriptors.c |  6 +--
 lib/libdvbv5/descriptors/cat.c |  2 +-
 .../descriptors/desc_atsc_service_location.c   |  1 -
 lib/libdvbv5/descriptors/desc_ca.c |  4 +-
 lib/libdvbv5/descriptors/desc_ca_identifier.c  |  2 +-
 lib/libdvbv5/descriptors/desc_cable_delivery.c |  1 -
 lib/libdvbv5/descriptors/desc_event_extended.c |  2 +-
 lib/libdvbv5/descriptors/desc_event_short.c|  6 +--
 lib/libdvbv5/descriptors/desc_extension.c  |  2 +-
 lib/libdvbv5/descriptors/desc_frequency_list.c |  4 +-
 lib/libdvbv5/descriptors/desc_hierarchy.c  |  1 -
 lib/libdvbv5/descriptors/desc_isdbt_delivery.c |  1 -
 lib/libdvbv5/descriptors/desc_language.c   |  2 +-
 lib/libdvbv5/descriptors/desc_service.c|  7 ++--
 lib/libdvbv5/descriptors/desc_t2_delivery.c|  1 -
 .../descriptors/desc_terrestrial_delivery.c|  1 -
 lib/libdvbv5/descriptors/desc_ts_info.c|  1 -
 lib/libdvbv5/descriptors/mpeg_pes.c|  2 +-
 lib/libdvbv5/descriptors/mpeg_ts.c | 43 +++---
 lib/libdvbv5/descriptors/nit.c |  2 +-
 lib/libdvbv5/descriptors/pat.c |  4 +-
 lib/libdvbv5/descriptors/sdt.c |  6 +--
 22 files changed, 46 insertions(+), 55 deletions(-)

diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 15696f0..4694b98 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -75,8 +75,7 @@ void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, 
const struct dvb_desc
 {
if (!parms)
parms = dvb_fe_dummy();
-   dvb_log(|   %s (0x%02x), 
dvb_descriptors[desc-type].name, desc-type);
-   hexdump(parms, |   , desc-data, desc-length);
+   hexdump(parms, |   , desc-data, desc-length);
 }
 
 const struct dvb_table_init dvb_table_initializers[] = {
@@ -167,6 +166,7 @@ void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, 
struct dvb_desc *desc)
dvb_desc_print_func print = dvb_descriptors[desc-type].print;
if (!print)
print = dvb_desc_default_print;
+   dvb_log(|0x%02x: %s, desc-type, 
dvb_descriptors[desc-type].name);
print(parms, desc);
desc = desc-next;
}
@@ -1362,6 +1362,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char 
*prefix, const unsigned c
for (i = strlen(hex); i  49; i++)
strncat(spaces,  , sizeof(spaces));
ascii[j] = '\0';
-   dvb_log(%s %s %s %s, prefix, hex, spaces, ascii);
+   dvb_log(%s%s %s %s, prefix, hex, spaces, ascii);
}
 }
diff --git a/lib/libdvbv5/descriptors/cat.c b/lib/libdvbv5/descriptors/cat.c
index 4069923..20376de 100644
--- a/lib/libdvbv5/descriptors/cat.c
+++ b/lib/libdvbv5/descriptors/cat.c
@@ -65,7 +65,7 @@ void dvb_table_cat_free(struct dvb_table_cat *cat)
 
 void dvb_table_cat_print(struct dvb_v5_fe_parms *parms, struct dvb_table_cat 
*cat)
 {
-   dvb_log(cat);
+   dvb_log(CAT);
dvb_table_header_print(parms, cat-header);
dvb_print_descriptors(parms, cat-descriptor);
 }
diff --git a/lib/libdvbv5/descriptors/desc_atsc_service_location.c 
b/lib/libdvbv5/descriptors/desc_atsc_service_location.c
index 5e3f461..6da43b6 100644
--- a/lib/libdvbv5/descriptors/desc_atsc_service_location.c
+++ b/lib/libdvbv5/descriptors/desc_atsc_service_location.c
@@ -64,7 +64,6 @@ void atsc_desc_service_location_print(struct dvb_v5_fe_parms 
*parms, const struc
struct atsc_desc_service_location_elementary *el = s_loc-elementary;
int i;
 
-   dvb_log(|   service location);
dvb_log(|   pcr PID   %d, s_loc-pcr_pid);
dvb_log(|\\ elementary service - %d elementaries, 
s_loc-number_elements);
for (i = 0; i  s_loc-number_elements; i++) {
diff --git a/lib/libdvbv5/descriptors/desc_ca.c 
b/lib/libdvbv5/descriptors/desc_ca.c
index 6b48175..40edfde 100644
--- a/lib/libdvbv5/descriptors/desc_ca.c
+++ b/lib/libdvbv5/descriptors/desc_ca.c
@@ -48,8 +48,8 @@ void dvb_desc_ca_init(struct dvb_v5_fe_parms *parms, const 
uint8_t *buf, struct
 void dvb_desc_ca_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc 
*desc)
 {
const struct dvb_desc_ca *d = (const struct dvb_desc_ca *) desc;
-   dvb_log(|   ca_id %04x, d-ca_id);
-   dvb_log(|   ca_pid%04x, d-ca_pid);
+   dvb_log(|   ca_id 0x%04x, d-ca_id);
+   dvb_log(|   ca_pid0x%04x, d-ca_pid);
dvb_log(|   privdata length   %d, d-privdata_len);
if (d-privdata)
hexdump(parms, |   

[PATCH 8/8] libdvbv5: add support for tables with multiple ts_id and section gaps

2014-03-30 Thread André Roth
this restores the logic for reading tables like EIT, where the
ts_id indicates the service and the sections are incremented by 8
for example. an application might wish to read a complete EIT
containing all services. in this case the function dvb_read_sections
can be used with allow_section_gaps set to 1 in the dvb_table_filter
struct.

- make struct dvb_table_filter public
- use more generic void * for tables
- make dvb_read_sections public
- fix continuous parsing when table_length  0
- fix logging

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/dvb-scan.h |  25 -
 lib/libdvbv5/dvb-scan.c | 118 +---
 2 files changed, 86 insertions(+), 57 deletions(-)

diff --git a/lib/include/libdvbv5/dvb-scan.h b/lib/include/libdvbv5/dvb-scan.h
index 9c47c95..206d409 100644
--- a/lib/include/libdvbv5/dvb-scan.h
+++ b/lib/include/libdvbv5/dvb-scan.h
@@ -57,12 +57,33 @@ struct dvb_v5_descriptors {
unsigned num_program;
 };
 
-int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd, unsigned char 
tid, uint16_t pid, unsigned char **table,
+struct dvb_table_filter {
+   /* Input data */
+   unsigned char tid;
+   uint16_t pid;
+   int ts_id;
+   void **table;
+
+   int allow_section_gaps;
+
+   /*
+* Private temp data used by dvb_read_sections().
+* Should not be filled outside dvb-scan.c, as they'll be
+* overrided
+*/
+   void *priv;
+};
+
+int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd, unsigned char 
tid, uint16_t pid, void **table,
unsigned timeout);
 
-int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, 
unsigned char tid, uint16_t pid, int id, uint8_t **table,
+int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, 
unsigned char tid, uint16_t pid, int ts_id, void **table,
unsigned timeout);
 
+int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
+struct dvb_table_filter *sect,
+unsigned timeout);
+
 struct dvb_v5_descriptors *dvb_scan_alloc_handler_table(uint32_t 
delivery_system,
   int verbose);
 
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index d4490fb..b0636b9 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -85,7 +85,7 @@ static int poll(struct dvb_v5_fe_parms *parms, int fd, 
unsigned int seconds)
 }
 
 int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd,
-unsigned char tid, uint16_t pid, uint8_t **table,
+unsigned char tid, uint16_t pid, void **table,
 unsigned timeout)
 {
return dvb_read_section_with_id(parms, dmx_fd, tid, pid, -1, table, 
timeout);
@@ -124,86 +124,91 @@ static int is_all_bits_set(int nr, unsigned long *addr)
 }
 
 
-struct tid_pid_table_priv {
+struct dvb_table_filter_priv {
int last_section;
unsigned long is_read_bits[BITS_TO_LONGS(256)];
-   int done;
-};
-
-struct tid_pid_table {
-   /* Input data */
-   unsigned char tid;
-   uint16_t pid;
-   int ts_id;
-   uint8_t **table;
 
-   /*
-* Private temp data used by dvb_read_sections().
-* Should not be filled outside dvb-scan.c, as they'll be
-* overrided
-*/
-   void *priv;
+   /* section gaps and multiple ts_id handling */
+   ssize_t table_length;
+   int first_ts_id;
+   int first_section;
+   int done;
 };
 
 static int dvb_parse_section_alloc(struct dvb_v5_fe_parms *parms,
-  struct tid_pid_table *sect)
+  struct dvb_table_filter *sect)
 {
-   struct tid_pid_table_priv *priv;
+   struct dvb_table_filter_priv *priv;
 
if (!sect-table) {
dvb_logerr(table memory pointer not filled);
return -4;
}
*sect-table = NULL;
-   priv = calloc(sizeof(struct tid_pid_table_priv), 1);
+   priv = calloc(sizeof(struct dvb_table_filter_priv), 1);
if (!priv) {
dvb_perror(Out of memory);
return -1;
}
priv-last_section = -1;
+   priv-first_section = -1;
+   priv-first_ts_id = -1;
sect-priv = priv;
 
return 0;
 }
 
-static void dvb_parse_section_free(struct tid_pid_table *sect)
+static void dvb_parse_section_free(struct dvb_table_filter *sect)
 {
if (sect-priv)
free(sect-priv);
 }
 
 static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
-struct tid_pid_table *sect,
+struct dvb_table_filter *sect,
 uint8_t *buf, ssize_t buf_length)
 {
struct dvb_table_header *h;
-   struct tid_pid_table_priv *priv;
+   struct dvb_table_filter_priv *priv;
 

[PATCH 7/8] libdvbv5: fix lost ressource in atsc_eit

2014-03-30 Thread André Roth
if the title of the EIT event is longer than the available data,
make sure the allocated buffer is not lost

Signed-off-by: André Roth neol...@gmail.com
---
 lib/libdvbv5/descriptors/atsc_eit.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/libdvbv5/descriptors/atsc_eit.c 
b/lib/libdvbv5/descriptors/atsc_eit.c
index 92764df..9e1397d 100644
--- a/lib/libdvbv5/descriptors/atsc_eit.c
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -74,6 +74,11 @@ ssize_t atsc_table_eit_init(struct dvb_v5_fe_parms *parms, 
const uint8_t *buf,
 atsc_time(event-start_time, event-start);
event-source_id = eit-header.id;
 
+   if(!*head)
+   *head = event;
+   if(last)
+   last-next = event;
+
size = event-title_length - 1;
if (p + size  endbuf) {
dvb_logerr(%s: short read %zd/%zd bytes, __func__,
@@ -83,11 +88,6 @@ ssize_t atsc_table_eit_init(struct dvb_v5_fe_parms *parms, 
const uint8_t *buf,
 /* TODO: parse title */
 p += size;
 
-   if(!*head)
-   *head = event;
-   if(last)
-   last-next = event;
-
/* get the descriptors for each program */
size = sizeof(union atsc_table_eit_desc_length);
if (p + size  endbuf) {
-- 
1.8.3.2

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


[PATCH 5/8] libdvbv5: descriptor parser return int

2014-03-30 Thread André Roth
If parsing a descriptor fails, let the outside world know.
Returning 0 means success, negative values indicate a parsing
error.
Free allocated memory on error.

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/desc_atsc_service_location.h |  2 +-
 lib/include/libdvbv5/desc_ca.h|  2 +-
 lib/include/libdvbv5/desc_ca_identifier.h |  2 +-
 lib/include/libdvbv5/desc_cable_delivery.h|  2 +-
 lib/include/libdvbv5/desc_event_extended.h|  2 +-
 lib/include/libdvbv5/desc_event_short.h   |  2 +-
 lib/include/libdvbv5/desc_extension.h |  4 ++--
 lib/include/libdvbv5/desc_frequency_list.h|  2 +-
 lib/include/libdvbv5/desc_hierarchy.h |  2 +-
 lib/include/libdvbv5/desc_isdbt_delivery.h|  2 +-
 lib/include/libdvbv5/desc_language.h  |  2 +-
 lib/include/libdvbv5/desc_logical_channel.h   |  2 +-
 lib/include/libdvbv5/desc_network_name.h  |  2 +-
 lib/include/libdvbv5/desc_partial_reception.h |  2 +-
 lib/include/libdvbv5/desc_sat.h   |  2 +-
 lib/include/libdvbv5/desc_service.h   |  2 +-
 lib/include/libdvbv5/desc_service_list.h  |  2 +-
 lib/include/libdvbv5/desc_service_location.h  |  2 +-
 lib/include/libdvbv5/desc_t2_delivery.h   |  2 +-
 lib/include/libdvbv5/desc_terrestrial_delivery.h  |  2 +-
 lib/include/libdvbv5/desc_ts_info.h   |  2 +-
 lib/include/libdvbv5/descriptors.h|  4 ++--
 lib/libdvbv5/descriptors.c| 19 ---
 lib/libdvbv5/descriptors/desc_atsc_service_location.c |  5 +++--
 lib/libdvbv5/descriptors/desc_ca.c|  3 ++-
 lib/libdvbv5/descriptors/desc_ca_identifier.c |  5 +++--
 lib/libdvbv5/descriptors/desc_cable_delivery.c|  3 ++-
 lib/libdvbv5/descriptors/desc_event_extended.c|  3 ++-
 lib/libdvbv5/descriptors/desc_event_short.c   |  3 ++-
 lib/libdvbv5/descriptors/desc_extension.c |  9 ++---
 lib/libdvbv5/descriptors/desc_frequency_list.c|  3 ++-
 lib/libdvbv5/descriptors/desc_hierarchy.c |  3 ++-
 lib/libdvbv5/descriptors/desc_isdbt_delivery.c|  7 ---
 lib/libdvbv5/descriptors/desc_language.c  |  3 ++-
 lib/libdvbv5/descriptors/desc_logical_channel.c   |  5 +++--
 lib/libdvbv5/descriptors/desc_network_name.c  |  3 ++-
 lib/libdvbv5/descriptors/desc_partial_reception.c |  5 +++--
 lib/libdvbv5/descriptors/desc_sat.c   |  4 +++-
 lib/libdvbv5/descriptors/desc_service.c   |  3 ++-
 lib/libdvbv5/descriptors/desc_service_list.c  |  7 +--
 lib/libdvbv5/descriptors/desc_service_location.c  |  9 +
 lib/libdvbv5/descriptors/desc_t2_delivery.c   | 11 ++-
 lib/libdvbv5/descriptors/desc_terrestrial_delivery.c  |  3 ++-
 lib/libdvbv5/descriptors/desc_ts_info.c   |  3 ++-
 44 files changed, 99 insertions(+), 68 deletions(-)

diff --git a/lib/include/libdvbv5/desc_atsc_service_location.h 
b/lib/include/libdvbv5/desc_atsc_service_location.h
index ebe11b7..310efa3 100644
--- a/lib/include/libdvbv5/desc_atsc_service_location.h
+++ b/lib/include/libdvbv5/desc_atsc_service_location.h
@@ -57,7 +57,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void atsc_desc_service_location_init (struct dvb_v5_fe_parms *parms, const 
uint8_t *buf, struct dvb_desc *desc);
+int atsc_desc_service_location_init (struct dvb_v5_fe_parms *parms, const 
uint8_t *buf, struct dvb_desc *desc);
 void atsc_desc_service_location_print(struct dvb_v5_fe_parms *parms, const 
struct dvb_desc *desc);
 void atsc_desc_service_location_free(struct dvb_desc *desc);
 
diff --git a/lib/include/libdvbv5/desc_ca.h b/lib/include/libdvbv5/desc_ca.h
index 49d346b..34723d7 100644
--- a/lib/include/libdvbv5/desc_ca.h
+++ b/lib/include/libdvbv5/desc_ca.h
@@ -49,7 +49,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void dvb_desc_ca_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
struct dvb_desc *desc);
+int dvb_desc_ca_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
struct dvb_desc *desc);
 void dvb_desc_ca_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc 
*desc);
 void dvb_desc_ca_free (struct dvb_desc *desc);
 
diff --git a/lib/include/libdvbv5/desc_ca_identifier.h 
b/lib/include/libdvbv5/desc_ca_identifier.h
index 1136a84..a4b8537 100644
--- a/lib/include/libdvbv5/desc_ca_identifier.h
+++ b/lib/include/libdvbv5/desc_ca_identifier.h
@@ -41,7 +41,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void dvb_desc_ca_identifier_init (struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, struct dvb_desc *desc);
+int dvb_desc_ca_identifier_init (struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, struct dvb_desc *desc);
 void dvb_desc_ca_identifier_print(struct dvb_v5_fe_parms *parms, const 

[PATCH 6/8] libdvbv5: remove unneeded includes

2014-03-30 Thread André Roth
Signed-off-by: André Roth neol...@gmail.com
---
 lib/libdvbv5/descriptors/desc_atsc_service_location.c | 1 -
 lib/libdvbv5/descriptors/desc_ca.c| 1 -
 lib/libdvbv5/descriptors/desc_ca_identifier.c | 1 -
 lib/libdvbv5/descriptors/desc_cable_delivery.c| 1 -
 lib/libdvbv5/descriptors/desc_event_extended.c| 1 -
 lib/libdvbv5/descriptors/desc_event_short.c   | 1 -
 lib/libdvbv5/descriptors/desc_extension.c | 1 -
 lib/libdvbv5/descriptors/desc_frequency_list.c| 1 -
 lib/libdvbv5/descriptors/desc_hierarchy.c | 1 -
 lib/libdvbv5/descriptors/desc_isdbt_delivery.c| 1 -
 lib/libdvbv5/descriptors/desc_language.c  | 1 -
 lib/libdvbv5/descriptors/desc_logical_channel.c   | 1 -
 lib/libdvbv5/descriptors/desc_network_name.c  | 1 -
 lib/libdvbv5/descriptors/desc_partial_reception.c | 1 -
 lib/libdvbv5/descriptors/desc_sat.c   | 1 -
 lib/libdvbv5/descriptors/desc_service.c   | 1 -
 lib/libdvbv5/descriptors/desc_service_list.c  | 1 -
 lib/libdvbv5/descriptors/desc_t2_delivery.c   | 1 -
 lib/libdvbv5/descriptors/desc_terrestrial_delivery.c  | 1 -
 lib/libdvbv5/descriptors/desc_ts_info.c   | 1 -
 20 files changed, 20 deletions(-)

diff --git a/lib/libdvbv5/descriptors/desc_atsc_service_location.c 
b/lib/libdvbv5/descriptors/desc_atsc_service_location.c
index d47eee0..a654adc 100644
--- a/lib/libdvbv5/descriptors/desc_atsc_service_location.c
+++ b/lib/libdvbv5/descriptors/desc_atsc_service_location.c
@@ -18,7 +18,6 @@
  *
  */
 
-#include libdvbv5/descriptors.h
 #include libdvbv5/desc_atsc_service_location.h
 #include libdvbv5/dvb-fe.h
 
diff --git a/lib/libdvbv5/descriptors/desc_ca.c 
b/lib/libdvbv5/descriptors/desc_ca.c
index 01d3b8c..791bda2 100644
--- a/lib/libdvbv5/descriptors/desc_ca.c
+++ b/lib/libdvbv5/descriptors/desc_ca.c
@@ -20,7 +20,6 @@
  */
 
 #include libdvbv5/desc_ca.h
-#include libdvbv5/descriptors.h
 #include libdvbv5/dvb-fe.h
 
 int dvb_desc_ca_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct 
dvb_desc *desc)
diff --git a/lib/libdvbv5/descriptors/desc_ca_identifier.c 
b/lib/libdvbv5/descriptors/desc_ca_identifier.c
index c986ac7..3102d01 100644
--- a/lib/libdvbv5/descriptors/desc_ca_identifier.c
+++ b/lib/libdvbv5/descriptors/desc_ca_identifier.c
@@ -20,7 +20,6 @@
  */
 
 #include libdvbv5/desc_ca_identifier.h
-#include libdvbv5/descriptors.h
 #include libdvbv5/dvb-fe.h
 
 int dvb_desc_ca_identifier_init(struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, struct dvb_desc *desc)
diff --git a/lib/libdvbv5/descriptors/desc_cable_delivery.c 
b/lib/libdvbv5/descriptors/desc_cable_delivery.c
index 63583eb..2ba0ce6 100644
--- a/lib/libdvbv5/descriptors/desc_cable_delivery.c
+++ b/lib/libdvbv5/descriptors/desc_cable_delivery.c
@@ -21,7 +21,6 @@
  */
 
 #include libdvbv5/desc_cable_delivery.h
-#include libdvbv5/descriptors.h
 #include libdvbv5/dvb-fe.h
 
 int dvb_desc_cable_delivery_init(struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, struct dvb_desc *desc)
diff --git a/lib/libdvbv5/descriptors/desc_event_extended.c 
b/lib/libdvbv5/descriptors/desc_event_extended.c
index 9d7c6e3..346a71c 100644
--- a/lib/libdvbv5/descriptors/desc_event_extended.c
+++ b/lib/libdvbv5/descriptors/desc_event_extended.c
@@ -20,7 +20,6 @@
  */
 
 #include libdvbv5/desc_event_extended.h
-#include libdvbv5/descriptors.h
 #include libdvbv5/dvb-fe.h
 #include parse_string.h
 
diff --git a/lib/libdvbv5/descriptors/desc_event_short.c 
b/lib/libdvbv5/descriptors/desc_event_short.c
index d28e5f0..e9d7bd7 100644
--- a/lib/libdvbv5/descriptors/desc_event_short.c
+++ b/lib/libdvbv5/descriptors/desc_event_short.c
@@ -20,7 +20,6 @@
  */
 
 #include libdvbv5/desc_event_short.h
-#include libdvbv5/descriptors.h
 #include libdvbv5/dvb-fe.h
 #include parse_string.h
 
diff --git a/lib/libdvbv5/descriptors/desc_extension.c 
b/lib/libdvbv5/descriptors/desc_extension.c
index 91748bb..0aaeba8 100644
--- a/lib/libdvbv5/descriptors/desc_extension.c
+++ b/lib/libdvbv5/descriptors/desc_extension.c
@@ -18,7 +18,6 @@
  *
  */
 
-#include libdvbv5/descriptors.h
 #include libdvbv5/desc_extension.h
 #include libdvbv5/desc_t2_delivery.h
 #include libdvbv5/dvb-fe.h
diff --git a/lib/libdvbv5/descriptors/desc_frequency_list.c 
b/lib/libdvbv5/descriptors/desc_frequency_list.c
index 9643015..a9a3b9e 100644
--- a/lib/libdvbv5/descriptors/desc_frequency_list.c
+++ b/lib/libdvbv5/descriptors/desc_frequency_list.c
@@ -20,7 +20,6 @@
  */
 
 #include libdvbv5/desc_frequency_list.h
-#include libdvbv5/descriptors.h
 #include libdvbv5/dvb-fe.h
 
 int dvb_desc_frequency_list_init(struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, struct dvb_desc *desc)
diff --git a/lib/libdvbv5/descriptors/desc_hierarchy.c 
b/lib/libdvbv5/descriptors/desc_hierarchy.c
index 0d8ac66..17b3699 100644
--- a/lib/libdvbv5/descriptors/desc_hierarchy.c
+++ b/lib/libdvbv5/descriptors/desc_hierarchy.c
@@ -20,7 +20,6 @@
  

[PATCH 3/8] libdvbv5: make dvb_desc_default_init and dvb_desc_default_print private

2014-03-30 Thread André Roth
dvb_desc_default_init and dvb_desc_default_print are used
internaly only, remove them from the header file.
add extern C to the parser functions, so they can be used
from C++ directly.

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/descriptors.h | 16 
 lib/libdvbv5/descriptors.c |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/include/libdvbv5/descriptors.h 
b/lib/include/libdvbv5/descriptors.h
index b869a14..1ea0957 100644
--- a/lib/include/libdvbv5/descriptors.h
+++ b/lib/include/libdvbv5/descriptors.h
@@ -65,14 +65,6 @@ struct dvb_desc {
uint8_t data[];
 } __attribute__((packed));
 
-void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
struct dvb_desc *desc);
-#ifdef __cplusplus
-extern C {
-#endif
-void dvb_desc_default_print  (struct dvb_v5_fe_parms *parms, const struct 
dvb_desc *desc);
-#ifdef __cplusplus
-}
-#endif
 
 #define dvb_desc_foreach( _desc, _tbl ) \
for( struct dvb_desc *_desc = _tbl-descriptor; _desc; _desc = 
_desc-next ) \
@@ -81,6 +73,10 @@ void dvb_desc_default_print  (struct dvb_v5_fe_parms *parms, 
const struct dvb_de
for( _struct *_desc = (_struct *) _tbl-descriptor; _desc; _desc = 
(_struct *) _desc-next ) \
if(_desc-type == _type) \
 
+#ifdef __cplusplus
+extern C {
+#endif
+
 uint32_t bcd(uint32_t bcd);
 
 void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned 
char *buf, int len);
@@ -89,6 +85,10 @@ void dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, 
const uint8_t *buf, ui
 void dvb_free_descriptors(struct dvb_desc **list);
 void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, struct dvb_desc 
*desc);
 
+#ifdef __cplusplus
+}
+#endif
+
 struct dvb_v5_fe_parms;
 
 typedef void (*dvb_desc_init_func) (struct dvb_v5_fe_parms *parms, const 
uint8_t *buf, struct dvb_desc *desc);
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 4694b98..86bc7af 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -66,12 +66,12 @@ static void dvb_desc_init(uint8_t type, uint8_t length, 
struct dvb_desc *desc)
desc-next   = NULL;
 }
 
-void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
struct dvb_desc *desc)
+static void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, struct dvb_desc *desc)
 {
memcpy(desc-data, buf, desc-length);
 }
 
-void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct 
dvb_desc *desc)
+static void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct 
dvb_desc *desc)
 {
if (!parms)
parms = dvb_fe_dummy();
-- 
1.8.3.2

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


[PATCH 2/8] libdvbv5: use DVB_DESC_HEADER macro in all descriptors

2014-03-30 Thread André Roth
the first fields of a descriptor need to be the
type, length and the next pointer. in order to
prevent changing these fields by accident,
provide them in a macro.


Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/desc_atsc_service_location.h | 7 ++-
 lib/include/libdvbv5/desc_ca.h| 7 ++-
 lib/include/libdvbv5/desc_ca_identifier.h | 7 ++-
 lib/include/libdvbv5/desc_cable_delivery.h| 7 ++-
 lib/include/libdvbv5/desc_event_extended.h| 7 ++-
 lib/include/libdvbv5/desc_event_short.h   | 7 ++-
 lib/include/libdvbv5/desc_extension.h | 7 ++-
 lib/include/libdvbv5/desc_frequency_list.h| 7 ++-
 lib/include/libdvbv5/desc_hierarchy.h | 6 ++
 lib/include/libdvbv5/desc_isdbt_delivery.h| 8 +++-
 lib/include/libdvbv5/desc_language.h  | 7 ++-
 lib/include/libdvbv5/desc_logical_channel.h   | 7 ++-
 lib/include/libdvbv5/desc_network_name.h  | 7 ++-
 lib/include/libdvbv5/desc_partial_reception.h | 7 ++-
 lib/include/libdvbv5/desc_sat.h   | 7 ++-
 lib/include/libdvbv5/desc_service.h   | 7 ++-
 lib/include/libdvbv5/desc_service_list.h  | 7 ++-
 lib/include/libdvbv5/desc_service_location.h  | 6 ++
 lib/include/libdvbv5/desc_t2_delivery.h   | 5 +++--
 lib/include/libdvbv5/desc_terrestrial_delivery.h  | 7 ++-
 lib/include/libdvbv5/desc_ts_info.h   | 7 ++-
 lib/include/libdvbv5/descriptors.h| 9 ++---
 22 files changed, 50 insertions(+), 103 deletions(-)

diff --git a/lib/include/libdvbv5/desc_atsc_service_location.h 
b/lib/include/libdvbv5/desc_atsc_service_location.h
index 1ff2341..ebe11b7 100644
--- a/lib/include/libdvbv5/desc_atsc_service_location.h
+++ b/lib/include/libdvbv5/desc_atsc_service_location.h
@@ -21,8 +21,7 @@
 #ifndef _ATSC_SERVICE_LOCATION_H
 #define _ATSC_SERVICE_LOCATION_H
 
-#include stdint.h
-#include unistd.h /* ssize_t */
+#include libdvbv5/descriptors.h
 
 struct atsc_desc_service_location_elementary {
uint8_t stream_type;
@@ -37,9 +36,7 @@ struct atsc_desc_service_location_elementary {
 } __attribute__((packed));
 
 struct atsc_desc_service_location {
-   uint8_t type;
-   uint8_t length;
-   struct dvb_desc *next;
+   DVB_DESC_HEADER();
 
struct atsc_desc_service_location_elementary *elementary;
 
diff --git a/lib/include/libdvbv5/desc_ca.h b/lib/include/libdvbv5/desc_ca.h
index 12f4ff3..49d346b 100644
--- a/lib/include/libdvbv5/desc_ca.h
+++ b/lib/include/libdvbv5/desc_ca.h
@@ -22,13 +22,10 @@
 #ifndef _CA_H
 #define _CA_H
 
-#include stdint.h
-#include unistd.h /* ssize_t */
+#include libdvbv5/descriptors.h
 
 struct dvb_desc_ca {
-   uint8_t type;
-   uint8_t length;
-   struct dvb_desc *next;
+   DVB_DESC_HEADER();
 
uint16_t ca_id;
union {
diff --git a/lib/include/libdvbv5/desc_ca_identifier.h 
b/lib/include/libdvbv5/desc_ca_identifier.h
index 18df191..1136a84 100644
--- a/lib/include/libdvbv5/desc_ca_identifier.h
+++ b/lib/include/libdvbv5/desc_ca_identifier.h
@@ -22,13 +22,10 @@
 #ifndef _CA_IDENTIFIER_H
 #define _CA_IDENTIFIER_H
 
-#include stdint.h
-#include unistd.h /* ssize_t */
+#include libdvbv5/descriptors.h
 
 struct dvb_desc_ca_identifier {
-   uint8_t type;
-   uint8_t length;
-   struct dvb_desc *next;
+   DVB_DESC_HEADER();
 
uint8_t caid_count;
uint16_t *caids;
diff --git a/lib/include/libdvbv5/desc_cable_delivery.h 
b/lib/include/libdvbv5/desc_cable_delivery.h
index 7abe920..8f5355a 100644
--- a/lib/include/libdvbv5/desc_cable_delivery.h
+++ b/lib/include/libdvbv5/desc_cable_delivery.h
@@ -23,13 +23,10 @@
 #ifndef _CABLE_DELIVERY_H
 #define _CABLE_DELIVERY_H
 
-#include stdint.h
-#include unistd.h /* ssize_t */
+#include libdvbv5/descriptors.h
 
 struct dvb_desc_cable_delivery {
-   uint8_t type;
-   uint8_t length;
-   struct dvb_desc *next;
+   DVB_DESC_HEADER();
 
uint32_t frequency;
union {
diff --git a/lib/include/libdvbv5/desc_event_extended.h 
b/lib/include/libdvbv5/desc_event_extended.h
index 286f91d..b15e551 100644
--- a/lib/include/libdvbv5/desc_event_extended.h
+++ b/lib/include/libdvbv5/desc_event_extended.h
@@ -22,13 +22,10 @@
 #ifndef _DESC_EVENT_EXTENDED_H
 #define _DESC_EVENT_EXTENDED_H
 
-#include stdint.h
-#include unistd.h /* ssize_t */
+#include libdvbv5/descriptors.h
 
 struct dvb_desc_event_extended {
-   uint8_t type;
-   uint8_t length;
-   struct dvb_desc *next;
+   DVB_DESC_HEADER();
 
union {
struct {
diff --git a/lib/include/libdvbv5/desc_event_short.h 
b/lib/include/libdvbv5/desc_event_short.h
index b2c979a..836e1b6 100644
--- a/lib/include/libdvbv5/desc_event_short.h
+++ b/lib/include/libdvbv5/desc_event_short.h
@@ -22,13 +22,10 @@
 #ifndef _DESC_EVENT_SHORT_H
 #define _DESC_EVENT_SHORT_H
 

[PATCH 4/8] libdvbv5: allow table parsers to get specific pointer to table struct

2014-03-30 Thread André Roth
this will allow simplifying the parser functions and
to return the number of bytes read or an error code.

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/atsc_eit.h |  2 +-
 lib/include/libdvbv5/cat.h  |  2 +-
 lib/include/libdvbv5/descriptors.h  |  2 +-
 lib/include/libdvbv5/eit.h  |  2 +-
 lib/include/libdvbv5/mgt.h  |  2 +-
 lib/include/libdvbv5/nit.h  |  2 +-
 lib/include/libdvbv5/pat.h  |  2 +-
 lib/include/libdvbv5/pmt.h  |  2 +-
 lib/include/libdvbv5/sdt.h  |  2 +-
 lib/include/libdvbv5/vct.h  |  2 +-
 lib/libdvbv5/descriptors.c  | 24 +---
 lib/libdvbv5/descriptors/atsc_eit.c | 17 ++---
 lib/libdvbv5/descriptors/cat.c  | 14 --
 lib/libdvbv5/descriptors/eit.c  |  5 +++--
 lib/libdvbv5/descriptors/mgt.c  | 16 ++--
 lib/libdvbv5/descriptors/nit.c  | 23 ---
 lib/libdvbv5/descriptors/pat.c  | 13 +++--
 lib/libdvbv5/descriptors/pmt.c  | 10 +-
 lib/libdvbv5/descriptors/sdt.c  | 10 ++
 lib/libdvbv5/descriptors/vct.c  | 13 +++--
 20 files changed, 91 insertions(+), 74 deletions(-)

diff --git a/lib/include/libdvbv5/atsc_eit.h b/lib/include/libdvbv5/atsc_eit.h
index 0c0d830..c527b1d 100644
--- a/lib/include/libdvbv5/atsc_eit.h
+++ b/lib/include/libdvbv5/atsc_eit.h
@@ -78,7 +78,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void atsc_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, uint8_t *table, ssize_t *table_length);
+ssize_t atsc_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, ssize_t buflen, struct atsc_table_eit *eit, ssize_t *table_length);
 void atsc_table_eit_free(struct atsc_table_eit *eit);
 void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, struct atsc_table_eit 
*eit);
 void atsc_time(const uint32_t start_time, struct tm *tm);
diff --git a/lib/include/libdvbv5/cat.h b/lib/include/libdvbv5/cat.h
index 4c442a8..df1e417 100644
--- a/lib/include/libdvbv5/cat.h
+++ b/lib/include/libdvbv5/cat.h
@@ -40,7 +40,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void dvb_table_cat_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, uint8_t *table, ssize_t *table_length);
+ssize_t dvb_table_cat_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, struct dvb_table_cat *cat, ssize_t *table_length);
 void dvb_table_cat_free(struct dvb_table_cat *cat);
 void dvb_table_cat_print(struct dvb_v5_fe_parms *parms, struct dvb_table_cat 
*t);
 
diff --git a/lib/include/libdvbv5/descriptors.h 
b/lib/include/libdvbv5/descriptors.h
index 1ea0957..cc67a38 100644
--- a/lib/include/libdvbv5/descriptors.h
+++ b/lib/include/libdvbv5/descriptors.h
@@ -35,7 +35,7 @@
 
 struct dvb_v5_fe_parms;
 
-typedef void (*dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const 
uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+typedef void (*dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const 
uint8_t *buf, ssize_t buflen, void *table, ssize_t *table_length);
 
 struct dvb_table_init {
dvb_table_init_func init;
diff --git a/lib/include/libdvbv5/eit.h b/lib/include/libdvbv5/eit.h
index 62e070d..fb5ce33 100644
--- a/lib/include/libdvbv5/eit.h
+++ b/lib/include/libdvbv5/eit.h
@@ -79,7 +79,7 @@ extern const char *dvb_eit_running_status_name[8];
 extern C {
 #endif
 
-void dvb_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, uint8_t *table, ssize_t *table_length);
+ssize_t dvb_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, struct dvb_table_eit *eit, ssize_t *table_length);
 void dvb_table_eit_free(struct dvb_table_eit *eit);
 void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit 
*eit);
 void dvb_time(const uint8_t data[5], struct tm *tm);
diff --git a/lib/include/libdvbv5/mgt.h b/lib/include/libdvbv5/mgt.h
index 346cbb5..4ea905d 100644
--- a/lib/include/libdvbv5/mgt.h
+++ b/lib/include/libdvbv5/mgt.h
@@ -68,7 +68,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, uint8_t *table, ssize_t *table_length);
+ssize_t atsc_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t 
*buf, ssize_t buflen, struct atsc_table_mgt *mgt, ssize_t *table_length);
 void atsc_table_mgt_free(struct atsc_table_mgt *mgt);
 void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt 
*mgt);
 
diff --git a/lib/include/libdvbv5/nit.h b/lib/include/libdvbv5/nit.h
index af57931..7477bd6 100644
--- a/lib/include/libdvbv5/nit.h
+++ b/lib/include/libdvbv5/nit.h
@@ -85,7 +85,7 @@ struct dvb_v5_fe_parms;
 extern C {
 #endif
 
-void dvb_table_nit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
ssize_t buflen, uint8_t *table, ssize_t *table_length);
+ssize_t dvb_table_nit_init 

No channels on Hauppauge 950Q

2014-03-30 Thread Sunset Machine
Today is March 30, 2014

The 950Q is a USB TV Stick. The driver loads, the firmware loads.
Various software sees the device but none of them find any channels. I
use an antenna for over-the-air HD television in the US. The device
works on Windows but not Linux (Debian 7.3, Squeeze).

I'm not a subscriber (dialup). Please CC me. Thank you!
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-30 Thread Linus Torvalds
On Sun, Mar 30, 2014 at 5:03 AM, Hans Verkuil hverk...@xs4all.nl wrote:

 which is clearly a sparse bug somewhere.

Yes. What is going on is that we create separate symbols for each
declaration, and we tie them all together (and warn if they have
conflicting types).

But then when we look up a symbol, we only look at the latest one, so
when we size the array, we look at that extern declaration, and
don't see the size that was created with the initializer.

I'll think about how to fix it cleanly. Expect a patch shortly.

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


Re: No channels on Hauppauge 950Q

2014-03-30 Thread Devin Heitmueller
On Sun, Mar 30, 2014 at 12:25 PM, Sunset Machine
sunsetmachi...@gmail.com wrote:
 Today is March 30, 2014

 The 950Q is a USB TV Stick. The driver loads, the firmware loads.
 Various software sees the device but none of them find any channels. I
 use an antenna for over-the-air HD television in the US. The device
 works on Windows but not Linux (Debian 7.3, Squeeze).

What kernel version are you using?  What applications have you tested
with?  If you have a relatively recent version of the HVR-950q stick
with a kernel older than 3.7, then you are likely to have issues with
not having some required driver updates for the new tuner chip inside
the unit.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-30 Thread Hans Verkuil
On 03/30/2014 06:48 PM, Linus Torvalds wrote:
 On Sun, Mar 30, 2014 at 5:03 AM, Hans Verkuil hverk...@xs4all.nl wrote:

 which is clearly a sparse bug somewhere.
 
 Yes. What is going on is that we create separate symbols for each
 declaration, and we tie them all together (and warn if they have
 conflicting types).
 
 But then when we look up a symbol, we only look at the latest one, so
 when we size the array, we look at that extern declaration, and
 don't see the size that was created with the initializer.
 
 I'll think about how to fix it cleanly. Expect a patch shortly.

Great!

Tomorrow I'll try to write test cases for the two other sparse problems
I found.

Regards,

Hans

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


Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-30 Thread Christopher Li
On Sun, Mar 30, 2014 at 9:48 AM, Linus Torvalds
torva...@linux-foundation.org wrote:
 But then when we look up a symbol, we only look at the latest one, so
 when we size the array, we look at that extern declaration, and
 don't see the size that was created with the initializer.

Exactly. Sparse need to handle merging of incremental type declare.
This is a long known sparse bug.


 I'll think about how to fix it cleanly. Expect a patch shortly.

Wow, cool. I want to mention one special case of the type merging.
It has some thing to do with scoping as well. When the scope ends,
the incremental type added inside the scope will need to strip away
as well. So it can not be blindly add to the original type without consider
how to take that layer away later.

This should be very exciting. Looking forward to the patch.

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


Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-30 Thread Linus Torvalds
On Sun, Mar 30, 2014 at 9:48 AM, Linus Torvalds
torva...@linux-foundation.org wrote:

 I'll think about how to fix it cleanly. Expect a patch shortly.

Ok, patch sent to linux-sparse mailing list. It fixes the particular
cut-down test-case and seems pretty simple and straightforward, but is
otherwise entirely untested, so who the hell knows..

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


em28xx_dvb.c errors

2014-03-30 Thread Chris Lee
I saw a previous email showing the error's but no patch, maybe there
was one but I didnt see it on my end.

It looks like a previous patch was applied wrong? not sure.

Chris


em28xx_dvb.c.patch
Description: Binary data


Re: lmedm04 NEC scancode question

2014-03-30 Thread Malcolm Priestley

On 28/03/14 00:38, David Härdeman wrote:

Hi Malcolm,


Hi David



I'm trying to make sure that the extended NEC parsing is consistent
across drivers and I have a question regarding
drivers/media/usb/dvb-usb-v2/lmedm04.c

In commit 616a4b83 you changed the scancode from something like this:

ibuf[2]  24 | ibuf[3]  16 | ibuf[4]  8 | ibuf[5]

into:

if ((ibuf[4] + ibuf[5]) == 0xff) {
key = ibuf[5];
key += (ibuf[3]  0)
? (ibuf[3] ^ 0xff)  8 : 0;
key += (ibuf[2] ^ 0xff)  16;

which can be written as:

(ibuf[2] ^ 0xff)  16 |
(ibuf[3]  0) ? (ibuf[3] ^ 0xff)  8 : 0 |
ibuf[5]

At the same time the keymap was changed from (one example from each
type):

0xef12ba45 = KEY_0
0xff40ea15 = KEY_0
0xff00e31c = KEY_0

These original key maps need to restored for 32 bit.



into:

0x10ed45   = KEY_0 (0x10ed = ~0xef12; 0x45 = ~0xba)
0xbf15 = KEY_0 (0xbf = 0x00bf = ~0xff40; 0x15 = ~0xea)
0x1c   = KEY_0 (0x1c = 0x001c; this is a NEC16 coding?)


Bits 8~23 are inverted on the key map because they are shifted  8.


Bits 8~15 are removed from the scan code.


I am assuming (given the ^ 0xff) that the hardware sends inverted bytes?
And that the reason ibuf[5] does not need ^ 0xff is that it already is
the inverted command (i.e. ibuf[5] == ~ibuf[4]).

To put it differently:

 ibuf[2] = ~addr = not_addr;
 ibuf[3] = ~not_addr = addr;
 ibuf[4] = ~cmd  = not_cmd;
 ibuf[5] = ~not_cmd  = cmd;

And the scancode can then be understood as:

addr  16 | not_addr  8 | cmd

Except for when addr = 0x00 in which case the scancode is simply NEC16:

0x00  8 | cmd

Is my interpretation correct?


No inverting.

At the time of the patch I couldn't get the 32 bit code to work 
correctly on rc_core so it was assumed to be 24 bit.


I have tested the patch series...

Is there a patch missing?  I get build error from ati_remote.c and
imon.c

error: too few arguments to function 'rc_g_keycode_from_table'

Anyway, I removed the errors.

Just needs the inverting removed and the original 32 bit key maps to work.

Regards


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


Re: No channels on Hauppauge 950Q

2014-03-30 Thread Sunset Machine
On 3/30/14, Devin Heitmueller dheitmuel...@kernellabs.com wrote:
 On Sun, Mar 30, 2014 at 12:25 PM, Sunset Machine
 sunsetmachi...@gmail.com wrote:
 Today is March 30, 2014

 The 950Q is a USB TV Stick. The driver loads, the firmware loads.
 Various software sees the device but none of them find any channels. I
 use an antenna for over-the-air HD television in the US. The device
 works on Windows but not Linux (Debian 7.3, Squeeze).

 What kernel version are you using?  What applications have you tested
 with?  If you have a relatively recent version of the HVR-950q stick
 with a kernel older than 3.7, then you are likely to have issues with
 not having some required driver updates for the new tuner chip inside
 the unit.

 Devin

 --
 Devin J. Heitmueller - Kernel Labs
 http://www.kernellabs.com


kernel 3.2.0-4-686-pae and a new 950q

3.13-1-686-pae is available in Debian testing.  I'll look into it.

TVTime, MythTV, Mplayer, Kaffeine, and w_scan. scan would oddly
leave the green signal light on when the program finished, as if it
were tuned, but reporting 0 channels found.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: No channels on Hauppauge 950Q

2014-03-30 Thread Devin Heitmueller
On Sun, Mar 30, 2014 at 3:16 PM, Sunset Machine
sunsetmachi...@gmail.com wrote:
 kernel 3.2.0-4-686-pae and a new 950q

Ok.  If you own a Revision E1H3 device, then that kernel definitely
won't work (the Rev is printed on the back of the stick above the
barcode).

 3.13-1-686-pae is available in Debian testing.  I'll look into it.

 TVTime, MythTV, Mplayer, Kaffeine, and w_scan. scan would oddly
 leave the green signal light on when the program finished, as if it
 were tuned, but reporting 0 channels found.

Well TVTime won't do OTA broadcasts since it's digital only.  That
said, the others should assuming you configured them properly.

Definitely check the stick revision and try a much newer kernel.
There have been a ton of fixes since 3.2 so it isn't worth even trying
to debug on that kernel.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: em28xx_dvb.c errors

2014-03-30 Thread Hans Verkuil
On 03/30/2014 07:42 PM, Chris Lee wrote:
 I saw a previous email showing the error's but no patch, maybe there
 was one but I didnt see it on my end.

The patch is here:

https://patchwork.linuxtv.org/patch/23278/

 
 It looks like a previous patch was applied wrong? not sure.

Yeah, it was.

Regards,

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


Re: lmedm04 NEC scancode question

2014-03-30 Thread David Härdeman
On Sun, Mar 30, 2014 at 07:18:20PM +0100, Malcolm Priestley wrote:
On 28/03/14 00:38, David Härdeman wrote:
I'm trying to make sure that the extended NEC parsing is consistent
across drivers and I have a question regarding
drivers/media/usb/dvb-usb-v2/lmedm04.c

In commit 616a4b83 you changed the scancode from something like this:

  ibuf[2]  24 | ibuf[3]  16 | ibuf[4]  8 | ibuf[5]

into:

  if ((ibuf[4] + ibuf[5]) == 0xff) {
  key = ibuf[5];
  key += (ibuf[3]  0)
  ? (ibuf[3] ^ 0xff)  8 : 0;
  key += (ibuf[2] ^ 0xff)  16;

which can be written as:

  (ibuf[2] ^ 0xff)  16 |
  (ibuf[3]  0) ? (ibuf[3] ^ 0xff)  8 : 0 |
  ibuf[5]

At the same time the keymap was changed from (one example from each
type):

  0xef12ba45 = KEY_0
  0xff40ea15 = KEY_0
  0xff00e31c = KEY_0
These original key maps need to restored for 32 bit.

With my patch series, NEC16 keymaps are still ok, they'll get
automagically translated to their NEC32 counterparts when they are
loaded into the in-memory scancode table (by treating any scancode =
0x as NEC16, scancode = 0xff as NECX and scancodes = 0xff
as NEC32).

For example, a keymap with a scancode of 0x1122 is interpreted as a
NEC16 scancode with 0x11 as the address and 0x22 as the command, which
will be stored in the in-memory table as 0x11ee22dd (NEC16 is 0xAACC and
translated into 0xAAÂÂCCĈĈ as NEC32).

into:

  0x10ed45   = KEY_0 (0x10ed = ~0xef12; 0x45 = ~0xba)
  0xbf15 = KEY_0 (0xbf = 0x00bf = ~0xff40; 0x15 = ~0xea)
  0x1c   = KEY_0 (0x1c = 0x001c; this is a NEC16 coding?)

Bits 8~23 are inverted on the key map because they are shifted  8.

Bits 8~15 are removed from the scan code.

Not sure I follow. Bytes 2 and 4 are usually inverted in NEC (if it's
the oldschool NEC16 protocol), why would bits 8-23 be inverted?

I am assuming (given the ^ 0xff) that the hardware sends inverted bytes?
And that the reason ibuf[5] does not need ^ 0xff is that it already is
the inverted command (i.e. ibuf[5] == ~ibuf[4]).

To put it differently:

 ibuf[2] = ~addr = not_addr;
 ibuf[3] = ~not_addr = addr;
 ibuf[4] = ~cmd  = not_cmd;
 ibuf[5] = ~not_cmd  = cmd;

And the scancode can then be understood as:

  addr  16 | not_addr  8 | cmd

Except for when addr = 0x00 in which case the scancode is simply NEC16:

  0x00  8 | cmd

Is my interpretation correct?

No inverting.

At the time of the patch I couldn't get the 32 bit code to work correctly on
rc_core so it was assumed to be 24 bit.

I have tested the patch series...

Is there a patch missing?  I get build error from ati_remote.c and
imon.c

Mea culpa, I used a .config with some drivers disabled, I've regenerated
the patch series to take ati_remote.c and imon.c into account as well,
I'll post a new patch series as soon as I've understood the lmedm04.c
scancode parsing...

error: too few arguments to function 'rc_g_keycode_from_table'

Anyway, I removed the errors.

For your testing purposes you could just disable those two drivers.

Just needs the inverting removed and the original 32 bit key maps to work.

I'd prefer to have the scancode entries that are NEC16 in NEC16 notation
if possible.

If I understand you correctly, ibuf[2] - ibuf[5] corresponds to bytes 1
- 4 of the 32 bit NEC scancode without any inversion/conversion, right?

If so, the scancodes would be for example:

Type1: 0xef12ba45 - NECX with addr 0xef12 and cmd 0x45 = 0xef1245

Type2: 0xff40ea15 - NECX with addr 0xff40 and cmd 0x15 = 0xff4015

Type3: 0xff00e31c - NEC16 with addr 0xff and cmd 0x1c = 0xff1c
(is that really addr 0xff and not 0x00? if it is 0x00, then that would
indicate a different byte order than simply ibuf[2] to ibuf[5]?)

Thanks for your input.

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


Re: [PATCH 5/5] rcar_vin: add devicetree support

2014-03-30 Thread Guennadi Liakhovetski
Hi Ben,

Since I never received a reply to this my query, I consider this your 
patch series suspended.

Thanks
Guennadi

On Sat, 8 Mar 2014, Guennadi Liakhovetski wrote:

 Hi Ben,
 
 On Fri, 7 Mar 2014, Ben Dooks wrote:
 
  Add support for devicetree probe for the rcar-vin
  driver.
 
 Thanks for the patch. I'm afraid I don't quite understand how it is 
 supposed to work though. AFAICS, the rcar_vin driver currently doesn't 
 support asynchronous probing, so, your code is relying on a specific 
 probing order? Besides, as of now soc-camera doesn't support OF probing. 
 You mentioned, that you have a patch for soc-camera to add OF support. I 
 think that and async probing for rcar_vin should be committed before this 
 patch becomes meaningful.

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks

On 30/03/14 22:04, Guennadi Liakhovetski wrote:

Hi Ben,

Since I never received a reply to this my query, I consider this your
patch series suspended.

Thanks
Guennadi


I meant to send out a patch series for the of probe for soc_camera.
The actual rcar_vin does not need much to support async probe, it is
just the soc_camera that needs sorting.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] rcar_vin: add devicetree support

2014-03-30 Thread Guennadi Liakhovetski
On Sun, 30 Mar 2014, Ben Dooks wrote:

 On 30/03/14 22:04, Guennadi Liakhovetski wrote:
  Hi Ben,
  
  Since I never received a reply to this my query, I consider this your
  patch series suspended.
  
  Thanks
  Guennadi
 
 I meant to send out a patch series for the of probe for soc_camera.
 The actual rcar_vin does not need much to support async probe, it is
 just the soc_camera that needs sorting.

But without that soc-camera DT support your patches are non-functional, 
right?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/3] [media] atmel-isi: add primary DT support

2014-03-30 Thread Guennadi Liakhovetski
Hi Josh,

Please correct me if I'm wrong, but I don't see how this is going to work 
without the central part - building asynchronous V4L2 data structures from 
the DT, something that your earlier patch media: soc-camera: OF cameras 
was doing, but which you stopped developing after a discussion with Ben 
(added to Cc).

Thanks
Guennadi

On Tue, 25 Mar 2014, Josh Wu wrote:

 This patch add the DT support for Atmel ISI driver.
 It use the same v4l2 DT interface that defined in video-interfaces.txt.
 
 Signed-off-by: Josh Wu josh...@atmel.com
 Cc: devicet...@vger.kernel.org
 ---
 v1 -- v2:
  refine the binding document.
  add port node description.
  removed the optional property.
 
  .../devicetree/bindings/media/atmel-isi.txt|   50 
 
  drivers/media/platform/soc_camera/atmel-isi.c  |   31 +++-
  2 files changed, 79 insertions(+), 2 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/media/atmel-isi.txt
 
 diff --git a/Documentation/devicetree/bindings/media/atmel-isi.txt 
 b/Documentation/devicetree/bindings/media/atmel-isi.txt
 new file mode 100644
 index 000..11c98ee
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/atmel-isi.txt
 @@ -0,0 +1,50 @@
 +Atmel Image Sensor Interface (ISI) SoC Camera Subsystem
 +--
 +
 +Required properties:
 +- compatible: must be atmel,at91sam9g45-isi
 +- reg: physical base address and length of the registers set for the device;
 +- interrupts: should contain IRQ line for the ISI;
 +- clocks: list of clock specifiers, corresponding to entries in
 +  the clock-names property;
 +- clock-names: must contain isi_clk, which is the isi peripherial clock.
 +
 +ISI supports a single port node with parallel bus. It should contain one
 +'port' child node with child 'endpoint' node. Please refer to the bindings
 +defined in Documentation/devicetree/bindings/media/video-interfaces.txt.
 +
 +Example:
 + isi: isi@f0034000 {
 + compatible = atmel,at91sam9g45-isi;
 + reg = 0xf0034000 0x4000;
 + interrupts = 37 IRQ_TYPE_LEVEL_HIGH 5;
 +
 + clocks = isi_clk;
 + clock-names = isi_clk;
 +
 + pinctrl-names = default;
 + pinctrl-0 = pinctrl_isi;
 +
 + port {
 + #address-cells = 1;
 + #size-cells = 0;
 +
 + isi_0: endpoint {
 + remote-endpoint = ov2640_0;
 + };
 + };
 + };
 +
 + i2c1: i2c@f0018000 {
 + ov2640: camera@0x30 {
 + compatible = omnivision,ov2640;
 + reg = 0x30;
 +
 + port {
 + ov2640_0: endpoint {
 + remote-endpoint = isi_0;
 + bus-width = 8;
 + };
 + };
 + };
 + };
 diff --git a/drivers/media/platform/soc_camera/atmel-isi.c 
 b/drivers/media/platform/soc_camera/atmel-isi.c
 index f4add0a..d6a1f7b 100644
 --- a/drivers/media/platform/soc_camera/atmel-isi.c
 +++ b/drivers/media/platform/soc_camera/atmel-isi.c
 @@ -19,6 +19,7 @@
  #include linux/interrupt.h
  #include linux/kernel.h
  #include linux/module.h
 +#include linux/of.h
  #include linux/platform_device.h
  #include linux/slab.h
  
 @@ -33,6 +34,7 @@
  #define VID_LIMIT_BYTES  (16 * 1024 * 1024)
  #define MIN_FRAME_RATE   15
  #define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE)
 +#define ISI_DEFAULT_MCLK_FREQ2500
  
  /* Frame buffer descriptor */
  struct fbd {
 @@ -885,6 +887,20 @@ static int atmel_isi_remove(struct platform_device *pdev)
   return 0;
  }
  
 +static int atmel_isi_probe_dt(struct atmel_isi *isi,
 + struct platform_device *pdev)
 +{
 + struct device_node *node = pdev-dev.of_node;
 +
 + /* Default settings for ISI */
 + isi-pdata.full_mode = 1;
 + isi-pdata.mck_hz = ISI_DEFAULT_MCLK_FREQ;
 + isi-pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
 + isi-pdata.data_width_flags = ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10;
 +
 + return 0;
 +}
 +
  static int atmel_isi_probe(struct platform_device *pdev)
  {
   unsigned int irq;
 @@ -896,7 +912,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
   struct isi_platform_data *pdata;
  
   pdata = dev-platform_data;
 - if (!pdata || !pdata-data_width_flags) {
 + if ((!pdata || !pdata-data_width_flags)  !pdev-dev.of_node) {
   dev_err(pdev-dev,
   No config available for Atmel ISI\n);
   return -EINVAL;
 @@ -912,7 +928,11 @@ static int atmel_isi_probe(struct platform_device *pdev)
   if (IS_ERR(isi-pclk))
   return PTR_ERR(isi-pclk);
  
 - memcpy(isi-pdata, pdata, sizeof(struct isi_platform_data));

[RFC 1/3] rcar_vin: copy flags from pdata

2014-03-30 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

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


[RFC 3/3] soc_camera: initial of code

2014-03-30 Thread Ben Dooks
Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c | 111 -
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 4b8c024..afe22d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
+#include media/v4l2-of.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
 
@@ -1579,6 +1580,112 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)   do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_camera_async_subdev *sasd;
+   struct v4l2_async_subdev **asd_array;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* alloacte a new subdev and add match info to it */
+   sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+   if (!sasd)
+   return -ENOMEM;
+
+   asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+sizeof(struct v4l2_async_subdev **),
+GFP_KERNEL);
+   if (!asd_array)
+   return -ENOMEM;
+
+   sasd-asd.match.of.node = remote;
+   sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+   asd_array[0] = sasd-asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   return ret;
+
+   sasc-sensor = sasd-asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   platform_device_put(sasc-pdev);
+   return -ENOMEM;
+   }
+
+   //sasc-notifier.subdevs = asd;
+   sasc-notifier.subdevs = asd_array;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));
+
+   icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name, mclk, 
icd);
+   if (IS_ERR(icd-clk)) {
+   ret = PTR_ERR(icd-clk);
+   goto eclkreg;
+   }
+
+   ret = v4l2_async_notifier_register(ici-v4l2_dev, sasc-notifier);
+   if (!ret)
+   return 0;
+
+eclkreg:
+   icd-clk = NULL;
+   platform_device_unregister(sasc-pdev);
+   dev_err(ici-v4l2_dev.dev, group probe failed: %d\n, ret);
+
+   return ret;
+}
+
+static inline void scan_of_host(struct soc_camera_host *ici)
+{
+   struct device_node *np = ici-v4l2_dev.dev-of_node;
+   struct device_node *epn = NULL;
+   struct device_node *ren;
+
+   while (true) {
+   epn = v4l2_of_get_next_endpoint(np, epn);
+   if (!epn)
+   break;
+
+   ren = v4l2_of_get_remote_port(epn);
+   if (!ren) {
+   pr_info(%s: no remote for %s\n,
+   __func__,  of_node_full_name(epn));
+   continue;
+   }
+
+   /* so we now have a remote node to connect */
+   soc_of_bind(ici, epn, ren-parent);
+   }
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
struct soc_camera_device *icd)
@@ -1830,7 +1937,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
mutex_init(ici-host_lock);
mutex_init(ici-clk_lock);
 
-   if (ici-asd_sizes)
+   if (ici-v4l2_dev.dev-of_node)
+   scan_of_host(ici);
+   else if (ici-asd_sizes)
/*
 * No OF, host with a list of subdevices. Don't try to mix

[RFC 2/3] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 .../devicetree/bindings/media/rcar_vin.txt | 79 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 67 --
 2 files changed, 140 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..105b8de
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,79 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180: adv7180@0x20 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180_1: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180_1;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 47516df..73c56c7 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1392,6 +1395,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1404,15 +1418,50 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata;
+   unsigned int pdata_flags;
int irq, ret;
 
-   pdata = pdev-dev.platform_data;
-   if (!pdata || !pdata-flags) {
-   dev_err(pdev-dev, platform data not set\n);
-   return -EINVAL;
+   if (pdev-dev.of_node) {
+   struct v4l2_of_endpoint ep;
+   

Re: [PATCH 5/5] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks

On 30/03/14 22:17, Guennadi Liakhovetski wrote:

On Sun, 30 Mar 2014, Ben Dooks wrote:


On 30/03/14 22:04, Guennadi Liakhovetski wrote:

Hi Ben,

Since I never received a reply to this my query, I consider this your
patch series suspended.

Thanks
Guennadi


I meant to send out a patch series for the of probe for soc_camera.
The actual rcar_vin does not need much to support async probe, it is
just the soc_camera that needs sorting.


But without that soc-camera DT support your patches are non-functional,
right?


They're not much use. I've sent the soc-camera patch out now for
review. I will sort out sending patches for the async device changes
for the device(s) on the lager board as soon as I can get some time
to re-test.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 2/3] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks

On 30/03/14 22:26, Ben Dooks wrote:

Add support for devicetree probe for the rcar-vin
driver.


Sorry, this was an older branch and needed
a fix for the pdev-id field.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2] rcar_vin: copy flags from pdata

2014-03-30 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

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


[RFCv3 1/3] rcar_vin: copy flags from pdata

2014-03-30 Thread Ben Dooks
The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 702dc47..47516df 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
int sequence;
/* State of the VIN module in capturing mode */
enum rcar_vin_state state;
-   struct rcar_vin_platform_data   *pdata;
struct soc_camera_host  ici;
struct list_headcapture;
 #define MAX_BUFFER_NUM 3
struct vb2_buffer   *queue_buf[MAX_BUFFER_NUM];
struct vb2_alloc_ctx*alloc_ctx;
enum v4l2_field field;
+   unsigned intpdata_flags;
unsigned intvb_count;
unsigned intnr_hw_slots;
boolrequest_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
break;
case V4L2_MBUS_FMT_YUYV8_2X8:
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
break;
case V4L2_MBUS_FMT_YUYV10_2X10:
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-   vnmc |= priv-pdata-flags  RCAR_VIN_BT656 ?
+   vnmc |= priv-pdata_flags  RCAR_VIN_BT656 ?
VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
break;
default:
@@ -799,7 +799,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
/* Make choises, based on platform preferences */
if ((common_flags  V4L2_MBUS_HSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_HSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -807,7 +807,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device 
*icd)
 
if ((common_flags  V4L2_MBUS_VSYNC_ACTIVE_HIGH) 
(common_flags  V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-   if (priv-pdata-flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
+   if (priv-pdata_flags  RCAR_VIN_VSYNC_ACTIVE_LOW)
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
else
common_flags = ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1447,7 +1447,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
priv-ici.drv_name = dev_name(pdev-dev);
priv-ici.ops = rcar_vin_host_ops;
 
-   priv-pdata = pdata;
+   priv-pdata_flags = pdata-flags;
priv-chip = pdev-id_entry-driver_data;
spin_lock_init(priv-lock);
INIT_LIST_HEAD(priv-capture);
-- 
1.9.0

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


[RFCv3 3/3] soc_camera: initial of code

2014-03-30 Thread Ben Dooks
Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
 drivers/media/platform/soc_camera/soc_camera.c | 111 -
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c 
b/drivers/media/platform/soc_camera/soc_camera.c
index 4b8c024..afe22d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include media/v4l2-common.h
 #include media/v4l2-ioctl.h
 #include media/v4l2-dev.h
+#include media/v4l2-of.h
 #include media/videobuf-core.h
 #include media/videobuf2-core.h
 
@@ -1579,6 +1580,112 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)   do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+static int soc_of_bind(struct soc_camera_host *ici,
+  struct device_node *ep,
+  struct device_node *remote)
+{
+   struct soc_camera_device *icd;
+   struct soc_camera_desc sdesc = {.host_desc.bus_id = ici-nr,};
+   struct soc_camera_async_client *sasc;
+   struct soc_camera_async_subdev *sasd;
+   struct v4l2_async_subdev **asd_array;
+   char clk_name[V4L2_SUBDEV_NAME_SIZE];
+   int ret;
+
+   /* alloacte a new subdev and add match info to it */
+   sasd = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasd), GFP_KERNEL);
+   if (!sasd)
+   return -ENOMEM;
+
+   asd_array = devm_kzalloc(ici-v4l2_dev.dev,
+sizeof(struct v4l2_async_subdev **),
+GFP_KERNEL);
+   if (!asd_array)
+   return -ENOMEM;
+
+   sasd-asd.match.of.node = remote;
+   sasd-asd.match_type = V4L2_ASYNC_MATCH_OF;
+   asd_array[0] = sasd-asd;
+
+   /* Or shall this be managed by the soc-camera device? */
+   sasc = devm_kzalloc(ici-v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+   if (!sasc)
+   return -ENOMEM;
+
+   /* HACK: just need a != NULL */
+   sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+   ret = soc_camera_dyn_pdev(sdesc, sasc);
+   if (ret  0)
+   return ret;
+
+   sasc-sensor = sasd-asd;
+
+   icd = soc_camera_add_pdev(sasc);
+   if (!icd) {
+   platform_device_put(sasc-pdev);
+   return -ENOMEM;
+   }
+
+   //sasc-notifier.subdevs = asd;
+   sasc-notifier.subdevs = asd_array;
+   sasc-notifier.num_subdevs = 1;
+   sasc-notifier.bound = soc_camera_async_bound;
+   sasc-notifier.unbind = soc_camera_async_unbind;
+   sasc-notifier.complete = soc_camera_async_complete;
+
+   icd-sasc = sasc;
+   icd-parent = ici-v4l2_dev.dev;
+
+   snprintf(clk_name, sizeof(clk_name), of-%s,
+of_node_full_name(remote));
+
+   icd-clk = v4l2_clk_register(soc_camera_clk_ops, clk_name, mclk, 
icd);
+   if (IS_ERR(icd-clk)) {
+   ret = PTR_ERR(icd-clk);
+   goto eclkreg;
+   }
+
+   ret = v4l2_async_notifier_register(ici-v4l2_dev, sasc-notifier);
+   if (!ret)
+   return 0;
+
+eclkreg:
+   icd-clk = NULL;
+   platform_device_unregister(sasc-pdev);
+   dev_err(ici-v4l2_dev.dev, group probe failed: %d\n, ret);
+
+   return ret;
+}
+
+static inline void scan_of_host(struct soc_camera_host *ici)
+{
+   struct device_node *np = ici-v4l2_dev.dev-of_node;
+   struct device_node *epn = NULL;
+   struct device_node *ren;
+
+   while (true) {
+   epn = v4l2_of_get_next_endpoint(np, epn);
+   if (!epn)
+   break;
+
+   ren = v4l2_of_get_remote_port(epn);
+   if (!ren) {
+   pr_info(%s: no remote for %s\n,
+   __func__,  of_node_full_name(epn));
+   continue;
+   }
+
+   /* so we now have a remote node to connect */
+   soc_of_bind(ici, epn, ren-parent);
+   }
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
struct soc_camera_device *icd)
@@ -1830,7 +1937,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
mutex_init(ici-host_lock);
mutex_init(ici-clk_lock);
 
-   if (ici-asd_sizes)
+   if (ici-v4l2_dev.dev-of_node)
+   scan_of_host(ici);
+   else if (ici-asd_sizes)
/*
 * No OF, host with a list of subdevices. Don't try to mix

[RFCv3 2/3] rcar_vin: add devicetree support

2014-03-30 Thread Ben Dooks
Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks ben.do...@codethink.co.uk
---
Changes since v1:
- fix pdev-id handling via usage of alias property
Changes since v2:
- fix documentation for v1 updates
---
 .../devicetree/bindings/media/rcar_vin.txt | 86 ++
 drivers/media/platform/soc_camera/rcar_vin.c   | 70 --
 2 files changed, 149 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 000..5463615
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+--
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - renesas,vin-r8a7791 for the R8A7791 device
+   - renesas,vin-r8a7790 for the R8A7790 device
+   - renesas,vin-r8a7779 for the R8A7779 device
+   - renesas,vin-r8a7778 for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+---
+
+   aliases {
+  vin0 = vin0;
+   };
+
+vin0: vin@0xe6ef {
+compatible = renesas,vin-r8a7790;
+clocks = mstp8_clks R8A7790_CLK_VIN0;
+reg = 0 0xe6ef 0 0x1000;
+interrupts = 0 188 IRQ_TYPE_LEVEL_HIGH;
+status = disabled;
+};
+
+Board setup example (vin1 composite video input)
+
+
+i2c2   {
+status = ok;
+pinctrl-0 = i2c2_pins;
+pinctrl-names = default;
+
+adv7180: adv7180@0x20 {
+compatible = adi,adv7180;
+reg = 0x20;
+remote = vin1;
+
+port {
+adv7180_1: endpoint {
+bus-width = 8;
+remote-endpoint = vin1ep0;
+};
+};
+};
+};
+
+/* composite video input */
+vin1 {
+pinctrl-0 = vin1_pins;
+pinctrl-names = default;
+
+status = ok;
+
+port {
+#address-cells = 1;
+#size-cells = 0;
+
+vin1ep0: endpoint {
+remote-endpoint = adv7180_1;
+bus-width = 8;
+};
+};
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 47516df..72d2504 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include linux/pm_runtime.h
 #include linux/slab.h
 #include linux/videodev2.h
+#include linux/of.h
+#include linux/of_device.h
 
 #include media/soc_camera.h
 #include media/soc_mediabus.h
@@ -32,6 +34,7 @@
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/v4l2-subdev.h
+#include media/v4l2-of.h
 #include media/videobuf2-dma-contig.h
 
 #include soc_scale_crop.h
@@ -1392,6 +1395,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
.init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+   { .compatible = renesas,vin-r8a7791, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7790, .data = (void *)RCAR_GEN2 },
+   { .compatible = renesas,vin-r8a7779, .data = (void *)RCAR_H1 },
+   { .compatible = renesas,vin-r8a7778, .data = (void *)RCAR_M1 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
{ r8a7791-vin,  RCAR_GEN2 },
{ r8a7790-vin,  RCAR_GEN2 },
@@ -1404,15 +1418,50 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+   const struct of_device_id *match = NULL;
struct rcar_vin_priv *priv;
struct resource *mem;
struct rcar_vin_platform_data *pdata;
+   

Re: No channels on Hauppauge 950Q

2014-03-30 Thread Sunset Machine
On 3/30/14, Devin Heitmueller dheitmuel...@kernellabs.com wrote:
 On Sun, Mar 30, 2014 at 3:16 PM, Sunset Machine
 sunsetmachi...@gmail.com wrote:
 kernel 3.2.0-4-686-pae and a new 950q

 Ok.  If you own a Revision E1H3 device, then that kernel definitely
 won't work (the Rev is printed on the back of the stick above the
 barcode).

It is an E1H3, and I have good news. After upgrading the kernel to
3.13 and the firmware, I ran w_scan and it found several channels.
Creating a channels.conf with w_scan and running the command mplayer
dvb://ThisTV soon had my local channel up on the screen.

Think I'll go kill some time now. :-)

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


cron job: media_tree daily build: ERRORS

2014-03-30 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:   Mon Mar 31 04:00:13 CEST 2014
git branch: test
git hash:   3ec40dcfb413214b2874aec858870502b61c2202
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: v0.5.0
host hardware:  x86_64
host os:3.13-7.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: ERRORS
linux-git-m32r: OK
linux-git-mips: ERRORS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: ERRORS
linux-2.6.31.14-i686: ERRORS
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: 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-i686: ERRORS
linux-3.13-i686: ERRORS
linux-3.14-rc1-i686: ERRORS
linux-2.6.31.14-x86_64: OK
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: 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-x86_64: ERRORS
linux-3.13-x86_64: ERRORS
linux-3.14-rc1-x86_64: ERRORS
apps: OK
spec-git: OK
sparse version: v0.5.0
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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