Re: [PATCH] staging: fwserial: replace 'a' with '(a)' to avoid precedence issues

2017-02-15 Thread Geert Uytterhoeven
On Tue, Feb 14, 2017 at 7:08 PM, Greg KH  wrote:
> On Tue, Feb 14, 2017 at 11:26:20PM +0530, Arushi Singhal wrote:
>> Macro argument 'a' may be better as '(a)' to avoid precedence issues as
>> reported by checkpatch.pl
>>
>> Signed-off-by: Arushi Singhal 
>> ---
>>  drivers/staging/fwserial/fwserial.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/fwserial/fwserial.c 
>> b/drivers/staging/fwserial/fwserial.c
>> index 41a49c8194e5..bdfc0a8c7af3 100644
>> --- a/drivers/staging/fwserial/fwserial.c
>> +++ b/drivers/staging/fwserial/fwserial.c
>> @@ -98,7 +98,7 @@ struct fwtty_transaction {
>>   };
>>  };
>>
>> -#define to_device(a, b)  (a->b)
>> +#define to_device((a), b)(a->b)
>
> Really?

Actually compiling files should be a requirement for submitting patches,
cfr. the response from kbuild test report.
The parentheses should be added to the second "a" instead ;-)

> Why do we even have this macro at all?  Can it just be removed?

Definitely. Would be much easier to read.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 6/9] staging: rtl8192u: Fixing coding style issues

2017-02-15 Thread SIMRAN SINGHAL
On Wed, Feb 15, 2017 at 9:01 AM, Joe Perches  wrote:
> On Wed, 2017-02-15 at 08:52 +0530, SIMRAN SINGHAL wrote:
>> Yes, I totally agree with joe.
>>
>> But as there is no coding style issue in this patch.
>
> Style is more than just checkpatch conformity.
>
>> So, do I have to resend the complete patch series again?
>
> I'm not applying any of these so that's entirely up
> to Greg.
>
> Perhaps he might apply the first 5 patches and reject
> this one, maybe he might apply all the patches.
>
> In any case, do strive to develop some reasonable
> semblance of style and do more than just checkpatch
> suggested patches and find and fix some actual defect
> somewhere.

Joe, I am new to Linux kernel and just have basic knowledge of
 C and C++.
For doing more than checkpatches I need to explore Linux kernel more,
so please suggest me some tasks that help me in exploring
Linux kernel, which helps me in building the better understanding of codes,
which I am finding difficult to understand so that I can do more than
just checkpatch.

Thanks,
Simran
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller

2017-02-15 Thread peter enderborg
On 02/14/2017 05:50 PM, Greg KH wrote:
> On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com 
> wrote:
>> From: Peter Enderborg 
>>
>> This collects stats for shrinker calls and how much
>> waste work we do within the lowmemorykiller.
>>
>> Signed-off-by: Peter Enderborg 
>> ---
>>  drivers/staging/android/Kconfig | 11 
>>  drivers/staging/android/Makefile|  1 +
>>  drivers/staging/android/lowmemorykiller.c   |  9 ++-
>>  drivers/staging/android/lowmemorykiller_stats.c | 85 
>> +
>>  drivers/staging/android/lowmemorykiller_stats.h | 29 +
>>  5 files changed, 134 insertions(+), 1 deletion(-)
>>  create mode 100644 drivers/staging/android/lowmemorykiller_stats.c
>>  create mode 100644 drivers/staging/android/lowmemorykiller_stats.h
>>
>> diff --git a/drivers/staging/android/Kconfig 
>> b/drivers/staging/android/Kconfig
>> index 6c00d6f..96e86c7 100644
>> --- a/drivers/staging/android/Kconfig
>> +++ b/drivers/staging/android/Kconfig
>> @@ -24,6 +24,17 @@ config ANDROID_LOW_MEMORY_KILLER
>>scripts (/init.rc), and it defines priority values with minimum free 
>> memory size
>>for each priority.
>>  
>> +config ANDROID_LOW_MEMORY_KILLER_STATS
>> +bool "Android Low Memory Killer: collect statistics"
>> +depends on ANDROID_LOW_MEMORY_KILLER
>> +default n
>> +help
>> +  Create a file in /proc/lmkstats that includes
>> +  collected statistics about kills, scans and counts
>> +  and  interaction with the shrinker. Its content
>> +  will be different depeding on lmk implementation used.
> Ick, no new /proc files please, this isn't a "process" value.  What's
> wrong with debugfs?
This is intended for android. Android users are very limited in their access
to linux part of the system on commercial models and lmk activity has a bad 
impact on the performance
of the device. Even the application developers has not much access so it seems 
to be fair to give
the users the information about why there is a problem.
> Also note the minor '  ' usage in your first sentence of the help text.
>
>>  source "drivers/staging/android/ion/Kconfig"
>>  
>>  endif # if ANDROID
>> diff --git a/drivers/staging/android/Makefile 
>> b/drivers/staging/android/Makefile
>> index 7ed1be7..d710eb2 100644
>> --- a/drivers/staging/android/Makefile
>> +++ b/drivers/staging/android/Makefile
>> @@ -4,3 +4,4 @@ obj-y+= ion/
>>  
>>  obj-$(CONFIG_ASHMEM)+= ashmem.o
>>  obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
>> +obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER_STATS)   += 
>> lowmemorykiller_stats.o
>> diff --git a/drivers/staging/android/lowmemorykiller.c 
>> b/drivers/staging/android/lowmemorykiller.c
>> index ec3b665..15c1b38 100644
>> --- a/drivers/staging/android/lowmemorykiller.c
>> +++ b/drivers/staging/android/lowmemorykiller.c
>> @@ -42,6 +42,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include "lowmemorykiller_stats.h"
>>  
>>  static u32 lowmem_debug_level = 1;
>>  static short lowmem_adj[6] = {
>> @@ -72,6 +73,7 @@ static unsigned long lowmem_deathpending_timeout;
>>  static unsigned long lowmem_count(struct shrinker *s,
>>struct shrink_control *sc)
>>  {
>> +lmk_inc_stats(LMK_COUNT);
>>  return global_node_page_state(NR_ACTIVE_ANON) +
>>  global_node_page_state(NR_ACTIVE_FILE) +
>>  global_node_page_state(NR_INACTIVE_ANON) +
>> @@ -95,6 +97,7 @@ static unsigned long lowmem_scan(struct shrinker *s, 
>> struct shrink_control *sc)
>>  global_node_page_state(NR_SHMEM) -
>>  total_swapcache_pages();
>>  
>> +lmk_inc_stats(LMK_SCAN);
>>  if (lowmem_adj_size < array_size)
>>  array_size = lowmem_adj_size;
>>  if (lowmem_minfree_size < array_size)
>> @@ -134,6 +137,7 @@ static unsigned long lowmem_scan(struct shrinker *s, 
>> struct shrink_control *sc)
>>  if (task_lmk_waiting(p) &&
>>  time_before_eq(jiffies, lowmem_deathpending_timeout)) {
>>  task_unlock(p);
>> +lmk_inc_stats(LMK_TIMEOUT);
>>  rcu_read_unlock();
>>  return 0;
>>  }
>> @@ -179,7 +183,9 @@ static unsigned long lowmem_scan(struct shrinker *s, 
>> struct shrink_control *sc)
>>   other_free * (long)(PAGE_SIZE / 1024));
>>  lowmem_deathpending_timeout = jiffies + HZ;
>>  rem += selected_tasksize;
>> -}
>> +lmk_inc_stats(LMK_KILL);
>> +} else
>> +lmk_inc_stats(LMK_WASTE);
>>  
>>  lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
>>   sc->nr_to_scan, sc->gfp_mask, rem);
>> @@ -196,6 +202,7 @@ static struct shrinker lowmem_shrinker = {
>>  static int __init lowmem_init(void)
>>  {
>>  register_sh

Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller

2017-02-15 Thread peter enderborg
On 02/14/2017 05:51 PM, Greg KH wrote:
> On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com 
> wrote:
>> From: Peter Enderborg 
>>
>> This collects stats for shrinker calls and how much
>> waste work we do within the lowmemorykiller.
>>
>> Signed-off-by: Peter Enderborg 
> Wait, what changed from the previous versions of this patch?  Did you
> take the review comments into consideration, or is this just a resend of
> the original patches in a format that isn't corrupted?
>
> thanks,
>
> greg k-h

This is just a send with git-send-email that seems to work better. Nothing
else than tab-spaces should be different. I would like to have some positive
feedback from google/android before I start to send updated patches to the list.
If google are ready for the userspace solution this patch set is pointless for
upstream kernel.

Michal Hocko is very negative to hole thing, but we have addressed at least some
issues he pointed out on the list in 2015. Is there any idea to continue?

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: xgifb: function definition argument should also have an identifier name

2017-02-15 Thread Arushi Singhal
function definition argument 'struct vb_device_info *' and 'unsigned
long' should also have an identifier name.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/xgifb/vb_init.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/xgifb/vb_init.h b/drivers/staging/xgifb/vb_init.h
index 500cabe41a3c..e4929314d33e 100644
--- a/drivers/staging/xgifb/vb_init.h
+++ b/drivers/staging/xgifb/vb_init.h
@@ -1,6 +1,6 @@
 #ifndef _VBINIT_
 #define _VBINIT_
 unsigned char XGIInitNew(struct pci_dev *pdev);
-void XGIRegInit(struct vb_device_info *, unsigned long);
+void XGIRegInit(struct vb_device_info *pVBInfo, unsigned long BaseAddr);
 #endif
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192u: Fix warnings about endianness

2017-02-15 Thread Arnd Bergmann
On Wed, Feb 15, 2017 at 8:54 AM, maomao xu  wrote:
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:177:16: warning: 
> cast to restricted __le16
>
> Signed-off-by: maomao xu 
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c 
> b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
> index 2453413..fb171bd 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
> @@ -172,7 +172,7 @@ static inline u16 Mk16(u8 hi, u8 lo)
>  }
>
>
> -static inline u16 Mk16_le(u16 *v)
> +static inline u16 Mk16_le(__le16 *v)
>  {
> return le16_to_cpu(*v);
>  }
> @@ -264,15 +264,15 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 
> *TK, const u16 *TTAK,
> PPK[5] = TTAK[4] + IV16;
>
> /* Step 2 - 96-bit bijective mixing using S-box */
> -   PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
> -   PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
> -   PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
> -   PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
> -   PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
> -   PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
> -
> -   PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
> -   PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
> +   PPK[0] += _S_(PPK[5] ^ Mk16_le((__le16 *) &TK[0]));
> +   PPK[1] += _S_(PPK[0] ^ Mk16_le((__le16 *) &TK[2]));
> +   PPK[2] += _S_(PPK[1] ^ Mk16_le((__le16 *) &TK[4]));
> +   PPK[3] += _S_(PPK[2] ^ Mk16_le((__le16 *) &TK[6]));
> +   PPK[4] += _S_(PPK[3] ^ Mk16_le((__le16 *) &TK[8]));
> +   PPK[5] += _S_(PPK[4] ^ Mk16_le((__le16 *) &TK[10]));
> +
> +   PPK[0] += RotR1(PPK[5] ^ Mk16_le((__le16 *) &TK[12]));
> +   PPK[1] += RotR1(PPK[0] ^ Mk16_le((__le16 *) &TK[14]));
> PPK[2] += RotR1(PPK[1]);
> PPK[3] += RotR1(PPK[2]);
> PPK[4] += RotR1(PPK[3]);
> @@ -285,7 +285,7 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, 
> const u16 *TTAK,
> WEPSeed[0] = Hi8(IV16);
> WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
> WEPSeed[2] = Lo8(IV16);
> -   WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
> +   WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((__le16 *) &TK[0])) >> 1);
>
>  #ifdef __BIG_ENDIAN
> {

I see the same warning was addressed very differently in 99277c1f9962
("Staging: rtl8192e: Fix Sparse warning of cast to restricted __le16 in
 rtllib_crypt_tkip.c"), which was for a close relative of that driver.

Only one of the two approaches (at most) can be correct, so we
regardless of your patch either rtl8192e or rtl8192u is broken on
big-endian machines.

I suspect rtl8192e is broken, and your patch is relatively harmless
(we could debate whether it is the cleanest approach, but it doesn't
change behavior and it avoids the warning), but maybe Peter
Waskiewicz knows something about the tkip algorithm that I don't
see.

 Arnd
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8192u: Fix warnings about endianness

2017-02-15 Thread maomao xu
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:564:37: warning: incorrect 
type in assignment (different base types)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:564:37:expected unsigned 
short [unsigned] [usertype] len
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:564:37:got restricted 
__be16 [usertype] 

Signed-off-by: maomao xu 

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index d1057b1..1e81c24 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -559,10 +559,8 @@ void ieee80211_indicate_packets(struct ieee80211_device 
*ieee, struct ieee80211_
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
} else {
-   u16 len;
/* Leave Ethernet header part of hdr and full payload */
-   len = htons(sub_skb->len);
-   memcpy(skb_push(sub_skb, 2), &len, 2);
+   put_unaligned_be16(sub_skb->len, 
kb_push(sub_skb, 2));
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
}
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 6/9] staging: rtl8192u: Fixing coding style issues

2017-02-15 Thread Joe Perches
On Wed, 2017-02-15 at 13:48 +0530, SIMRAN SINGHAL wrote:
> Joe, I am new to Linux kernel and just have basic knowledge of
>  C and C++.
> For doing more than checkpatches I need to explore Linux kernel more,
> so please suggest me some tasks that help me in exploring
> Linux kernel, which helps me in building the better understanding of codes,
> which I am finding difficult to understand so that I can do more than
> just checkpatch.

Linux kernel isn't a great project to learn c/c++ as
it is a relatively old, complex project without a lo
of obvious defects.

see: http://kernelnewbies.org

Make sure you read the kernel newbies lists and the
kernel process help files in Documentation/process/.

In the drivers/staging directory tree are many TODO
files.  Read some of them.

List of kernel related bugs to fix:
https://bugzilla.kernel.org/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=VERIFIED&bug_status=DEFERRED&bug_status=NEEDINFO&bugidtype=include&chfieldto=Now&cmdtype=doit&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailreporter2=1&emailtype1=substring&emailtype2=substring&field0-0-0=noop&kernel_version_type=allwordssubstr&long_desc_type=substring&order=Reuse%20same%20sort%20as%20last%20time&query_format=advanced®ression=both&short_desc_type=allwordssubstr&type0-0-0=noop
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fwserial: replace 'a' with '(a)' to avoid precedence issues

2017-02-15 Thread Joe Perches
On Wed, 2017-02-15 at 09:14 +0100, Geert Uytterhoeven wrote:
> On Tue, Feb 14, 2017 at 7:08 PM, Greg KH  wrote:
> > On Tue, Feb 14, 2017 at 11:26:20PM +0530, Arushi Singhal wrote:
> > > Macro argument 'a' may be better as '(a)' to avoid precedence issues as
> > > reported by checkpatch.pl
> > > 
> > > Signed-off-by: Arushi Singhal 
> > > ---
> > >  drivers/staging/fwserial/fwserial.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/staging/fwserial/fwserial.c 
> > > b/drivers/staging/fwserial/fwserial.c
> > > index 41a49c8194e5..bdfc0a8c7af3 100644
> > > --- a/drivers/staging/fwserial/fwserial.c
> > > +++ b/drivers/staging/fwserial/fwserial.c
> > > @@ -98,7 +98,7 @@ struct fwtty_transaction {
> > >   };
> > >  };
> > > 
> > > -#define to_device(a, b)  (a->b)
> > > +#define to_device((a), b)(a->b)
> > 
> > Really?
> 
> Actually compiling files should be a requirement for submitting patches,
> cfr. the response from kbuild test report.
> The parentheses should be added to the second "a" instead ;-)
> 
> > Why do we even have this macro at all?  Can it just be removed?
> 
> Definitely. Would be much easier to read.

The use of & in some of the fwtty_ macro uses
suggest it would be easier to read if the fwtty_macros
were removed altogether and simply converted to their
dev_ equivalents.

$ git grep -E -w -n "fwtty_(err|info|notice|warn|dbg|err_ratelimited)"| cat
drivers/staging/fwserial/fwserial.c:101:#define fwtty_err(p, fmt, ...)  
\
drivers/staging/fwserial/fwserial.c:103:#define fwtty_info(p, fmt, ...) 
\
drivers/staging/fwserial/fwserial.c:105:#define fwtty_notice(p, fmt, ...)   
\
drivers/staging/fwserial/fwserial.c:107:#define fwtty_dbg(p, fmt, ...)  
\
drivers/staging/fwserial/fwserial.c:109:#define fwtty_err_ratelimited(p, fmt, 
...)  \
drivers/staging/fwserial/fwserial.c:121:fwtty_dbg(port, "short 
write: avail:%d req:%d wrote:%d\n",
drivers/staging/fwserial/fwserial.c:200:
fwtty_err_ratelimited(port, "card busy\n");
drivers/staging/fwserial/fwserial.c:203:
fwtty_err_ratelimited(port, "bad unit addr or write length\n");
drivers/staging/fwserial/fwserial.c:206:
fwtty_err_ratelimited(port, "failed rx\n");
drivers/staging/fwserial/fwserial.c:209:
fwtty_err_ratelimited(port, "missing ack\n");
drivers/staging/fwserial/fwserial.c:212:
fwtty_err_ratelimited(port, "remote busy\n");
drivers/staging/fwserial/fwserial.c:215:
fwtty_err_ratelimited(port, "failed tx: %d\n", rcode);
drivers/staging/fwserial/fwserial.c:289:fwtty_dbg(port, "fifo len: %d 
avail: %d\n", len, avail);
drivers/staging/fwserial/fwserial.c:326:fwtty_dbg(port, "status: %x 
delta: %x\n", status, delta);
drivers/staging/fwserial/fwserial.c:522:fwtty_dbg(port, "sending %d 
brks\n", n);
drivers/staging/fwserial/fwserial.c:546:fwtty_dbg(port, "%d\n", n);
drivers/staging/fwserial/fwserial.c:586:
fwtty_err_ratelimited(port, "flip buffer overrun\n");
drivers/staging/fwserial/fwserial.c:629:
fwtty_err_ratelimited(port, "ignoring unauthenticated data\n");
drivers/staging/fwserial/fwserial.c:686:fwtty_dbg(port, "rcode: %d\n", 
rcode);
drivers/staging/fwserial/fwserial.c:749:fwtty_dbg(port, "out: 
%u rem: %d\n", txn->dma_pended.len, n);
drivers/staging/fwserial/fwserial.c:759:
fwtty_err_ratelimited(port, "fifo err: %d\n",
drivers/staging/fwserial/fwserial.c:819:fwtty_dbg(port, "%02x\n", ch);
drivers/staging/fwserial/fwserial.c:904:fwtty_dbg(port, "on/off: %d\n", 
on);
drivers/staging/fwserial/fwserial.c:932:fwtty_dbg(port, "%d\n", rc);
drivers/staging/fwserial/fwserial.c:1110:   fwtty_dbg(port, "%d\n", c);
drivers/staging/fwserial/fwserial.c:1137:   fwtty_dbg(port, "%d\n", n);
drivers/staging/fwserial/fwserial.c:1151:   fwtty_dbg(port, "%d\n", n);
drivers/staging/fwserial/fwserial.c:1160:   fwtty_dbg(port, "%02x\n", ch);
drivers/staging/fwserial/fwserial.c:1187:   fwtty_dbg(port, "CRTSCTS: 
%d\n", C_CRTSCTS(tty) != 0);
drivers/staging/fwserial/fwserial.c:1341:   fwtty_dbg(port, "%d\n", state);
drivers/staging/fwserial/fwserial.c:1378:   fwtty_dbg(port, "%x\n", tiocm);
drivers/staging/fwserial/fwserial.c:1388:   fwtty_dbg(port, "set: %x clear: 
%x\n", set, clear);
drivers/staging/fwserial/fwserial.c:1700:   fwtty_info(&peer->unit, "peer 
(guid:%016llx) connected on %s\n",
drivers/staging/fwserial/fwserial.c:1722:   
fwtty_dbg(&peer->unit, "mgmt write error: %d\n", rcode);
drivers/staging/fwserial/fwserial.c:1844:   fwtty_err(&peer->unit, 
"avail ports in use\n");
drive

Re: [PATCH v3 00/24] i.MX Media Driver

2017-02-15 Thread Philipp Zabel
Hi Steve,

On Tue, 2017-02-14 at 18:27 -0800, Steve Longerbeam wrote:
[...]
> >
> > # Provide an EDID to the HDMI source
> > v4l2-ctl -d /dev/v4l-subdev2 --set-edid=file=edid-1080p.hex
> 
> I can probably generate this Intel hex file myself from sysfs
> edid outputs, but for convenience do you mind sending me this
> file? I have a 1080p HDMI source I can plug into the tc358743.

I copied the EDID off of some random 1080p HDMI monitor,
probably using something like:

xxd -g1 /sys/class/drm/card0-HDMI-A-1/edid | cut -c 9-56

--8<--
 00 ff ff ff ff ff ff 00 09 d1 89 78 45 54 00 00
 2a 14 01 03 80 35 1e 78 2e b8 45 a1 59 55 9f 28
 0d 50 54 a5 6b 80 81 c0 81 00 81 80 a9 c0 b3 00
 d1 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c
 45 00 13 2a 21 00 00 1e 00 00 00 ff 00 4e 41 41
 30 36 32 39 36 53 4c 30 0a 20 00 00 00 fd 00 32
 4c 1e 53 11 00 0a 20 20 20 20 20 20 00 00 00 fc
 00 42 65 6e 51 20 47 4c 32 34 34 30 48 0a 01 18
 02 03 22 f1 4f 90 05 04 03 02 01 11 12 13 14 06
 07 15 16 1f 23 09 07 07 65 03 0c 00 10 00 83 01
 00 00 02 3a 80 18 71 38 2d 40 58 2c 45 00 13 2a
 21 00 00 1f 01 1d 80 18 71 1c 16 20 58 2c 25 00
 13 2a 21 00 00 9f 01 1d 00 72 51 d0 1e 20 6e 28
 55 00 13 2a 21 00 00 1e 8c 0a d0 8a 20 e0 2d 10
 10 3e 96 00 13 2a 21 00 00 18 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 eb
-->8--

> The other problem here is that my version of v4l2-ctl, built from
> master branch of g...@github.com:gjasny/v4l-utils.git, does not
> support taking a subdev node:
> 
> root@mx6q:~# v4l2-ctl -d /dev/v4l-subdev15 --get-edid=format=hex
> VIDIOC_QUERYCAP: failed: Inappropriate ioctl for device
> /dev/v4l-subdev15: not a v4l2 node
> 
> Is this something you added yourself, or where can I find this version
> of v4l2-ctrl?

Ah right, I still have no proper fix for that. v4l-ctl bails out if it
can't VIDIOC_QUERYCAP, which is an ioctl not supported on subdevices.
I have just patched it out locally:

--8<--
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 886a91d093ae..fa15a49375ae 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -1214,10 +1214,7 @@ int main(int argc, char **argv)
}
 
verbose = options[OptVerbose];
-   if (doioctl(fd, VIDIOC_QUERYCAP, &vcap)) {
-   fprintf(stderr, "%s: not a v4l2 node\n", device);
-   exit(1);
-   }
+   doioctl(fd, VIDIOC_QUERYCAP, &vcap);
capabilities = vcap.capabilities;
if (capabilities & V4L2_CAP_DEVICE_CAPS)
capabilities = vcap.device_caps;
-->8--

Note that setting the EDID is not necessary if you can force the mode on
your HDMI source.

regards
Philipp

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192u: Fix warnings about endianness

2017-02-15 Thread kbuild test robot
Hi maomao,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.10-rc8 next-20170215]
[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/maomao-xu/staging-rtl8192u-Fix-warnings-about-endianness/20170215-171426
config: x86_64-randconfig-x019-201707 (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 

All error/warnings (new ones prefixed by >>):

   drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c: In function 
'ieee80211_indicate_packets':
>> drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:563:38: error: implicit 
>> declaration of function 'kb_push' [-Werror=implicit-function-declaration]
put_unaligned_be16(sub_skb->len, kb_push(sub_skb, 2));
 ^~~
>> drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:563:38: warning: passing 
>> argument 2 of 'put_unaligned_be16' makes pointer from integer without a cast 
>> [-Wint-conversion]
   In file included from arch/x86/include/asm/unaligned.h:8:0,
from include/linux/etherdevice.h:28,
from drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:40:
   include/linux/unaligned/access_ok.h:52:29: note: expected 'void *' but 
argument is of type 'int'
static __always_inline void put_unaligned_be16(u16 val, void *p)
^~
   cc1: some warnings being treated as errors

vim +/kb_push +563 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c

   557   * replace EtherType */
   558  skb_pull(sub_skb, SNAP_SIZE);
   559  memcpy(skb_push(sub_skb, ETH_ALEN), 
prxb->src, ETH_ALEN);
   560  memcpy(skb_push(sub_skb, ETH_ALEN), 
prxb->dst, ETH_ALEN);
   561  } else {
   562  /* Leave Ethernet header part of hdr and full 
payload */
 > 563  put_unaligned_be16(sub_skb->len, 
 > kb_push(sub_skb, 2));
   564  memcpy(skb_push(sub_skb, ETH_ALEN), 
prxb->src, ETH_ALEN);
   565  memcpy(skb_push(sub_skb, ETH_ALEN), 
prxb->dst, ETH_ALEN);
   566  }

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


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8192u: Fix warnings about endianness

2017-02-15 Thread maomao xu
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:564:37: warning: incorrect 
type in assignment (different base types)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:564:37:expected unsigned 
short [unsigned] [usertype] len
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c:564:37:got restricted 
__be16 [usertype] 

Signed-off-by: maomao xu 

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index d1057b1..1e81c24 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -559,10 +559,8 @@ void ieee80211_indicate_packets(struct ieee80211_device 
*ieee, struct ieee80211_
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
} else {
-   u16 len;
/* Leave Ethernet header part of hdr and full payload */
-   len = htons(sub_skb->len);
-   memcpy(skb_push(sub_skb, 2), &len, 2);
+   put_unaligned_be16(sub_skb->len, 
skb_push(sub_skb, 2));
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
}
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: Speakup: speakup_decpc: fixed a block comment misalignment

2017-02-15 Thread Daniel Perez
Fixed a coding style issue (block comments misasligned and code indents
not done with tabs)

Signed-off-by: Daniel Perez 
---
 drivers/staging/speakup/speakup_decpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/speakup_decpc.c 
b/drivers/staging/speakup/speakup_decpc.c
index 6bf38e4..ca3fc4d 100644
--- a/drivers/staging/speakup/speakup_decpc.c
+++ b/drivers/staging/speakup/speakup_decpc.c
@@ -85,8 +85,8 @@
 #defineCTRL_io_priority0x0c00  /*   change i/o priority */
 #defineCTRL_free_mem   0x0d00  /*   get free paragraphs on 
module */
 #defineCTRL_get_lang   0x0e00  /* return bit mask of loaded
-* languages
-*/
+* languages
+*/
 #defineCMD_test0x2000  /* self-test 
request */
 #defineTEST_mask   0x0F00  /* isolate test field */
 #defineTEST_null   0x  /* no test requested */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv6 1/3] staging: wlan-ng: move logical continuations at the end of line

2017-02-15 Thread Maksymilian Piechota
On Tue, Feb 14, 2017 at 09:16:31AM -0800, Greg Kroah-Hartman wrote:
> On Mon, Feb 13, 2017 at 09:25:49AM -0500, Maksymilian Piechota wrote:
> > move logical continuations at the end of line
> > 
> > Signed-off-by: Maksymilian Piechota 
> > ---
> >  drivers/staging/wlan-ng/prism2mgmt.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
> > b/drivers/staging/wlan-ng/prism2mgmt.c
> > index 16fb2d3..64a9ebc 100644
> > --- a/drivers/staging/wlan-ng/prism2mgmt.c
> > +++ b/drivers/staging/wlan-ng/prism2mgmt.c
> > @@ -1308,9 +1308,8 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, 
> > void *msgp)
> > hw->sniffhdr = 0;
> > wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
> > } else
> > -   if ((msg->wlanheader.status ==
> > -P80211ENUM_msgitem_status_data_ok)
> > -   && (msg->wlanheader.data == P80211ENUM_truth_true)) {
> > +   if ((msg->wlanheader.status == 
> > P80211ENUM_msgitem_status_data_ok) && 
> > +   (msg->wlanheader.data == P80211ENUM_truth_true)) {
> > hw->sniffhdr = 1;
> > wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
> > } else {
> 
> This patch has checkpatch.pl errors.  Please always use checkpatch so
> you don't get emails from grumpy maintainers telling you to fix the
> checkpatch errors :)
> 
> Please fix up and resend the whole series.
> 
> thanks,
> 
> greg k-h

of course it has. Few patches ago I've sent all changes in one patch so
there was no errors. Then You asked me to break up every change to particular
commits, so there are checkpatch errors between them. PATCH 3/3 solves
all errors.

So how should I commit this changes, finally? I feel bit lost.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] greybus: fw-management: Replace strncpy with strlcpy

2017-02-15 Thread Bryan O'Donoghue
On 15/02/17 00:09, Tobin C. Harding wrote:
> Greybus currently uses strncpy() coupled with a check for '\0' on the
> last byte of various buffers. strncpy() is passed size parameter equal
> to the size of the buffer in all instances. If the source string is
> larger than the destination buffer the check catches this and, after
> logging the error, returns an error value. In one instance the
> immediate return is not required. Using strncpy() with the manual check
> adds code that could be removed by the use of strlcpy(), although truncation
> then needs to be checked.
> 
> Replace calls to strncpy() with calls to strlcpy(). Replace null
> termination checks  with checks for truncated string. Add log message
> if string is truncated but do not return an error code.

The strlcpy() replace should be one patch.
The not returning on truncation should be a separate patch.

Personally I don't think the flow should change re: returning errors on
string truncation but, either way you should split it up.

---
bod
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fsl-mc: Add missing header

2017-02-15 Thread Laurentiu Tudor


On 02/13/2017 06:40 PM, Bogdan Purcareata wrote:
> Compiling the fsl-mc bus driver will yield a couple of static analysis
> errors:
> warning: symbol 'fsl_mc_msi_domain_alloc_irqs' was not declared
> warning: symbol 'fsl_mc_msi_domain_free_irqs' was not declared.
> warning: symbol 'its_fsl_mc_msi_init' was not declared.
> warning: symbol 'its_fsl_mc_msi_cleanup' was not declared.
>
> Since these are properly declared, but the header is not included, add
> it in the source files. This way the symbol is properly exported.
>
> Signed-off-by: Bogdan Purcareata 
> ---
> Sent against staging-testing.
>
>   drivers/staging/fsl-mc/bus/fsl-mc-msi.c| 1 +
>   drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c 
> b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
> index 7975c6e..b8b2c86 100644
> --- a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
> +++ b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c
> @@ -17,6 +17,7 @@
>   #include 
>   #include 
>   #include "../include/mc-bus.h"
> +#include "fsl-mc-private.h"
>
>   /*
>* Generate a unique ID identifying the interrupt (only used within the MSI
> diff --git a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c 
> b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> index 0e2c1b5..87e4471 100644
> --- a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> +++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c
> @@ -17,6 +17,7 @@
>   #include 
>   #include 
>   #include "../include/mc-bus.h"
> +#include "fsl-mc-private.h"
>
>   static struct irq_chip its_msi_irq_chip = {
>   .name = "ITS-fMSI",
>

Acked-by: Laurentiu Tudor 

---
Best Regards, Laurentiu
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging:nvec:nvec_ps2.c: Preferingkzalloc(sizeof(*ser_dev)...) over kzalloc(sizeof(struct serio)...)

2017-02-15 Thread Marc Dietrich
Am Dienstag, 14. Februar 2017, 22:31:20 CET schrieb Arushi Singhal:
> Prefer kzalloc(sizeof(*ser_dev)...) over kzalloc(sizeof(struct
> serio)...) as reported by checkpatch.pl.
> 
> Signed-off-by: Arushi Singhal 

looks like we are in a (make everyone) happy week.

Acked-by: Marc Dietrich 


> ---
>  drivers/staging/nvec/nvec_ps2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/nvec/nvec_ps2.c
> b/drivers/staging/nvec/nvec_ps2.c index 499952c8ef39..3b7bce3ffd19 100644
> --- a/drivers/staging/nvec/nvec_ps2.c
> +++ b/drivers/staging/nvec/nvec_ps2.c
> @@ -107,7 +107,7 @@ static int nvec_mouse_probe(struct platform_device
> *pdev) struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
>   struct serio *ser_dev;
> 
> - ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
> + ser_dev = kzalloc(sizeof(*ser_dev), GFP_KERNEL);
>   if (!ser_dev)
>   return -ENOMEM;



signature.asc
Description: This is a digitally signed message part.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[patch] staging: bcm2835-camera: free first element in array

2017-02-15 Thread Dan Carpenter
We should free gdev[0] so the > should be >=.

Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera 
driver.")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c 
b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
index ca15a698e018..9bcd8e546a14 100644
--- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
+++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
@@ -1998,7 +1998,7 @@ static int __init bm2835_mmal_init(void)
 free_dev:
kfree(dev);
 
-   for ( ; camera > 0; camera--) {
+   for ( ; camera >= 0; camera--) {
bcm2835_cleanup_instance(gdev[camera]);
gdev[camera] = NULL;
}
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [patch] staging: bcm2835-camera: free first element in array

2017-02-15 Thread walter harms


Am 15.02.2017 13:25, schrieb Dan Carpenter:
> We should free gdev[0] so the > should be >=.
> 
> Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera 
> driver.")
> Signed-off-by: Dan Carpenter 
> 
> diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c 
> b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> index ca15a698e018..9bcd8e546a14 100644
> --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> @@ -1998,7 +1998,7 @@ static int __init bm2835_mmal_init(void)
>  free_dev:
>   kfree(dev);
>  
> - for ( ; camera > 0; camera--) {
> + for ( ; camera >= 0; camera--) {
>   bcm2835_cleanup_instance(gdev[camera]);
>   gdev[camera] = NULL;
>   }

since we already know that programmers are bad in counting backwards ...

is is possible to change that into std. loop like:

 for(i=0, i< camera; i++ {
bcm2835_cleanup_instance(gdev[i]);
gdev[i] = NULL;
}

this is way a much more common pattern.


just my 2 cents,
re,
 wh

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: octeon: Use net_device_stats from struct net_device

2017-02-15 Thread Tobias Klauser
Instead of using a private copy of struct net_device_stats in
struct octeon_ethernet, use stats from struct net_device. Also remove
the now unnecessary .ndo_get_stats function.

Signed-off-by: Tobias Klauser 
---
 drivers/staging/octeon/ethernet-rx.c |  6 +++---
 drivers/staging/octeon/ethernet-tx.c | 10 +-
 drivers/staging/octeon/ethernet.c| 18 +-
 drivers/staging/octeon/octeon-ethernet.h |  2 --
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-rx.c 
b/drivers/staging/octeon/ethernet-rx.c
index fc849d4a1b5d..7f8cf875157c 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -356,8 +356,8 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int 
budget)
 
/* Increment RX stats for virtual ports */
if (port >= CVMX_PIP_NUM_INPUT_PORTS) {
-   priv->stats.rx_packets++;
-   priv->stats.rx_bytes += skb->len;
+   dev->stats.rx_packets++;
+   dev->stats.rx_bytes += skb->len;
}
netif_receive_skb(skb);
} else {
@@ -365,7 +365,7 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int 
budget)
 * Drop any packet received for a device that
 * isn't up.
 */
-   priv->stats.rx_dropped++;
+   dev->stats.rx_dropped++;
dev_kfree_skb_irq(skb);
}
} else {
diff --git a/drivers/staging/octeon/ethernet-tx.c 
b/drivers/staging/octeon/ethernet-tx.c
index 0b8053205091..ff4119e8de42 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -459,7 +459,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device 
*dev)
case QUEUE_DROP:
skb->next = to_free_list;
to_free_list = skb;
-   priv->stats.tx_dropped++;
+   dev->stats.tx_dropped++;
break;
case QUEUE_HW:
cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE, -1);
@@ -534,7 +534,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device 
*dev)
if (unlikely(!work)) {
printk_ratelimited("%s: Failed to allocate a work queue 
entry\n",
   dev->name);
-   priv->stats.tx_dropped++;
+   dev->stats.tx_dropped++;
dev_kfree_skb_any(skb);
return 0;
}
@@ -545,7 +545,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device 
*dev)
printk_ratelimited("%s: Failed to allocate a packet buffer\n",
   dev->name);
cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1);
-   priv->stats.tx_dropped++;
+   dev->stats.tx_dropped++;
dev_kfree_skb_any(skb);
return 0;
}
@@ -662,8 +662,8 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device 
*dev)
/* Submit the packet to the POW */
cvmx_pow_work_submit(work, work->word1.tag, work->word1.tag_type,
 cvmx_wqe_get_qos(work), cvmx_wqe_get_grp(work));
-   priv->stats.tx_packets++;
-   priv->stats.tx_bytes += skb->len;
+   dev->stats.tx_packets++;
+   dev->stats.tx_bytes += skb->len;
dev_consume_skb_any(skb);
return 0;
 }
diff --git a/drivers/staging/octeon/ethernet.c 
b/drivers/staging/octeon/ethernet.c
index a379734a54b1..429e24adfcf5 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -228,17 +228,17 @@ static struct net_device_stats 
*cvm_oct_common_get_stats(struct net_device *dev)
cvmx_pko_get_port_status(priv->port, 1, &tx_status);
}
 
-   priv->stats.rx_packets += rx_status.inb_packets;
-   priv->stats.tx_packets += tx_status.packets;
-   priv->stats.rx_bytes += rx_status.inb_octets;
-   priv->stats.tx_bytes += tx_status.octets;
-   priv->stats.multicast += rx_status.multicast_packets;
-   priv->stats.rx_crc_errors += rx_status.inb_errors;
-   priv->stats.rx_frame_errors += rx_status.fcs_align_err_packets;
-   priv->stats.rx_dropped += rx_status.dropped_packets;
+   dev->stats.rx_packets += rx_status.inb_packets;
+   dev->stats.tx_packets += tx_status.packets;
+   dev->stats.rx_bytes += rx_status.inb_octets;
+   dev->stats.tx_bytes += tx_status.octets;
+   dev->stats.multicast += rx_status.multicast_packets;
+  

[PATCH] staging: ks7010: fix coding style issues reported by checkpatch.pl

2017-02-15 Thread Chetan Sethi
This is patch to ks_wlan.h which fixes various coding style errors and
warnings issued by checkpatch.pl

Signed-off-by: Chetan Sethi 
---
 drivers/staging/ks7010/ks_wlan.h | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index c7fa508..c24cc10 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -18,10 +18,10 @@
 #include 
 #include 
 
-#include /* spinlock_t   
*/
-#include/* wait_queue_head_t
*/
-#include/* pid_t
*/
-#include/* struct net_device_stats,  struct sk_buff 
*/
+#include /* spinlock_t */
+#include/* wait_queue_head_t */
+#include/* pid_t */
+#include/* struct net_device_stats,  struct sk_buff */
 #include 
 #include 
 #include   /* struct atomic_t */
@@ -36,7 +36,9 @@
 
 #ifdef KS_WLAN_DEBUG
 #define DPRINTK(n, fmt, args...) \
- if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, 
__FUNCTION__, ## args)
+   do {if (KS_WLAN_DEBUG > (n)) \
+   pr_notice("%s: "fmt, __func__, ## args); \
+   } while (0)
 #else
 #define DPRINTK(n, fmt, args...)
 #endif
@@ -356,7 +358,8 @@ struct wpa_key_t {
u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE];  /* LSB first */
struct sockaddr addr;   /* ff:ff:ff:ff:ff:ff for broadcast/multicast
 * (group) keys or unicast address for
-* individual keys */
+* individual keys
+*/
u16 alg;
u16 key_len;/* WEP: 5 or 13, TKIP: 32, CCMP: 16 */
u8 key_val[IW_ENCODING_TOKEN_MAX];
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 0/3] x86/vdso: Add Hyper-V TSC page clocksource support

2017-02-15 Thread Vitaly Kuznetsov
Andy Lutomirski  writes:

> On Tue, Feb 14, 2017 at 7:50 AM, Vitaly Kuznetsov  wrote:
>> Thomas Gleixner  writes:
>>
>>> On Tue, 14 Feb 2017, Vitaly Kuznetsov wrote:
>>>
 Hi,

 while we're still waiting for a definitive ACK from Microsoft that the
 algorithm is good for SMP case (as we can't prevent the code in vdso from
 migrating between CPUs) I'd like to send v2 with some modifications to keep
 the discussion going.
>>>
>>> Migration is irrelevant. The TSC page is guest global so updates will
>>> happen on some (random) host CPU and therefor you need the usual barriers
>>> like we have them in our seqcounts unless an access to the sequence will
>>> trap into the host, which would defeat the whole purpose of the TSC page.
>>>
>>
>> KY Srinivasan  writes:
>>
>>> I checked with the folks on the Hyper-V side and they have confirmed that 
>>> we need to
>>> add memory barriers in the guest code to ensure the various reads from the 
>>> TSC page are
>>> correctly ordered - especially, the initial read of the sequence counter 
>>> must have acquire
>>> semantics. We should ensure that other reads from the TSC page are 
>>> completed before the
>>> second read of the sequence counter. I am working with the Windows team to 
>>> correctly
>>> reflect this algorithm in the Hyper-V specification.
>>
>>
>> Thank you,
>>
>> do I get it right that combining the above I only need to replace
>> virt_rmb() barriers with plain rmb() to get 'lfence' in hv_read_tsc_page
>> (PATCH 2)? As members of struct ms_hyperv_tsc_page are volatile we don't
>> need READ_ONCE(), compilers are not allowed to merge accesses. The
>> resulting code looks good to me:
>
> No, on multiple counts, unfortunately.
>
> 1. LFENCE is basically useless except for IO and for (Intel only)
> rdtsc_ordered().  AFAIK there is literally no scenario under which
> LFENCE is useful for access to normal memory.
>

Interesting,

(For some reason I was under the impression that when I do

READ var1 -> reg1
READ var2 -> reg2

from normal memory reads can actually happen in any order and LFENCE
in between gives us strict ordering.) But I completely agree it wouldn't
help in situations you descibe below:

> 2. The problem here has little to do with barriers.  You're doing:
>
> read seq;
> read var1;
> read var2;
> read tsc;
> read seq again;
>
> If the hypervisor updates things between reading var1 and var2 or
> between reading var2 and tsc, you aren't guaranteed to notice unless
> something fancy is going on regardless of barriers.  Similarly, if the
> hypervisor starts updating, then you start and finish the whole
> function, and then the hypervisor finishes, what guarantees you
> notice?
>
> This really needs a spec from the hypervisor folks as to what's going
> on.  KVM does this horrible thing in which it sometimes freezes all
> vCPUs when updating, for better or for worse.  Mostly for worse.  If
> MS does the same thing, they should document it.

... so I'll have to summon K. Y. again and ask him to use his magic
powers to extract some info from the Hyper-V team. As we have TSC page
clocksource for quite a while now and no bugs were reported there should
be something.

Actually, we already have an implementation of TSC page update in KVM
(see arch/x86/kvm/hyperv.c, kvm_hv_setup_tsc_page()) and the update does
the following:

0) stash seq into seq_prev
1) seq = 0 making all reads from the page invalid
2) smp_wmb()
3) update tsc_scale, tsc_offset
4) smp_wmb()
5) set seq = seq_prev + 1

As far as I understand this helps with situations you described above as
guest will notice either invalid value of 0 or seq change. In case the
implementation in real Hyper-V is the same we're safe with compile
barriers only.

>
> 3. You need rdtsc_ordered().  Plain RDTSC is not ordered wrt other
> memory access, and it can observably screw up as a result.

Another interesting thing is if we look at how this is implemented in
Windows (see linux.git commit c35b82ef0294) there are no barriers there
even for rdtsc...

>
> Also, Linux tries to avoid volatile variables, so please use READ_ONCE().
>

Will do both of the above in my next submission, thanks for the feedback!

[snip]

-- 
  Vitaly
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] Staging: comedi: drivers: comedi_test: Add auto-configuration capability

2017-02-15 Thread Cheah Kok Cheong
On Mon, Feb 13, 2017 at 11:14:14AM +, Ian Abbott wrote:
> On 11/02/17 10:37, Cheah Kok Cheong wrote:
> >+static int __init comedi_test_init(void)
> >+{
> >+int ret;
> >+
> >+ret = comedi_driver_register(&waveform_driver);
> >+if (ret) {
> >+pr_err("comedi_test: unable to register driver\n");
> >+return ret;
> >+}
> >+
> >+if (!config_mode) {
> >+ctcls = class_create(THIS_MODULE, CLASS_NAME);
> >+if (IS_ERR(ctcls)) {
> >+pr_warn("comedi_test: unable to create class\n");
> >+return ret;
> >+}
> >+
> >+ctdev = device_create(ctcls, NULL, MKDEV(0, 0), NULL, DEV_NAME);
> >+if (IS_ERR(ctdev)) {
> >+pr_warn("comedi_test: unable to create device\n");
> >+goto clean2;
> >+}
> >+
> >+ret = comedi_auto_config(ctdev, &waveform_driver, 0);
> >+if (ret) {
> >+pr_warn("comedi_test: unable to auto-configure 
> >device\n");
> >+goto clean;
> >+}
> >+}
> >+
> >+return 0;
> >+
> >+clean:
> >+device_destroy(ctcls, MKDEV(0, 0));
> >+clean2:
> >+class_destroy(ctcls);
> >+
> >+return 0;
> >+}
> >+module_init(comedi_test_init);
> >+
> >+static void __exit comedi_test_exit(void)
> >+{
> >+comedi_auto_unconfig(ctdev);
> >+
> >+device_destroy(ctcls, MKDEV(0, 0));
> >+
> >+class_destroy(ctcls);
> 
> If the driver init returned successfully, but failed to set-up the
> auto-configured device, the device and class will not exist at this point,
> so those three calls need to go in an 'if' statement.  Perhaps you could use
> 'if (ctcls) {', and set 'ctcls = NULL;' after calling
> 'class_destroy(ctcls);' in the init function.
> 
> Apart from that, it looks fine.
> 

Thanks for pointing out those two pointers have to be "NULL" if
auto-configuration fails.

Please review below snippet.
Sorry for the inconvenience caused.

[ Snip ]

static int __init comedi_test_init(void)
{
int ret;

ret = comedi_driver_register(&waveform_driver);
if (ret) {
pr_err("comedi_test: unable to register driver\n");
return ret;
}

if (!config_mode) {
ctcls = class_create(THIS_MODULE, CLASS_NAME);
if (IS_ERR(ctcls)) {
pr_warn("comedi_test: unable to create class\n");
goto clean3;
}

ctdev = device_create(ctcls, NULL, MKDEV(0, 0), NULL, DEV_NAME);
if (IS_ERR(ctdev)) {
pr_warn("comedi_test: unable to create device\n");
goto clean2;
}

ret = comedi_auto_config(ctdev, &waveform_driver, 0);
if (ret) {
pr_warn("comedi_test: unable to auto-configure 
device\n");
goto clean;
}
}

return 0;

clean:
device_destroy(ctcls, MKDEV(0, 0));
clean2:
class_destroy(ctcls);
ctdev = NULL;
clean3:
ctcls = NULL;

return 0;
}
module_init(comedi_test_init);

static void __exit comedi_test_exit(void)
{
if (ctdev)
comedi_auto_unconfig(ctdev);

if (ctcls) {
device_destroy(ctcls, MKDEV(0, 0));
class_destroy(ctcls);
}

comedi_driver_unregister(&waveform_driver);
}
module_exit(comedi_test_exit);

[ Snip ]

Thks.
Brgds,
CheahKC
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Drivers: hv: util: don't forget to init host_ts.lock

2017-02-15 Thread Dexuan Cui

Without the patch, I always get a "BUG: spinlock bad magic" warning.

Fixes: 3716a49a81ba ("hv_utils: implement Hyper-V PTP source")
Signed-off-by: Dexuan Cui 
Cc: Vitaly Kuznetsov 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
---

3716a49a81ba is the commit id in char-misc.git, since the patch hasn't
been in Linus's tree yet.

 drivers/hv/hv_util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 098cd3d..60d763c 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -591,6 +591,8 @@ static int hv_timesync_init(struct hv_util_service *srv)
if (!hyperv_cs)
return -ENODEV;
 
+   spin_lock_init(&host_ts.lock);
+
INIT_WORK(&wrk.work, hv_set_host_time);
 
/*
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv6 1/3] staging: wlan-ng: move logical continuations at the end of line

2017-02-15 Thread Greg Kroah-Hartman
On Wed, Feb 15, 2017 at 06:53:43AM -0500, Maksymilian Piechota wrote:
> On Tue, Feb 14, 2017 at 09:16:31AM -0800, Greg Kroah-Hartman wrote:
> > On Mon, Feb 13, 2017 at 09:25:49AM -0500, Maksymilian Piechota wrote:
> > > move logical continuations at the end of line
> > > 
> > > Signed-off-by: Maksymilian Piechota 
> > > ---
> > >  drivers/staging/wlan-ng/prism2mgmt.c | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
> > > b/drivers/staging/wlan-ng/prism2mgmt.c
> > > index 16fb2d3..64a9ebc 100644
> > > --- a/drivers/staging/wlan-ng/prism2mgmt.c
> > > +++ b/drivers/staging/wlan-ng/prism2mgmt.c
> > > @@ -1308,9 +1308,8 @@ int prism2mgmt_wlansniff(struct wlandevice 
> > > *wlandev, void *msgp)
> > >   hw->sniffhdr = 0;
> > >   wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
> > >   } else
> > > - if ((msg->wlanheader.status ==
> > > -  P80211ENUM_msgitem_status_data_ok)
> > > - && (msg->wlanheader.data == P80211ENUM_truth_true)) {
> > > + if ((msg->wlanheader.status == 
> > > P80211ENUM_msgitem_status_data_ok) && 
> > > + (msg->wlanheader.data == P80211ENUM_truth_true)) {
> > >   hw->sniffhdr = 1;
> > >   wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
> > >   } else {
> > 
> > This patch has checkpatch.pl errors.  Please always use checkpatch so
> > you don't get emails from grumpy maintainers telling you to fix the
> > checkpatch errors :)
> > 
> > Please fix up and resend the whole series.
> > 
> > thanks,
> > 
> > greg k-h
> 
> of course it has. Few patches ago I've sent all changes in one patch so
> there was no errors. Then You asked me to break up every change to particular
> commits, so there are checkpatch errors between them. PATCH 3/3 solves
> all errors.

But you added NEW errors in this patch, which isn't ok at all.  Don't
make a new error and then remove it in a later one, that's just crazy!

(hint, trailing whitespace...)

Also, you made this change in a way that added another new problem (too
long of a line), you don't have to do that in order to fix this one
warning.

Please fix up and resend.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller

2017-02-15 Thread Greg KH
On Wed, Feb 15, 2017 at 09:22:10AM +0100, peter enderborg wrote:
> On 02/14/2017 05:50 PM, Greg KH wrote:
> > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com 
> > wrote:
> >> From: Peter Enderborg 
> >>
> >> This collects stats for shrinker calls and how much
> >> waste work we do within the lowmemorykiller.
> >>
> >> Signed-off-by: Peter Enderborg 
> >> ---
> >>  drivers/staging/android/Kconfig | 11 
> >>  drivers/staging/android/Makefile|  1 +
> >>  drivers/staging/android/lowmemorykiller.c   |  9 ++-
> >>  drivers/staging/android/lowmemorykiller_stats.c | 85 
> >> +
> >>  drivers/staging/android/lowmemorykiller_stats.h | 29 +
> >>  5 files changed, 134 insertions(+), 1 deletion(-)
> >>  create mode 100644 drivers/staging/android/lowmemorykiller_stats.c
> >>  create mode 100644 drivers/staging/android/lowmemorykiller_stats.h
> >>
> >> diff --git a/drivers/staging/android/Kconfig 
> >> b/drivers/staging/android/Kconfig
> >> index 6c00d6f..96e86c7 100644
> >> --- a/drivers/staging/android/Kconfig
> >> +++ b/drivers/staging/android/Kconfig
> >> @@ -24,6 +24,17 @@ config ANDROID_LOW_MEMORY_KILLER
> >>  scripts (/init.rc), and it defines priority values with minimum free 
> >> memory size
> >>  for each priority.
> >>  
> >> +config ANDROID_LOW_MEMORY_KILLER_STATS
> >> +  bool "Android Low Memory Killer: collect statistics"
> >> +  depends on ANDROID_LOW_MEMORY_KILLER
> >> +  default n
> >> +  help
> >> +Create a file in /proc/lmkstats that includes
> >> +collected statistics about kills, scans and counts
> >> +and  interaction with the shrinker. Its content
> >> +will be different depeding on lmk implementation used.
> > Ick, no new /proc files please, this isn't a "process" value.  What's
> > wrong with debugfs?
> This is intended for android. Android users are very limited in their access
> to linux part of the system on commercial models and lmk activity has a bad 
> impact on the performance
> of the device. Even the application developers has not much access so it 
> seems to be fair to give
> the users the information about why there is a problem.

Why would you want to give "all users" this information at all?  This is
a debugging tool, your debugging userspace framework can use whatever
interface you create to access it (i.e. debugfs).

Again, do not add debugging stuff to /proc/ that's not ok, sorry.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller

2017-02-15 Thread Greg KH
On Wed, Feb 15, 2017 at 09:21:56AM +0100, peter enderborg wrote:
> On 02/14/2017 05:51 PM, Greg KH wrote:
> > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com 
> > wrote:
> >> From: Peter Enderborg 
> >>
> >> This collects stats for shrinker calls and how much
> >> waste work we do within the lowmemorykiller.
> >>
> >> Signed-off-by: Peter Enderborg 
> > Wait, what changed from the previous versions of this patch?  Did you
> > take the review comments into consideration, or is this just a resend of
> > the original patches in a format that isn't corrupted?
> >
> > thanks,
> >
> > greg k-h
> 
> This is just a send with git-send-email that seems to work better. Nothing
> else than tab-spaces should be different. I would like to have some positive
> feedback from google/android before I start to send updated patches to the 
> list.
> If google are ready for the userspace solution this patch set is pointless for
> upstream kernel.
> 
> Michal Hocko is very negative to hole thing, but we have addressed at least 
> some
> issues he pointed out on the list in 2015. Is there any idea to continue?

If Michal rejected this solution, then I wouldn't be spending much time
on it at all.  Instead, I strongly suggest you try to do what he pointed
out should be done instead.  If that requires userspace help, great, try
that and see what happens.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 6/8] vmbus: remove unused low_latency option

2017-02-15 Thread KY Srinivasan


> -Original Message-
> From: Stephen Hemminger [mailto:step...@networkplumber.org]
> Sent: Tuesday, February 14, 2017 10:21 PM
> To: KY Srinivasan ; Haiyan Yang
> 
> Cc: de...@linuxdriverproject.org; Stephen Hemminger
> 
> Subject: [PATCH 6/8] vmbus: remove unused low_latency option
> 
> This was intended for future use, but since the code is currently unused (and
> therefore dead and unused), remove it.
> 
> It can be restored when there is a use case.

Stephen, I do have a use case for this. I wanted to get this into the Greg's 
tree and then
Modify both netvsc and storvsc to use it. This is currently shipping as part of 
Clear Linux
and makes a significant difference in the boot time on Hyper-V.

K. Y
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/hv/channel.c   |  2 +-
>  include/linux/hyperv.h | 36 
>  2 files changed, 1 insertion(+), 37 deletions(-)
> 
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index
> deb852238b2d..01d5bdb69770 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -47,7 +47,7 @@ void vmbus_setevent(struct vmbus_channel *channel)
>* For channels marked as in "low latency" mode
>* bypass the monitor page mechanism.
>*/
> - if (channel->offermsg.monitor_allocated && !channel->low_latency) {
> + if (channel->offermsg.monitor_allocated) {
>   vmbus_send_interrupt(channel->offermsg.child_relid);
> 
>   /* Get the child to parent monitor page */ diff --git
> a/include/linux/hyperv.h b/include/linux/hyperv.h index
> b8807da6ef72..09d10a4a34f4 100644
> --- a/include/linux/hyperv.h
> +++ b/include/linux/hyperv.h
> @@ -853,32 +853,6 @@ struct vmbus_channel {
>   struct rcu_head rcu;
> 
>   /*
> -  * For performance critical channels (storage, networking
> -  * etc,), Hyper-V has a mechanism to enhance the throughput
> -  * at the expense of latency:
> -  * When the host is to be signaled, we just set a bit in a shared page
> -  * and this bit will be inspected by the hypervisor within a certain
> -  * window and if the bit is set, the host will be signaled. The window
> -  * of time is the monitor latency - currently around 100 usecs. This
> -  * mechanism improves throughput by:
> -  *
> -  * A) Making the host more efficient - each time it wakes up,
> -  *potentially it will process morev number of packets. The
> -  *monitor latency allows a batch to build up.
> -  * B) By deferring the hypercall to signal, we will also minimize
> -  *the interrupts.
> -  *
> -  * Clearly, these optimizations improve throughput at the expense of
> -  * latency. Furthermore, since the channel is shared for both
> -  * control and data messages, control messages currently suffer
> -  * unnecessary latency adversley impacting performance and boot
> -  * time. To fix this issue, permit tagging the channel as being
> -  * in "low latency" mode. In this mode, we will bypass the monitor
> -  * mechanism.
> -  */
> - bool low_latency;
> -
> - /*
>* NUMA distribution policy:
>* We support teo policies:
>* 1) Balanced: Here all performance critical channels are @@ -926,16
> +900,6 @@ static inline void set_channel_pending_send_size(struct
> vmbus_channel *c,
>   c->outbound.ring_buffer->pending_send_sz = size;  }
> 
> -static inline void set_low_latency_mode(struct vmbus_channel *c) -{
> - c->low_latency = true;
> -}
> -
> -static inline void clear_low_latency_mode(struct vmbus_channel *c) -{
> - c->low_latency = false;
> -}
> -
>  void vmbus_onmessage(void *context);
> 
>  int vmbus_request_offers(void);
> --
> 2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 0/2] staging: wlan-ng: align else if statement to coding standard

2017-02-15 Thread Maksymilian Piechota
PATCHv0:

  - Spaces replaced with tabs

Maksymilian Piechota (1):
  staging: wlan-ng: This patch fixes the checkpatch.pl warning:

else if statement still did not fulfill coding standard requirements.


PATCHv2:

  - else if statement moved to single line

Maksymilian Piechota (1):
  staging: wlan-ng: This patch fixes the checkpatch.pl warning:

Subject was not precise.

PATCHv3:

  - Subject is more precise
  - Changelog text describe every change  

Maksymilian Piechota (1):
  staging: lustre: align else if statement to coding standard

Too much changes for one patch.

PATCHv4:
  
  - Previous patch breaked up to particular patches for every change

Maksymilian Piechota (2):
  staging: lustre: move logical continuations at the end of line
  staging: lustre: move else if statement to a single line

Continuation of the statement should be realigned

PATCHv5:

  - Wrong prefixes in commits and patches titles changed
  - Else if continuation realigned 

Maksymilian Piechota (3):
  staging: wlan-ng: move logical continuations at the end of line
  staging: wlan-ng: move else if statement to a single line
  staging: wlan-ng: realign else if continuation

Lack of patches history. No changelog text for particular patches

PATCHv6:

  - changelog text for patches added
  - patches history added

Maksymilian Piechota (3):
  staging: wlan-ng: move logical continuations at the end of line
  staging: wlan-ng: move else if statement to a single line
  staging: wlan-ng: realign else if continuation

Checkpatch errors appears between patches.

PATCHv7:

  - Changes made from scratch
  - else if statement moved to a single line
  - logical continuation moved at the end of line

Maksymilian Piechota (2):
  staging: wlan-ng: move else if statement to a single line
  staging: wlan-ng: move logical continuation at the end of line

 drivers/staging/wlan-ng/prism2mgmt.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 1/2] staging: wlan-ng: move else if statement to a single line

2017-02-15 Thread Maksymilian Piechota
move else if statement to a single line

Signed-off-by: Maksymilian Piechota 
---
 drivers/staging/wlan-ng/prism2mgmt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
b/drivers/staging/wlan-ng/prism2mgmt.c
index 16fb2d3..a45ff00 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -1307,8 +1307,7 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void 
*msgp)
&& (msg->prismheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 0;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
-   } else
-   if ((msg->wlanheader.status ==
+   } else if ((msg->wlanheader.status ==
 P80211ENUM_msgitem_status_data_ok)
&& (msg->wlanheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 1;
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v7 2/2] staging: wlan-ng: move logical continuation at the end of line

2017-02-15 Thread Maksymilian Piechota
move logical continuations at the end of line

Signed-off-by: Maksymilian Piechota 
---
 drivers/staging/wlan-ng/prism2mgmt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2mgmt.c 
b/drivers/staging/wlan-ng/prism2mgmt.c
index a45ff00..1cc6c9a 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -1308,8 +1308,8 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void 
*msgp)
hw->sniffhdr = 0;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else if ((msg->wlanheader.status ==
-P80211ENUM_msgitem_status_data_ok)
-   && (msg->wlanheader.data == P80211ENUM_truth_true)) {
+  P80211ENUM_msgitem_status_data_ok) &&
+  (msg->wlanheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 1;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else {
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 6/8] vmbus: remove unused low_latency option

2017-02-15 Thread Stephen Hemminger
On Wed, 15 Feb 2017 15:05:18 +
KY Srinivasan  wrote:

> > -Original Message-
> > From: Stephen Hemminger [mailto:step...@networkplumber.org]
> > Sent: Tuesday, February 14, 2017 10:21 PM
> > To: KY Srinivasan ; Haiyan Yang
> > 
> > Cc: de...@linuxdriverproject.org; Stephen Hemminger
> > 
> > Subject: [PATCH 6/8] vmbus: remove unused low_latency option
> > 
> > This was intended for future use, but since the code is currently unused 
> > (and
> > therefore dead and unused), remove it.
> > 
> > It can be restored when there is a use case.  
> 
> Stephen, I do have a use case for this. I wanted to get this into the Greg's 
> tree and then
> Modify both netvsc and storvsc to use it. This is currently shipping as part 
> of Clear Linux
> and makes a significant difference in the boot time on Hyper-V.
> 
> K. Y

Ok, I just saw it had been around since July (4.8) and still no usage


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: visorbus, replace init_timer with setup_timer

2017-02-15 Thread Jiri Slaby
From: Stefan Svinciak 

Newer version is more readable and needs less changes if/when
timer_struct is to be changed.

Signed-off-by: Stefan Svinciak 
Signed-off-by: Jiri Slaby 
Cc: David Kershner 
Cc: Greg Kroah-Hartman 
Cc: 
Cc: 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index aea1aa262b28..55f29ae8e015 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -623,9 +623,7 @@ create_visor_device(struct visor_device *dev)
dev->device.release = visorbus_release_device;
/* keep a reference just for us (now 2) */
get_device(&dev->device);
-   init_timer(&dev->timer);
-   dev->timer.data = (unsigned long)(dev);
-   dev->timer.function = dev_periodic_work;
+   setup_timer(&dev->timer, dev_periodic_work, (unsigned long)dev);
 
/*
 * bus_id must be a unique name with respect to this bus TYPE
-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8712: Fix sparse warnings about endianness

2017-02-15 Thread Larry Finger

On 02/14/2017 08:57 PM, maomao xu wrote:

drivers/staging/rtl8712/rtl871x_xmit.c:350:44: warning: restricted __le32 
degrades to integer

Signed-off-by: maomao xu 



You are using the wrong tree. In the staging-next branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git, there is a patch


commit 07222e535831b916221dd2a48a3047ec7e45dc72
Author: Larry Finger 
Date:   Fri Feb 10 21:30:27 2017 -0600

staging: r8712u: Fix Sparse warning in rtl871x_xmit.c

that already makes that fix. In fact, all the endian issues in that driver are 
resolved. When the compilers were changed to include endian issues with all 
Sparse checks, we started getting patches that silenced the warnings, but broke 
the driver on big-endian hardware. For that reason, I generate the set of 
patches that fixed all of them and tested on a BE laptop that I keep just for 
that purpose.


NACK.

Larry


diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c 
b/drivers/staging/rtl8712/rtl871x_xmit.c
index 4ab82ba..1c2ac28 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.c
+++ b/drivers/staging/rtl8712/rtl871x_xmit.c
@@ -347,7 +347,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt 
*pkt,
 * some settings above.
 */
if (check_fwstate(pmlmepriv, WIFI_MP_STATE))
-   pattrib->priority = (txdesc.txdw1 >> QSEL_SHT) & 0x1f;
+   pattrib->priority = (le32_to_cpu(txdesc.txdw1) >> QSEL_SHT) & 
0x1f;
return _SUCCESS;
 }




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] staging: visorbus, replace init_timer with setup_timer

2017-02-15 Thread Kershner, David A
> -Original Message-
> From: Jiri Slaby [mailto:jsl...@suse.cz]
> Sent: Wednesday, February 15, 2017 11:04 AM
> To: Kershner, David A 
> Cc: linux-ker...@vger.kernel.org; Stefan Svinciak ; Jiri
> Slaby ; Greg Kroah-Hartman
> ; *S-Par-Maintainer
> ; de...@driverdev.osuosl.org
> Subject: [PATCH] staging: visorbus, replace init_timer with setup_timer
> 
> From: Stefan Svinciak 
> 
> Newer version is more readable and needs less changes if/when
> timer_struct is to be changed.
> 
> Signed-off-by: Stefan Svinciak 
> Signed-off-by: Jiri Slaby 
> Cc: David Kershner 
> Cc: Greg Kroah-Hartman 
> Cc: 
> Cc: 

Acked-by: David Kershner 

Looks good and runs nicely on s-Par. 

David Kershner

> ---
>  drivers/staging/unisys/visorbus/visorbus_main.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c
> b/drivers/staging/unisys/visorbus/visorbus_main.c
> index aea1aa262b28..55f29ae8e015 100644
> --- a/drivers/staging/unisys/visorbus/visorbus_main.c
> +++ b/drivers/staging/unisys/visorbus/visorbus_main.c
> @@ -623,9 +623,7 @@ create_visor_device(struct visor_device *dev)
>   dev->device.release = visorbus_release_device;
>   /* keep a reference just for us (now 2) */
>   get_device(&dev->device);
> - init_timer(&dev->timer);
> - dev->timer.data = (unsigned long)(dev);
> - dev->timer.function = dev_periodic_work;
> + setup_timer(&dev->timer, dev_periodic_work, (unsigned long)dev);
> 
>   /*
>* bus_id must be a unique name with respect to this bus TYPE
> --
> 2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging:bcm2048 : Add parentheses around variable x

2017-02-15 Thread Tabrez Khan
On Fri, Feb 3, 2017 at 3:42 PM, Dan Carpenter  wrote:
> On Sat, Dec 03, 2016 at 03:14:26PM +0530, Tabrez khan wrote:
>> Add parentheses around variable x for the readability purpose.
>>
>
> It's not really about readability...
>
> regards,
> dan carpenter
>
 I will resend it again.

-- 
Regards
Tabrez Khan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192u: Fix warnings about endianness

2017-02-15 Thread Dan Carpenter
On Wed, Feb 15, 2017 at 09:33:15AM +0100, Arnd Bergmann wrote:
> I see the same warning was addressed very differently in 99277c1f9962
> ("Staging: rtl8192e: Fix Sparse warning of cast to restricted __le16 in
>  rtllib_crypt_tkip.c"), which was for a close relative of that driver.
> 
> Only one of the two approaches (at most) can be correct, so we
> regardless of your patch either rtl8192e or rtl8192u is broken on
> big-endian machines.

99277c1f9962 ("Staging: rtl8192e: Fix Sparse warning of cast to restricted 
__le16 in
rtllib_crypt_tkip.c") is obviously broken.  Can you send a patch to
change it back?

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/5] pci: set msi_domain_ops as __ro_after_init

2017-02-15 Thread Bjorn Helgaas
[+cc Kees, Thomas, Marc]

Hi Jess,

Thanks for the patch!

On Fri, Feb 10, 2017 at 05:37:56PM -0800, Jess Frazelle wrote:
> Marked msi_domain_ops structs as __ro_after_init when called only during init.
> This protects the data structure from accidental corruption.
> 
> Suggested-by: Kees Cook 
> Signed-off-by: Jess Frazelle 
> ---
>  drivers/pci/host/pci-hyperv.c | 2 +-
>  drivers/pci/host/vmd.c| 2 +-
>  drivers/pci/msi.c | 2 +-

I understand the value of __ro_after_init, but I'm not certain about
sprinkling it around in seemingly random places because it's hard to
know where to put it and whether we put it in all the right places.

How did you choose these three files to change?  There are other
instances of struct msi_domain_ops that use MSI_FLAG_USE_DEF_DOM_OPS.
Should they be changed, too?  If not, is there a rule to figure out
which ones should be made __ro_after_init?

I wonder if adding __ro_after_init is really the best solution.  I
looked at VMD to see how vmd_msi_domain_ops is updated.  Here are the
definitions:

  static struct msi_domain_ops vmd_msi_domain_ops = {
.get_hwirq = vmd_get_hwirq,
.msi_init  = vmd_msi_init,
...
  };

  static struct msi_domain_info vmd_msi_domain_info = {
.flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
 MSI_FLAG_PCI_MSIX,
.ops = &vmd_msi_domain_ops,
...
  };

Both vmd_msi_domain_ops and vmd_msi_domain_info are statically
initialized, but not completely.  Then we pass a pointer to
pci_msi_create_irq_domain(), which fills in defaults for some of the
function pointers that weren't statically initialized:

  vmd_enable_domain()
pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info, ...)
  if (info->flags & MSI_FLAG_USE_DEF_DOM_OPS)
pci_msi_domain_update_dom_ops(info)
  if (ops->set_desc == NULL)
ops->msi_check = pci_msi_domain_check_cap

We know at build-time what all the function pointers will be, so in
principle we should be able to make the struct const, which would be
even better than __ro_after_init.

For example, we could require that callers set every function pointer
before calling pci_msi_create_irq_domain(), using the default ones
(pci_msi_domain_set_desc, pci_msi_domain_check_cap,
pci_msi_domain_handle_error) if it doesn't need to override them,
e.g.,

  static struct msi_domain_ops vmd_msi_domain_ops = {
.get_hwirq = vmd_get_hwirq,
.msi_check = pci_msi_domain_check_cap,
  };

Or we could leave NULL pointers in the structure and have the code
that calls through the function pointers check for NULL and call the
default itself, e.g.,

  if (ops->msi_check)
ops->msi_check(...)
  else
pci_msi_domain_check_cap(...)

It looks like the "USE_DEF_OPS" framework was added by Jiang Liu with
the commits below.  I would CC: him for his thoughts, but I don't
have a current email address.

  aeeb59657c35 ("genirq: Provide default callbacks for msi_domain_ops")
  3878eaefb89a ("PCI/MSI: Enhance core to support hierarchy irqdomain")

Bjorn

>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 3efcc7bdc5fb..f05b93689d8f 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -958,7 +958,7 @@ static irq_hw_number_t hv_msi_domain_ops_get_hwirq(struct 
> msi_domain_info *info,
>   return arg->msi_hwirq;
>  }
> 
> -static struct msi_domain_ops hv_msi_ops = {
> +static struct msi_domain_ops hv_msi_ops __ro_after_init = {
>   .get_hwirq  = hv_msi_domain_ops_get_hwirq,
>   .msi_prepare= pci_msi_prepare,
>   .set_desc   = pci_msi_set_desc,
> diff --git a/drivers/pci/host/vmd.c b/drivers/pci/host/vmd.c
> index 18ef1a93c10a..152c461538e4 100644
> --- a/drivers/pci/host/vmd.c
> +++ b/drivers/pci/host/vmd.c
> @@ -253,7 +253,7 @@ static void vmd_set_desc(msi_alloc_info_t *arg, struct 
> msi_desc *desc)
>   arg->desc = desc;
>  }
> 
> -static struct msi_domain_ops vmd_msi_domain_ops = {
> +static struct msi_domain_ops vmd_msi_domain_ops __ro_after_init = {
>   .get_hwirq  = vmd_get_hwirq,
>   .msi_init   = vmd_msi_init,
>   .msi_free   = vmd_msi_free,
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index 50c5003295ca..93141d5e2d1c 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -1413,7 +1413,7 @@ static void pci_msi_domain_set_desc(msi_alloc_info_t 
> *arg,
>  #define pci_msi_domain_set_desc  NULL
>  #endif
> 
> -static struct msi_domain_ops pci_msi_domain_ops_default = {
> +static struct msi_domain_ops pci_msi_domain_ops_default __ro_after_init = {
>   .set_desc   = pci_msi_domain_set_desc,
>   .msi_check  = pci_msi_domain_check_cap,
>   .handle_error   = pci_msi_domain_handle_error,
> --
> 2.11.0
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/l

Re: [PATCH v2 3/5] pci: set msi_domain_ops as __ro_after_init

2017-02-15 Thread Kees Cook
On Wed, Feb 15, 2017 at 12:33 PM, Bjorn Helgaas  wrote:
> [+cc Kees, Thomas, Marc]
>
> Hi Jess,
>
> Thanks for the patch!
>
> On Fri, Feb 10, 2017 at 05:37:56PM -0800, Jess Frazelle wrote:
>> Marked msi_domain_ops structs as __ro_after_init when called only during 
>> init.
>> This protects the data structure from accidental corruption.
>>
>> Suggested-by: Kees Cook 
>> Signed-off-by: Jess Frazelle 
>> ---
>>  drivers/pci/host/pci-hyperv.c | 2 +-
>>  drivers/pci/host/vmd.c| 2 +-
>>  drivers/pci/msi.c | 2 +-
>
> I understand the value of __ro_after_init, but I'm not certain about
> sprinkling it around in seemingly random places because it's hard to
> know where to put it and whether we put it in all the right places.
>
> How did you choose these three files to change?  There are other
> instances of struct msi_domain_ops that use MSI_FLAG_USE_DEF_DOM_OPS.
> Should they be changed, too?  If not, is there a rule to figure out
> which ones should be made __ro_after_init?
>
> I wonder if adding __ro_after_init is really the best solution.  I
> looked at VMD to see how vmd_msi_domain_ops is updated.  Here are the
> definitions:
>
>   static struct msi_domain_ops vmd_msi_domain_ops = {
> .get_hwirq = vmd_get_hwirq,
> .msi_init  = vmd_msi_init,
> ...
>   };
>
>   static struct msi_domain_info vmd_msi_domain_info = {
> .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
>  MSI_FLAG_PCI_MSIX,
> .ops = &vmd_msi_domain_ops,
> ...
>   };
>
> Both vmd_msi_domain_ops and vmd_msi_domain_info are statically
> initialized, but not completely.  Then we pass a pointer to
> pci_msi_create_irq_domain(), which fills in defaults for some of the
> function pointers that weren't statically initialized:
>
>   vmd_enable_domain()
> pci_msi_create_irq_domain(NULL, &vmd_msi_domain_info, ...)
>   if (info->flags & MSI_FLAG_USE_DEF_DOM_OPS)
> pci_msi_domain_update_dom_ops(info)
>   if (ops->set_desc == NULL)
> ops->msi_check = pci_msi_domain_check_cap
>
> We know at build-time what all the function pointers will be, so in
> principle we should be able to make the struct const, which would be
> even better than __ro_after_init.
>
> For example, we could require that callers set every function pointer
> before calling pci_msi_create_irq_domain(), using the default ones
> (pci_msi_domain_set_desc, pci_msi_domain_check_cap,
> pci_msi_domain_handle_error) if it doesn't need to override them,
> e.g.,
>
>   static struct msi_domain_ops vmd_msi_domain_ops = {
> .get_hwirq = vmd_get_hwirq,
> .msi_check = pci_msi_domain_check_cap,
>   };
>
> Or we could leave NULL pointers in the structure and have the code
> that calls through the function pointers check for NULL and call the
> default itself, e.g.,
>
>   if (ops->msi_check)
> ops->msi_check(...)
>   else
> pci_msi_domain_check_cap(...)
>
> It looks like the "USE_DEF_OPS" framework was added by Jiang Liu with
> the commits below.  I would CC: him for his thoughts, but I don't
> have a current email address.
>
>   aeeb59657c35 ("genirq: Provide default callbacks for msi_domain_ops")
>   3878eaefb89a ("PCI/MSI: Enhance core to support hierarchy irqdomain")

If we can do const, that would be preferred. That's generally easier
to reason about. I ended up doing this to the cdrom ops structure just
the other day:

http://www.openwall.com/lists/kernel-hardening/2017/02/14/2

-Kees

-- 
Kees Cook
Pixel Security
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/5] pci: set msi_domain_ops as __ro_after_init

2017-02-15 Thread Thomas Gleixner
On Wed, 15 Feb 2017, Bjorn Helgaas wrote:
> We know at build-time what all the function pointers will be, so in
> principle we should be able to make the struct const, which would be
> even better than __ro_after_init.

Not everywhere unfortunately. In some instances it's a runtime decision, but
yes, they could be fixed. But there is a downside in doing this. See below.

> For example, we could require that callers set every function pointer
> before calling pci_msi_create_irq_domain(), using the default ones
> (pci_msi_domain_set_desc, pci_msi_domain_check_cap,
> pci_msi_domain_handle_error) if it doesn't need to override them,
> e.g.,
> 
>   static struct msi_domain_ops vmd_msi_domain_ops = {
> .get_hwirq = vmd_get_hwirq,
> .msi_check = pci_msi_domain_check_cap,
>   };
> 
> Or we could leave NULL pointers in the structure and have the code
> that calls through the function pointers check for NULL and call the
> default itself, e.g.,
> 
>   if (ops->msi_check)
> ops->msi_check(...)
>   else
> pci_msi_domain_check_cap(...)
> 
> It looks like the "USE_DEF_OPS" framework was added by Jiang Liu with
> the commits below.  I would CC: him for his thoughts, but I don't
> have a current email address.

Me neither :(

I think I suggested to Jiang to do that 'update with default functions' to

- avoid exporting the world and some more

- have the flexibility to add new functions to the ops w/o updating a
  gazillion of existing usage sites, which has saved us lots of chaising in
  the last years

- avoid the if (ops->ptr) ops->ptr(); else default_fn(); constructs all
  over the place.

I admit I did not think about the fact that this makes the structs non
const.

Mopping that up by exporting the default functions and setting all the
function pointers is tedious and requires a full tree sweep when we add new
stuff. There's also code shared between PCI/platform/DT based stuff, so
that becomes interesting.

Doing the if (ops->ptr) ops->ptr() else default_fn(); dance should be
simpler to pull off. There are not that many sites to look at, but then we
have some of the GICv3 code using the domain ops out of core.

For now doing the __ro_after_init is definitely the simplest and fastest
solution to tighten these statically allocated structures.

I have a look with Marc, what can be done in the long run.

Thanks,

tglx
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8192e: Fix endianness issue

2017-02-15 Thread maomao xu
Fix endianness issue about Mk16_le function

Signed-off-by: maomao xu 

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c 
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index ae103b0..05b66d4 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -162,9 +162,9 @@ static inline u16 Mk16(u8 hi, u8 lo)
 }
 
 
-static inline u16 Mk16_le(u16 *v)
+static inline u16 Mk16_le(__le16 *v)
 {
-   return *v;
+   return le16_to_cpu(*v);
 }
 
 
@@ -253,15 +253,15 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, 
const u16 *TTAK,
PPK[5] = TTAK[4] + IV16;
 
/* Step 2 - 96-bit bijective mixing using S-box */
-   PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
-   PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
-   PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
-   PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
-   PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
-   PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
-
-   PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
-   PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
+   PPK[0] += _S_(PPK[5] ^ Mk16_le((__le16 *) &TK[0]));
+   PPK[1] += _S_(PPK[0] ^ Mk16_le((__le16 *) &TK[2]));
+   PPK[2] += _S_(PPK[1] ^ Mk16_le((__le16 *) &TK[4]));
+   PPK[3] += _S_(PPK[2] ^ Mk16_le((__le16 *) &TK[6]));
+   PPK[4] += _S_(PPK[3] ^ Mk16_le((__le16 *) &TK[8]));
+   PPK[5] += _S_(PPK[4] ^ Mk16_le((__le16 *) &TK[10]));
+
+   PPK[0] += RotR1(PPK[5] ^ Mk16_le((__le16 *) &TK[12]));
+   PPK[1] += RotR1(PPK[0] ^ Mk16_le((__le16 *) &TK[14]));
PPK[2] += RotR1(PPK[1]);
PPK[3] += RotR1(PPK[2]);
PPK[4] += RotR1(PPK[3]);
@@ -273,7 +273,7 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, 
const u16 *TTAK,
WEPSeed[0] = Hi8(IV16);
WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
WEPSeed[2] = Lo8(IV16);
-   WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
+   WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((__le16 *) &TK[0])) >> 1);
 
 #ifdef __BIG_ENDIAN
{
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 01/36] [media] dt-bindings: Add bindings for i.MX media driver

2017-02-15 Thread Steve Longerbeam
Add bindings documentation for the i.MX media driver.

Signed-off-by: Steve Longerbeam 
---
 Documentation/devicetree/bindings/media/imx.txt | 66 +
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx.txt

diff --git a/Documentation/devicetree/bindings/media/imx.txt 
b/Documentation/devicetree/bindings/media/imx.txt
new file mode 100644
index 000..fd5af50
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/imx.txt
@@ -0,0 +1,66 @@
+Freescale i.MX Media Video Device
+=
+
+Video Media Controller node
+---
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.
+
+Required properties:
+- compatible : "fsl,imx-capture-subsystem";
+- ports  : Should contain a list of phandles pointing to camera
+   sensor interface ports of IPU devices
+
+example:
+
+capture-subsystem {
+   compatible = "fsl,capture-subsystem";
+   ports = <&ipu1_csi0>, <&ipu1_csi1>;
+};
+
+fim child node
+--
+
+This is an optional child node of the ipu_csi port nodes. If present and
+available, it enables the Frame Interval Monitor. Its properties can be
+used to modify the method in which the FIM measures frame intervals.
+Refer to Documentation/media/v4l-drivers/imx.rst for more info on the
+Frame Interval Monitor.
+
+Optional properties:
+- fsl,input-capture-channel: an input capture channel and channel flags,
+specified as . The channel number
+must be 0 or 1. The flags can be
+IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, or
+IRQ_TYPE_EDGE_BOTH, and specify which input
+capture signal edge will trigger the input
+capture event. If an input capture channel is
+specified, the FIM will use this method to
+measure frame intervals instead of via the EOF
+interrupt. The input capture method is much
+preferred over EOF as it is not subject to
+interrupt latency errors. However it requires
+routing the VSYNC or FIELD output signals of
+the camera sensor to one of the i.MX input
+capture pads (SD1_DAT0, SD1_DAT1), which also
+gives up support for SD1.
+
+
+mipi_csi2 node
+--
+
+This is the device node for the MIPI CSI-2 Receiver, required for MIPI
+CSI-2 sensors.
+
+Required properties:
+- compatible   : "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";
+- reg   : physical base address and length of the register set;
+- clocks   : the MIPI CSI-2 receiver requires three clocks: hsi_tx
+  (the DPHY clock), video_27m, and eim_podf;
+- clock-names  : must contain "dphy", "cfg", "pix";
+
+Optional properties:
+- interrupts   : must contain two level-triggered interrupts,
+  in order: 100 and 101;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 00/36] i.MX Media Driver

2017-02-15 Thread Steve Longerbeam
In version 4:

Changes suggested by Philipp Zabel  and
Jean-Michel Hautbois :

- split out VDIC from imx-ic-prpvf into a distinct VDIC subdev.

Changes suggested by Philipp Zabel :

- Re-org of pre-process entities. Created an ipuX_ic_prp entity
  that receives on a single sink pad from the CSIs and the VDIC.
  Two source pads route to ipuX_ic_prpenc and ipuX_ic_prpvf. The
  code for ipuX_ic_prpenc and ipuX_ic_prpvf is now identical, which
  adds rotation to ipuX_ic_prpvf.

- renamed media node in DT to capture-subsystem, compatible string to
  "fsl,imx-capture-subsystem".

- the ov564x subdevs get the xclk rate from clk_get_rate() instead of
  attempting to change the rate. "xclk" property in ov564x DT nodes is
  removed.

- changed "pix" clock to IMX6QDL_CLK_EIM_PODF in mipi_csi node.

- added comptible string "snps,dw-mipi-csi2" to mipi_csi node in DT.

- silenced many of the v4l2_info()'s.

- move conversion of ALTERNATE field type to SEQ_BT/TB to output pad
  of ipuX_csiY entity.

- added bounds checks to set_fmt in ipuX_csiY and ipuX_vdic entities.

- Get rid of SMFC entity. CSI frame output via SMFC and IDMAC channel
  is now built into the CSI entities via a new source pad. So CSI
  entities now have two source pads : direct and IDMAC.

- the IPU internal pads (direct between subunuits, not via IDMAC channels),
  should only accept the pixel formats used internally by the IPU:
  MEDIA_BUS_FMT_AYUV8_1X32 and MEDIA_BUS_FMT_ARGB_1X32.

- export V4L2_EVENT_IMX_EOF_TIMEOUT as V4L2_EVENT_FRAME_TIMEOUT for
  general use.

- export imx_media_inherit_controls() as v4l2_pipeline_inherit_controls()
  for general use.

- completely removed dma_buf ring support. There is no capture interface
  or ic-pp subdevs any longer. The CSI and ic-prp enc/vf subdevs now attach
  directly to a capture device node from their IDMAC (non-direct) source pads.


Changes suggested by Javier Martinez Canillas :

- add missing MODULE_DEVICE_TABLE() to video mux subdev.


Changes suggested by Hans Verkuil :

- entity function type MEDIA_ENT_F_MUX renamed to MEDIA_ENT_F_VID_MUX.

- removed use of g_mbus_config subdev op. Sensor bus config is instead
  gotten from the sensor DT node via v4l2_of_parse_endpoint().

- use v4l2_ctrl_handler_setup() for restoring current control values
  in the ov564x subdevs, rather than a custom control cache.


Changes suggested by Russell King :

- re-ordered clock lane and data lane # assignments in device tree.

- fixed module unload.

- propagate the return code from ipu_ic_task_idma_init(), don't start
  streaming if it returned error!


Changes suggested by Laurent Pinchart :

- ov5640 subdev is improved and moved to drivers/media/i2c, along with
  binding docs. The ov5642 subdev has been dropped for now.

- regulator DT properties are now required in ov5640 subdev, and resewt/power
  GPIOs are optional. Created dummy regulator nodes in imx6qdl-sabrelite.dtsi
  for the ov5640 node (the ov5640 regulators are fixed regulators on the
  OV5640 module for sabrelite).

- removed use of endpoint ID in device tree as a way to specify a MIPI CSI-2
  virtual channel for the OV5640. The ov5640 subdev now hard-codes the
  virtual channel to 1 until a new subdev API becomes available to allow
  run-time virtual channel selection.


Other changes:

- v4l2-compliance fixes.

- since dma_buf ring support is gone, the VDIC subdev is modified to
  potentially receive frames from a future output device node on its
  IDMAC sink pad.

- fixed mbus pixel format enumeration and selection. The source pads
  and capture device select the correct formats based on the sink
  formats. For example the capture device can only report and allow
  selecting an RGB format if the attached source pad's format is RGB.
  Likewise for YUV space, with the added benefit that the capture
  device can select a YUV planar format in this case, and the attached
  subdev will comply and output planar.

- stripped out sensor input OF properties and parsing for now. It is
  problematic since there is currently no subdev op so that the bridge
  can retrieve this information and use for VIDIOC_{ENUM|S|G}_INPUT.

- modified imx6-mipi-csi2 subdev to comply strictly with the MIPI CSI-2
  startup sequence described in the i.MX6 reference manual.



Philipp Zabel (6):
  ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their
connections
  add mux and video interface bridge entity functions
  platform: add video-multiplexer subdevice driver
  media: imx: csi: fix crop rectangle changes in set_fmt
  media: imx: csi: add frame skipping support
  media: imx: csi: fix crop rectangle reset in sink set_fmt

Russell King (3):
  media: imx: add support for bayer formats
  media: imx: csi: add support for bayer formats
  media: imx: mipi-csi2: enable setting and getting of frame rates

Steve Longerbeam (27):
  [media] dt-bindings: Add bindings for i.MX media driver
  ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node
  ARM: 

[PATCH v4 02/36] ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node

2017-02-15 Thread Steve Longerbeam
Add to the MIPI CSI2 receiver node: compatible strings,
interrupt sources, and clocks.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6qdl.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 61569c8..aac70b9 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -1125,7 +1125,14 @@
};
 
mipi_csi: mipi@021dc000 {
+   compatible = "fsl,imx6-mipi-csi2", 
"snps,dw-mipi-csi2";
reg = <0x021dc000 0x4000>;
+   interrupts = <0 100 0x04>, <0 101 0x04>;
+   clocks = <&clks IMX6QDL_CLK_HSI_TX>,
+<&clks IMX6QDL_CLK_VIDEO_27M>,
+<&clks IMX6QDL_CLK_EIM_PODF>;
+   clock-names = "dphy", "cfg", "pix";
+   status = "disabled";
};
 
mipi_dsi: mipi@021e {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 05/36] ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround

2017-02-15 Thread Steve Longerbeam
There is a pin conflict with GPIO_6. This pin functions as a power
input pin to the OV5642 camera sensor, but ENET uses it as the h/w
workaround for erratum ERR006687, to wake-up the ARM cores on normal
RX and TX packet done events. So we need to remove the h/w workaround
to support the OV5642. The result is that the CPUidle driver will no
longer allow entering the deep idle states on the sabrelite.

This is a partial revert of

commit 6261c4c8f13e ("ARM: dts: imx6qdl-sabrelite: use GPIO_6 for FEC
interrupt.")
commit a28eeb43ee57 ("ARM: dts: imx6: tag boards that have the HW workaround
for ERR006687")

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
index 1f9076e..795b5a5 100644
--- a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
@@ -271,9 +271,6 @@
txd1-skew-ps = <0>;
txd2-skew-ps = <0>;
txd3-skew-ps = <0>;
-   interrupts-extended = <&gpio1 6 IRQ_TYPE_LEVEL_HIGH>,
- <&intc 0 119 IRQ_TYPE_LEVEL_HIGH>;
-   fsl,err006687-workaround-present;
status = "okay";
 };
 
@@ -374,7 +371,6 @@
MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL   0x1b030
/* Phy reset */
MX6QDL_PAD_EIM_D23__GPIO3_IO23  0x000b0
-   MX6QDL_PAD_GPIO_6__ENET_IRQ 0x000b1
>;
};
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 08/36] ARM: dts: imx6-sabreauto: create i2cmux for i2c3

2017-02-15 Thread Steve Longerbeam
The sabreauto uses a steering pin to select between the SDA signal on
i2c3 bus, and a data-in pin for an SPI NOR chip. Use i2cmux to control
this steering pin. Idle state of the i2cmux selects SPI NOR. This is not
a classic way to use i2cmux, since one side of the mux selects something
other than an i2c bus, but it works and is probably the cleanest
solution. Note that if one thread is attempting to access SPI NOR while
another thread is accessing i2c3, the SPI NOR access will fail since the
i2cmux has selected the SDA pin rather than SPI NOR data-in. This couldn't
be avoided in any case, the board is not designed to allow concurrent
i2c3 and SPI NOR functions (and the default device-tree does not enable
SPI NOR anyway).

Devices hanging off i2c3 should now be defined under i2cmux, so
that the steering pin can be properly controlled to access those
devices. The port expanders (MAX7310) are thus moved into i2cmux.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 65 +---
 1 file changed, 44 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index 52390ba..cace88c 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -108,6 +108,44 @@
default-brightness-level = <7>;
status = "okay";
};
+
+   i2cmux {
+   compatible = "i2c-mux-gpio";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_i2c3mux>;
+   mux-gpios = <&gpio5 4 0>;
+   i2c-parent = <&i2c3>;
+   idle-state = <0>;
+
+   i2c@1 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <1>;
+
+   max7310_a: gpio@30 {
+   compatible = "maxim,max7310";
+   reg = <0x30>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   max7310_b: gpio@32 {
+   compatible = "maxim,max7310";
+   reg = <0x32>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   max7310_c: gpio@34 {
+   compatible = "maxim,max7310";
+   reg = <0x34>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+   };
+   };
 };
 
 &clks {
@@ -291,27 +329,6 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";
-
-   max7310_a: gpio@30 {
-   compatible = "maxim,max7310";
-   reg = <0x30>;
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
-
-   max7310_b: gpio@32 {
-   compatible = "maxim,max7310";
-   reg = <0x32>;
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
-
-   max7310_c: gpio@34 {
-   compatible = "maxim,max7310";
-   reg = <0x34>;
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
 };
 
 &iomuxc {
@@ -419,6 +436,12 @@
>;
};
 
+   pinctrl_i2c3mux: i2c3muxgrp {
+   fsl,pins = <
+   MX6QDL_PAD_EIM_A24__GPIO5_IO04 0x0b0b1
+   >;
+   };
+
pinctrl_pwm3: pwm1grp {
fsl,pins = <
MX6QDL_PAD_SD4_DAT1__PWM3_OUT   0x1b0b1
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 09/36] ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b

2017-02-15 Thread Steve Longerbeam
The reset pin to the port expander chip (MAX7310) is controlled by a gpio,
so define a reset-gpios property to control it. There are three MAX7310's
on the SabreAuto CPU card (max7310_[abc]), but all use the same pin for
their reset. Since all can't acquire the same pin, assign it to max7310_b,
that chip is needed by more functions (usb and adv7180).

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index cace88c..967c3b8 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -136,6 +136,9 @@
reg = <0x32>;
gpio-controller;
#gpio-cells = <2>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_max7310>;
+   reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
};
 
max7310_c: gpio@34 {
@@ -442,6 +445,12 @@
>;
};
 
+   pinctrl_max7310: max7310grp {
+   fsl,pins = <
+   MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x1b0b0
+   >;
+   };
+
pinctrl_pwm3: pwm1grp {
fsl,pins = <
MX6QDL_PAD_SD4_DAT1__PWM3_OUT   0x1b0b1
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 06/36] ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors

2017-02-15 Thread Steve Longerbeam
Adds the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor.
Both hang off the same i2c2 bus, so they require different (and non-
default) i2c slave addresses.

The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux.

The OV5640 connects to the input port on the MIPI CSI-2 receiver on
mipi_csi.

The OV5642 node is disabled temporarily while the subdev driver is
cleaned up and submitted later.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6dl-sabrelite.dts   |   5 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts|   5 ++
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi | 148 +++
 3 files changed, 158 insertions(+)

diff --git a/arch/arm/boot/dts/imx6dl-sabrelite.dts 
b/arch/arm/boot/dts/imx6dl-sabrelite.dts
index 0f06ca5..cfd5110 100644
--- a/arch/arm/boot/dts/imx6dl-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6dl-sabrelite.dts
@@ -48,3 +48,8 @@
model = "Freescale i.MX6 DualLite SABRE Lite Board";
compatible = "fsl,imx6dl-sabrelite", "fsl,imx6dl";
 };
+
+&ipu1_csi1_from_ipu1_csi1_mux {
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+};
diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 66d10d8..e00fc06 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -52,3 +52,8 @@
 &sata {
status = "okay";
 };
+
+&ipu1_csi1_from_mipi_vc1 {
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+};
diff --git a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
index 795b5a5..7958a0c 100644
--- a/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
@@ -39,6 +39,8 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
+
+#include 
 #include 
 #include 
 
@@ -94,6 +96,42 @@
pinctrl-0 = <&pinctrl_can_xcvr>;
gpio = <&gpio1 2 GPIO_ACTIVE_LOW>;
};
+
+   reg_1p5v: regulator@4 {
+   compatible = "regulator-fixed";
+   reg = <4>;
+   regulator-name = "1P5V";
+   regulator-min-microvolt = <150>;
+   regulator-max-microvolt = <150>;
+   regulator-always-on;
+   };
+
+   reg_1p8v: regulator@5 {
+   compatible = "regulator-fixed";
+   reg = <5>;
+   regulator-name = "1P8V";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   };
+
+   reg_2p8v: regulator@6 {
+   compatible = "regulator-fixed";
+   reg = <6>;
+   regulator-name = "2P8V";
+   regulator-min-microvolt = <280>;
+   regulator-max-microvolt = <280>;
+   regulator-always-on;
+   };
+   };
+
+   mipi_xclk: mipi_xclk {
+   compatible = "pwm-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2200>;
+   clock-output-names = "mipi_pwm3";
+   pwms = <&pwm3 0 45>; /* 1 / 45 ns = 22 MHz */
+   status = "okay";
};
 
gpio-keys {
@@ -220,6 +258,22 @@
};
 };
 
+&ipu1_csi0_from_ipu1_csi0_mux {
+   bus-width = <8>;
+   data-shift = <12>; /* Lines 19:12 used */
+   hsync-active = <1>;
+   vync-active = <1>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+   remote-endpoint = <&ov5642_to_ipu1_csi0_mux>;
+};
+
+&ipu1_csi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu1_csi0>;
+};
+
 &audmux {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_audmux>;
@@ -299,6 +353,53 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c2>;
status = "okay";
+
+   ov5640: camera@40 {
+   compatible = "ovti,ov5640";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ov5640>;
+   reg = <0x40>;
+   clocks = <&mipi_xclk>;
+   clock-names = "xclk";
+   DOVDD-supply = <®_1p8v>;
+   AVDD-supply = <®_2p8v>;
+   DVDD-supply = <®_1p5v>;
+   reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; /* NANDF_D5 */
+   pwdn-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* NANDF_WP_B */
+
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ov5640_to_mipi_csi2: endpoint {
+   remote-endpoint = <&mipi_csi2_in>;
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+   };
+  

[PATCH v4 10/36] ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture

2017-02-15 Thread Steve Longerbeam
Add pinctrl groups for both GPT input capture channels.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index 967c3b8..495709f 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -457,6 +457,18 @@
>;
};
 
+   pinctrl_gpt_input_capture0: gptinputcapture0grp {
+   fsl,pins = <
+   MX6QDL_PAD_SD1_DAT0__GPT_CAPTURE1   0x1b0b0
+   >;
+   };
+
+   pinctrl_gpt_input_capture1: gptinputcapture1grp {
+   fsl,pins = <
+   MX6QDL_PAD_SD1_DAT1__GPT_CAPTURE2   0x1b0b0
+   >;
+   };
+
pinctrl_spdif: spdifgrp {
fsl,pins = <
MX6QDL_PAD_KEY_COL3__SPDIF_IN 0x1b0b0
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 11/36] ARM: dts: imx6-sabreauto: add the ADV7180 video decoder

2017-02-15 Thread Steve Longerbeam
Enables the ADV7180 decoder sensor. The ADV7180 connects to the
parallel-bus mux input on ipu1_csi0_mux.

The ADV7180 power pin is via max7310_b port expander.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 58 
 1 file changed, 58 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index 495709f..f03057b 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -124,6 +124,21 @@
#size-cells = <0>;
reg = <1>;
 
+   adv7180: camera@21 {
+   compatible = "adi,adv7180";
+   reg = <0x21>;
+   powerdown-gpios = <&max7310_b 2 
GPIO_ACTIVE_LOW>;
+   interrupt-parent = <&gpio1>;
+   interrupts = <27 0x8>;
+
+   port {
+   adv7180_to_ipu1_csi0_mux: endpoint {
+   remote-endpoint = 
<&ipu1_csi0_mux_from_parallel_sensor>;
+   bus-width = <8>;
+   };
+   };
+   };
+
max7310_a: gpio@30 {
compatible = "maxim,max7310";
reg = <0x30>;
@@ -151,6 +166,25 @@
};
 };
 
+&ipu1_csi0_from_ipu1_csi0_mux {
+   bus-width = <8>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+   remote-endpoint = <&adv7180_to_ipu1_csi0_mux>;
+   bus-width = <8>;
+};
+
+&ipu1_csi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu1_csi0>;
+
+   /* enable frame interval monitor on this port */
+   fim {
+   status = "okay";
+   };
+};
+
 &clks {
assigned-clocks = <&clks IMX6QDL_PLL4_BYPASS_SRC>,
  <&clks IMX6QDL_PLL4_BYPASS>,
@@ -445,6 +479,30 @@
>;
};
 
+   pinctrl_ipu1_csi0: ipu1csi0grp {
+   fsl,pins = <
+   MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04   0x1b0b0
+   MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05   0x1b0b0
+   MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06   0x1b0b0
+   MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07   0x1b0b0
+   MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08   0x1b0b0
+   MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09   0x1b0b0
+   MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18  0x1b0b0
+   MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19  0x1b0b0
+   MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK 0x1b0b0
+   MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC0x1b0b0
+   MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC   0x1b0b0
+   >;
+   };
+
pinctrl_max7310: max7310grp {
fsl,pins = <
MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x1b0b0
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 12/36] add mux and video interface bridge entity functions

2017-02-15 Thread Steve Longerbeam
From: Philipp Zabel 

Signed-off-by: Philipp Zabel 

- renamed MEDIA_ENT_F_MUX to MEDIA_ENT_F_VID_MUX

Signed-off-by: Steve Longerbeam 
---
 Documentation/media/uapi/mediactl/media-types.rst | 22 ++
 include/uapi/linux/media.h|  6 ++
 2 files changed, 28 insertions(+)

diff --git a/Documentation/media/uapi/mediactl/media-types.rst 
b/Documentation/media/uapi/mediactl/media-types.rst
index 3e03dc2..023be29 100644
--- a/Documentation/media/uapi/mediactl/media-types.rst
+++ b/Documentation/media/uapi/mediactl/media-types.rst
@@ -298,6 +298,28 @@ Types and flags used to represent the media graph elements
  received on its sink pad and outputs the statistics data on
  its source pad.
 
+-  ..  row 29
+
+   ..  _MEDIA-ENT-F-MUX:
+
+   -  ``MEDIA_ENT_F_MUX``
+
+   - Video multiplexer. An entity capable of multiplexing must have at
+ least two sink pads and one source pad, and must pass the video
+ frame(s) received from the active sink pad to the source pad. Video
+ frame(s) from the inactive sink pads are discarded.
+
+-  ..  row 30
+
+   ..  _MEDIA-ENT-F-VID-IF-BRIDGE:
+
+   -  ``MEDIA_ENT_F_VID_IF_BRIDGE``
+
+   - Video interface bridge. A video interface bridge entity must have at
+ least one sink pad and one source pad. It receives video frame(s) on
+ its sink pad in one bus format (HDMI, eDP, MIPI CSI-2, ...) and
+ converts them and outputs them on its source pad in another bus format
+ (eDP, MIPI CSI-2, parallel, ...).
 
 ..  tabularcolumns:: |p{5.5cm}|p{12.0cm}|
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 4890787..fac96c6 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -105,6 +105,12 @@ struct media_device_info {
 #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS  (MEDIA_ENT_F_BASE + 0x4006)
 
 /*
+ * Switch and bridge entitites
+ */
+#define MEDIA_ENT_F_VID_MUX(MEDIA_ENT_F_BASE + 0x5001)
+#define MEDIA_ENT_F_VID_IF_BRIDGE  (MEDIA_ENT_F_BASE + 0x5002)
+
+/*
  * Connectors
  */
 /* It is a responsibility of the entity drivers to add connectors and links */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 13/36] [media] v4l2: add a frame timeout event

2017-02-15 Thread Steve Longerbeam
Add a new FRAME_TIMEOUT event to signal that a video capture or
output device has timed out waiting for reception or transmit
completion of a video frame.

Signed-off-by: Steve Longerbeam 
---
 Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +
 Documentation/media/videodev2.h.rst.exceptions  | 1 +
 include/uapi/linux/videodev2.h  | 1 +
 3 files changed, 7 insertions(+)

diff --git a/Documentation/media/uapi/v4l/vidioc-dqevent.rst 
b/Documentation/media/uapi/v4l/vidioc-dqevent.rst
index 8d663a7..dd77d9b 100644
--- a/Documentation/media/uapi/v4l/vidioc-dqevent.rst
+++ b/Documentation/media/uapi/v4l/vidioc-dqevent.rst
@@ -197,6 +197,11 @@ call.
the regions changes. This event has a struct
:c:type:`v4l2_event_motion_det`
associated with it.
+* - ``V4L2_EVENT_FRAME_TIMEOUT``
+  - 7
+  - This event is triggered when the video capture or output device
+   has timed out waiting for the reception or transmit completion of
+   a frame of video.
 * - ``V4L2_EVENT_PRIVATE_START``
   - 0x0800
   - Base event number for driver-private events.
diff --git a/Documentation/media/videodev2.h.rst.exceptions 
b/Documentation/media/videodev2.h.rst.exceptions
index e11a0d0..5b0f767 100644
--- a/Documentation/media/videodev2.h.rst.exceptions
+++ b/Documentation/media/videodev2.h.rst.exceptions
@@ -459,6 +459,7 @@ replace define V4L2_EVENT_CTRL event-type
 replace define V4L2_EVENT_FRAME_SYNC event-type
 replace define V4L2_EVENT_SOURCE_CHANGE event-type
 replace define V4L2_EVENT_MOTION_DET event-type
+replace define V4L2_EVENT_FRAME_TIMEOUT event-type
 replace define V4L2_EVENT_PRIVATE_START event-type
 
 replace define V4L2_EVENT_CTRL_CH_VALUE ctrl-changes-flags
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 46e8a2e3..e174c45 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -2132,6 +2132,7 @@ struct v4l2_streamparm {
 #define V4L2_EVENT_FRAME_SYNC  4
 #define V4L2_EVENT_SOURCE_CHANGE   5
 #define V4L2_EVENT_MOTION_DET  6
+#define V4L2_EVENT_FRAME_TIMEOUT   7
 #define V4L2_EVENT_PRIVATE_START   0x0800
 
 /* Payload for V4L2_EVENT_VSYNC */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

2017-02-15 Thread Steve Longerbeam
v4l2_pipeline_inherit_controls() will add the v4l2 controls from
all subdev entities in a pipeline to a given video device.

Signed-off-by: Steve Longerbeam 
---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++
 include/media/v4l2-mc.h   | 25 
 2 files changed, 73 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-mc.c 
b/drivers/media/v4l2-core/v4l2-mc.c
index 303980b..09d4d97 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+struct media_entity *start_entity)
+{
+   struct media_device *mdev = start_entity->graph_obj.mdev;
+   struct media_entity *entity;
+   struct media_graph graph;
+   struct v4l2_subdev *sd;
+   int ret;
+
+   ret = media_graph_walk_init(&graph, mdev);
+   if (ret)
+   return ret;
+
+   media_graph_walk_start(&graph, start_entity);
+
+   while ((entity = media_graph_walk_next(&graph))) {
+   if (!is_media_entity_v4l2_subdev(entity))
+   continue;
+
+   sd = media_entity_to_v4l2_subdev(entity);
+
+   ret = v4l2_ctrl_add_handler(vfd->ctrl_handler,
+   sd->ctrl_handler,
+   NULL);
+   if (ret)
+   break;
+   }
+
+   media_graph_walk_cleanup(&graph);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(__v4l2_pipeline_inherit_controls);
+
+int v4l2_pipeline_inherit_controls(struct video_device *vfd,
+  struct media_entity *start_entity)
+{
+   struct media_device *mdev = start_entity->graph_obj.mdev;
+   int ret;
+
+   mutex_lock(&mdev->graph_mutex);
+   ret = __v4l2_pipeline_inherit_controls(vfd, start_entity);
+   mutex_unlock(&mdev->graph_mutex);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_pipeline_inherit_controls);
+
 /* 
-
  * Pipeline power management
  *
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index 2634d9d..9848e77 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -171,6 +171,17 @@ void v4l_disable_media_source(struct video_device *vdev);
  */
 int v4l_vb2q_enable_media_source(struct vb2_queue *q);
 
+/**
+ * v4l2_pipeline_inherit_controls - Add the v4l2 controls from all
+ * subdev entities in a pipeline to
+ * the given video device.
+ * @vfd: the video device
+ * @start_entity: Starting entity
+ */
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+struct media_entity *start_entity);
+int v4l2_pipeline_inherit_controls(struct video_device *vfd,
+  struct media_entity *start_entity);
 
 /**
  * v4l2_pipeline_pm_use - Update the use count of an entity
@@ -231,6 +242,20 @@ static inline int v4l_vb2q_enable_media_source(struct 
vb2_queue *q)
return 0;
 }
 
+static inline int __v4l2_pipeline_inherit_controls(
+   struct video_device *vfd,
+   struct media_entity *start_entity)
+{
+   return 0;
+}
+
+static inline int v4l2_pipeline_inherit_controls(
+   struct video_device *vfd,
+   struct media_entity *start_entity)
+{
+   return 0;
+}
+
 static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
 {
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 03/36] ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections

2017-02-15 Thread Steve Longerbeam
From: Philipp Zabel 

This patch adds the device tree graph connecting the input multiplexers
to the IPU CSIs and the MIPI-CSI2 gasket on i.MX6. The MIPI_IPU
multiplexers are added as children of the iomuxc-gpr syscon device node.
On i.MX6Q/D two two-input multiplexers in front of IPU1 CSI0 and IPU2
CSI1 allow to select between CSI0/1 parallel input pads and the MIPI
CSI-2 virtual channels 0/3.
On i.MX6DL/S two five-input multiplexers in front of IPU1 CSI0 and IPU1
CSI1 allow to select between CSI0/1 parallel input pads and any of the
four MIPI CSI-2 virtual channels.

Signed-off-by: Philipp Zabel 

--

- Removed some dangling/unused endpoints (ipu2_csi0_from_csi2ipu)
- Renamed the mipi virtual channel endpoint labels, from "mipi_csiX_..."
  to "mipi_vcX...".
- Added input endpoint anchors to the video muxes for the connections
  from parallel sensors.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6dl.dtsi  | 180 +
 arch/arm/boot/dts/imx6q.dtsi   | 116 ++
 arch/arm/boot/dts/imx6qdl.dtsi |  10 ++-
 3 files changed, 305 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi
index 1ade195..371288a 100644
--- a/arch/arm/boot/dts/imx6dl.dtsi
+++ b/arch/arm/boot/dts/imx6dl.dtsi
@@ -181,6 +181,186 @@
  "di0", "di1";
 };
 
+&gpr {
+   ipu1_csi0_mux: ipu1_csi0_mux@34 {
+   compatible = "video-multiplexer";
+   reg = <0x34>;
+   bit-mask = <0x7>;
+   bit-shift = <0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+
+   ipu1_csi0_mux_from_mipi_vc0: endpoint {
+   remote-endpoint = <&mipi_vc0_to_ipu1_csi0_mux>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   ipu1_csi0_mux_from_mipi_vc1: endpoint {
+   remote-endpoint = <&mipi_vc1_to_ipu1_csi0_mux>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   ipu1_csi0_mux_from_mipi_vc2: endpoint {
+   remote-endpoint = <&mipi_vc2_to_ipu1_csi0_mux>;
+   };
+   };
+
+   port@3 {
+   reg = <3>;
+
+   ipu1_csi0_mux_from_mipi_vc3: endpoint {
+   remote-endpoint = <&mipi_vc3_to_ipu1_csi0_mux>;
+   };
+   };
+
+   port@4 {
+   reg = <4>;
+
+   ipu1_csi0_mux_from_parallel_sensor: endpoint {
+   };
+   };
+
+   port@5 {
+   reg = <5>;
+
+   ipu1_csi0_mux_to_ipu1_csi0: endpoint {
+   remote-endpoint = 
<&ipu1_csi0_from_ipu1_csi0_mux>;
+   };
+   };
+   };
+
+   ipu1_csi1_mux: ipu1_csi1_mux@34 {
+   compatible = "video-multiplexer";
+   reg = <0x34>;
+   bit-mask = <0x7>;
+   bit-shift = <3>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+
+   ipu1_csi1_mux_from_mipi_vc0: endpoint {
+   remote-endpoint = <&mipi_vc0_to_ipu1_csi1_mux>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   ipu1_csi1_mux_from_mipi_vc1: endpoint {
+   remote-endpoint = <&mipi_vc1_to_ipu1_csi1_mux>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   ipu1_csi1_mux_from_mipi_vc2: endpoint {
+   remote-endpoint = <&mipi_vc2_to_ipu1_csi1_mux>;
+   };
+   };
+
+   port@3 {
+   reg = <3>;
+
+   ipu1_csi1_mux_from_mipi_vc3: endpoint {
+   remote-endpoint = <&mipi_vc3_to_ipu1_csi1_mux>;
+   };
+   };
+
+   port@4 {
+   reg = <4>;
+
+   ipu1_csi1_mux_from_parallel_sensor: endpoint {
+   };
+   };
+
+   port@5 {
+   reg = <5>;
+
+   ipu1_csi1_mux_to_ipu1_csi1: endpoint {
+   remote-endpoint = 
<&ipu1_csi1_from_ipu1_csi1_mux>;
+   };
+   };
+   };
+};
+
+&ipu1_csi1 {
+   ipu1_csi1_from_ipu1_csi1_mux: endpoint {
+   r

[PATCH v4 15/36] platform: add video-multiplexer subdevice driver

2017-02-15 Thread Steve Longerbeam
From: Philipp Zabel 

This driver can handle SoC internal and external video bus multiplexers,
controlled either by register bit fields or by a GPIO. The subdevice
passes through frame interval and mbus configuration of the active input
to the output side.

Signed-off-by: Sascha Hauer 
Signed-off-by: Philipp Zabel 

--

- fixed a cut&paste error in vidsw_remove(): v4l2_async_register_subdev()
  should be unregister.

- added media_entity_cleanup() and v4l2_device_unregister_subdev()
  to vidsw_remove().

- added missing MODULE_DEVICE_TABLE().
  Suggested-by: Javier Martinez Canillas 

- there was a line left over from a previous iteration that negated
  the new way of determining the pad count just before it which
  has been removed (num_pads = of_get_child_count(np)).

- Philipp Zabel has developed a set of patches that allow adding
  to the subdev async notifier waiting list using a chaining method
  from the async registered callbacks (v4l2_of_subdev_registered()
  and the prep patches for that). For now, I've removed the use of
  v4l2_of_subdev_registered() for the vidmux driver's registered
  callback. This doesn't affect the functionality of this driver,
  but allows for it to be merged now, before adding the chaining
  support.

Signed-off-by: Steve Longerbeam 
---
 .../bindings/media/video-multiplexer.txt   |  59 +++
 drivers/media/platform/Kconfig |   8 +
 drivers/media/platform/Makefile|   2 +
 drivers/media/platform/video-multiplexer.c | 474 +
 4 files changed, 543 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/video-multiplexer.txt
 create mode 100644 drivers/media/platform/video-multiplexer.c

diff --git a/Documentation/devicetree/bindings/media/video-multiplexer.txt 
b/Documentation/devicetree/bindings/media/video-multiplexer.txt
new file mode 100644
index 000..9d133d9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/video-multiplexer.txt
@@ -0,0 +1,59 @@
+Video Multiplexer
+=
+
+Video multiplexers allow to select between multiple input ports. Video received
+on the active input port is passed through to the output port. Muxes described
+by this binding may be controlled by a syscon register bitfield or by a GPIO.
+
+Required properties:
+- compatible : should be "video-multiplexer"
+- reg: should be register base of the register containing the control bitfield
+- bit-mask: bitmask of the control bitfield in the control register
+- bit-shift: bit offset of the control bitfield in the control register
+- gpios: alternatively to reg, bit-mask, and bit-shift, a single GPIO phandle
+  may be given to switch between two inputs
+- #address-cells: should be <1>
+- #size-cells: should be <0>
+- port@*: at least three port nodes containing endpoints connecting to the
+  source and sink devices according to of_graph bindings. The last port is
+  the output port, all others are inputs.
+
+Example:
+
+syscon {
+   compatible = "syscon", "simple-mfd";
+
+   mux {
+   compatible = "video-multiplexer";
+   /* Single bit (1 << 19) in syscon register 0x04: */
+   reg = <0x04>;
+   bit-mask = <1>;
+   bit-shift = <19>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   mux_in0: endpoint {
+   remote-endpoint = <&video_source0_out>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   mux_in1: endpoint {
+   remote-endpoint = <&video_source1_out>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   mux_out: endpoint {
+   remote-endpoint = <&capture_interface_in>;
+   };
+   };
+   };
+};
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index c9106e1..3d60d4c 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -74,6 +74,14 @@ config VIDEO_M32R_AR_M64278
  To compile this driver as a module, choose M here: the
  module will be called arv.
 
+config VIDEO_MULTIPLEXER
+   tristate "Video Multiplexer"
+   depends on VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
+   help
+ This driver provides support for SoC internal N:1 video bus
+ multiplexers controlled by register bitfields as well as external
+ 2:1 video multiplexers controlled by a single GPIO.
+
 config VIDEO_OMAP3
tristate "OMAP 3 Camera support"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 349ddf6..31bfa99 100644
--- a/drivers/media/platform/Ma

[PATCH v4 04/36] ARM: dts: imx6qdl: add capture-subsystem device

2017-02-15 Thread Steve Longerbeam
Signed-off-by: Steve Longerbeam 
---
 arch/arm/boot/dts/imx6dl.dtsi | 5 +
 arch/arm/boot/dts/imx6q.dtsi  | 5 +
 2 files changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi
index 371288a..f1743fc 100644
--- a/arch/arm/boot/dts/imx6dl.dtsi
+++ b/arch/arm/boot/dts/imx6dl.dtsi
@@ -100,6 +100,11 @@
};
};
 
+   capture-subsystem {
+   compatible = "fsl,imx-capture-subsystem";
+   ports = <&ipu1_csi0>, <&ipu1_csi1>;
+   };
+
display-subsystem {
compatible = "fsl,imx-display-subsystem";
ports = <&ipu1_di0>, <&ipu1_di1>;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index b833b0d..4cc6579 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -206,6 +206,11 @@
};
};
 
+   capture-subsystem {
+   compatible = "fsl,imx-capture-subsystem";
+   ports = <&ipu1_csi0>, <&ipu1_csi1>, <&ipu2_csi0>, <&ipu2_csi1>;
+   };
+
display-subsystem {
compatible = "fsl,imx-display-subsystem";
ports = <&ipu1_di0>, <&ipu1_di1>, <&ipu2_di0>, <&ipu2_di1>;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 07/36] ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors

2017-02-15 Thread Steve Longerbeam
Enables the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor.

The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux.

The OV5640 connects to the input port on the MIPI CSI-2 receiver on
mipi_csi.

Until the OV5652 sensor module compatible with the SabreSD becomes
available for testing, the ov5642 node is currently disabled.
---
 arch/arm/boot/dts/imx6dl-sabresd.dts   |   5 ++
 arch/arm/boot/dts/imx6q-sabresd.dts|   5 ++
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 114 -
 3 files changed, 123 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx6dl-sabresd.dts 
b/arch/arm/boot/dts/imx6dl-sabresd.dts
index 1e45f2f..9607afe 100644
--- a/arch/arm/boot/dts/imx6dl-sabresd.dts
+++ b/arch/arm/boot/dts/imx6dl-sabresd.dts
@@ -15,3 +15,8 @@
model = "Freescale i.MX6 DualLite SABRE Smart Device Board";
compatible = "fsl,imx6dl-sabresd", "fsl,imx6dl";
 };
+
+&ipu1_csi1_from_ipu1_csi1_mux {
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+};
diff --git a/arch/arm/boot/dts/imx6q-sabresd.dts 
b/arch/arm/boot/dts/imx6q-sabresd.dts
index 9cbdfe7..527772b 100644
--- a/arch/arm/boot/dts/imx6q-sabresd.dts
+++ b/arch/arm/boot/dts/imx6q-sabresd.dts
@@ -23,3 +23,8 @@
 &sata {
status = "okay";
 };
+
+&ipu1_csi1_from_mipi_vc1 {
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+};
diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi 
b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
index 55ef535..f4e13c6 100644
--- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
@@ -10,6 +10,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include 
 #include 
 #include 
 
@@ -146,6 +147,36 @@
};
 };
 
+&ipu1_csi0_from_ipu1_csi0_mux {
+   bus-width = <8>;
+   data-shift = <12>; /* Lines 19:12 used */
+   hsync-active = <1>;
+   vsync-active = <1>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+   remote-endpoint = <&ov5642_to_ipu1_csi0_mux>;
+};
+
+&ipu1_csi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu1_csi0>;
+};
+
+&mipi_csi {
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+
+   mipi_csi2_in: endpoint {
+   remote-endpoint = <&ov5640_to_mipi_csi2>;
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+   };
+   };
+};
+
 &audmux {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_audmux>;
@@ -214,7 +245,32 @@
0x8014 /* 4:FN_DMICCDAT */
0x /* 5:Default */
>;
-   };
+   };
+
+   ov5642: camera@3c {
+   compatible = "ovti,ov5642";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ov5642>;
+   clocks = <&clks IMX6QDL_CLK_CKO>;
+   clock-names = "xclk";
+   reg = <0x3c>;
+   DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+   AVDD-supply = <&vgen3_reg>;  /* 2.8v, rev C board is VGEN3
+   rev B board is VGEN5 */
+   DVDD-supply = <&vgen2_reg>;  /* 1.5v*/
+   pwdn-gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>;
+   reset-gpios = <&gpio1 17 GPIO_ACTIVE_LOW>;
+   status = "disabled";
+
+   port {
+   ov5642_to_ipu1_csi0_mux: endpoint {
+   remote-endpoint = 
<&ipu1_csi0_mux_from_parallel_sensor>;
+   bus-width = <8>;
+   hsync-active = <1>;
+   vsync-active = <1>;
+   };
+   };
+   };
 };
 
 &i2c2 {
@@ -223,6 +279,32 @@
pinctrl-0 = <&pinctrl_i2c2>;
status = "okay";
 
+   ov5640: camera@3c {
+   compatible = "ovti,ov5640";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ov5640>;
+   reg = <0x3c>;
+   clocks = <&clks IMX6QDL_CLK_CKO>;
+   clock-names = "xclk";
+   DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+   AVDD-supply = <&vgen3_reg>;  /* 2.8v, rev C board is VGEN3
+   rev B board is VGEN5 */
+   DVDD-supply = <&vgen2_reg>;  /* 1.5v*/
+   pwdn-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>;
+   reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
+
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ov5640_to_mipi_csi2: endpoint {
+   remote-endpoint = <&mipi_csi2_in>;
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+   };
+   };
+   };
+
pmic: pfuze100@08 {
compatible = "fsl,pfuze100";
reg = <

[PATCH v4 20/36] media: imx: Add CSI subdev driver

2017-02-15 Thread Steve Longerbeam
This is a media entity subdevice for the i.MX Camera
Sensor Interface module.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/Kconfig |   13 +
 drivers/staging/media/imx/Makefile|2 +
 drivers/staging/media/imx/imx-media-csi.c | 1220 +
 3 files changed, 1235 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx-media-csi.c

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index 722ed55..e27ad6d 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -5,3 +5,16 @@ config VIDEO_IMX_MEDIA
  Say yes here to enable support for video4linux media controller
  driver for the i.MX5/6 SOC.
 
+if VIDEO_IMX_MEDIA
+menu "i.MX5/6 Media Sub devices"
+
+config VIDEO_IMX_CSI
+   tristate "i.MX5/6 Camera Sensor Interface driver"
+   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
+   select VIDEOBUF2_DMA_CONTIG
+   default y
+   ---help---
+ A video4linux camera sensor interface driver for i.MX5/6.
+
+endmenu
+endif
diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 4606a3a..c054490 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -4,3 +4,5 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
+
+obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
new file mode 100644
index 000..0343fc3
--- /dev/null
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -0,0 +1,1220 @@
+/*
+ * V4L2 Capture CSI Subdev for Freescale i.MX5/6 SOC
+ *
+ * Copyright (c) 2014-2016 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "imx-media.h"
+
+/*
+ * Min/Max supported width and heights.
+ *
+ * We allow planar output, so we have to align width by 16 pixels
+ * to meet IDMAC alignment requirements.
+ *
+ * TODO: move this into pad format negotiation, if capture device
+ * has not requested planar formats, we should allow 8 pixel
+ * alignment.
+ */
+#define MIN_W   176
+#define MIN_H   144
+#define MAX_W  4096
+#define MAX_H  4096
+#define W_ALIGN4 /* multiple of 16 pixels */
+#define H_ALIGN1 /* multiple of 2 lines */
+#define S_ALIGN1 /* multiple of 2 */
+
+struct csi_priv {
+   struct device *dev;
+   struct ipu_soc *ipu;
+   struct imx_media_dev *md;
+   struct v4l2_subdev sd;
+   struct media_pad pad[CSI_NUM_PADS];
+   int active_output_pad;
+   int csi_id;
+   int smfc_id;
+
+   struct ipuv3_channel *idmac_ch;
+   struct ipu_smfc *smfc;
+   struct ipu_csi *csi;
+
+   struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS];
+   const struct imx_media_pixfmt *cc[CSI_NUM_PADS];
+   struct v4l2_rect crop;
+
+   /* the video device at IDMAC output pad */
+   struct imx_media_video_dev *vdev;
+
+   /* active vb2 buffers to send to video dev sink */
+   struct imx_media_buffer *active_vb2_buf[2];
+   struct imx_media_dma_buf underrun_buf;
+
+   int ipu_buf_num;  /* ipu double buffer index: 0-1 */
+
+   /* the sink for the captured frames */
+   struct media_entity *sink;
+   enum ipu_csi_dest dest;
+   /* the source subdev */
+   struct v4l2_subdev *src_sd;
+
+   /* the mipi virtual channel number at link validate */
+   int vc_num;
+
+   /* the attached sensor at stream on */
+   struct imx_media_subdev *sensor;
+
+   spinlock_t irqlock; /* protect eof_irq handler */
+   struct timer_list eof_timeout_timer;
+   int eof_irq;
+   int nfb4eof_irq;
+
+   struct v4l2_ctrl_handler ctrl_hdlr;
+   struct imx_media_fim *fim;
+
+   bool power_on;  /* power is on */
+   bool stream_on; /* streaming is on */
+   bool last_eof;  /* waiting for last EOF at stream off */
+   struct completion last_eof_comp;
+};
+
+static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev)
+{
+   return container_of(sdev, struct csi_priv, sd);
+}
+
+static void csi_idmac_put_ipu_resources(struct csi_priv *priv)
+{
+   if (!IS_ERR_OR_NULL(priv->idmac_ch))
+   ipu_idmac_put(priv->idmac_ch);
+   priv->idmac_ch = NULL;
+
+   if (!IS_ERR_OR_NULL(priv->smfc))
+   ipu_smfc_put(priv->smfc);
+   priv->smfc = NULL;
+}
+
+static int csi_idmac_get_ipu_resources(struct csi_priv *priv)
+

[PATCH v4 17/36] media: Add userspace header file for i.MX

2017-02-15 Thread Steve Longerbeam
This adds a header file for use by userspace programs wanting to interact
with the i.MX media driver. It defines custom v4l2 controls and events
generated by the i.MX v4l2 subdevices.

Signed-off-by: Steve Longerbeam 
---
 include/uapi/media/Kbuild |  1 +
 include/uapi/media/imx.h  | 29 +
 2 files changed, 30 insertions(+)
 create mode 100644 include/uapi/media/imx.h

diff --git a/include/uapi/media/Kbuild b/include/uapi/media/Kbuild
index aafaa5a..fa78958 100644
--- a/include/uapi/media/Kbuild
+++ b/include/uapi/media/Kbuild
@@ -1 +1,2 @@
 # UAPI Header export list
+header-y += imx.h
diff --git a/include/uapi/media/imx.h b/include/uapi/media/imx.h
new file mode 100644
index 000..1fdd1c1
--- /dev/null
+++ b/include/uapi/media/imx.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014-2015 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the
+ * License, or (at your option) any later version
+ */
+
+#ifndef __UAPI_MEDIA_IMX_H__
+#define __UAPI_MEDIA_IMX_H__
+
+/*
+ * events from the subdevs
+ */
+#define V4L2_EVENT_IMX_CLASS  V4L2_EVENT_PRIVATE_START
+#define V4L2_EVENT_IMX_NFB4EOF(V4L2_EVENT_IMX_CLASS + 1)
+#define V4L2_EVENT_IMX_FRAME_INTERVAL (V4L2_EVENT_IMX_CLASS + 2)
+
+enum imx_ctrl_id {
+   V4L2_CID_IMX_MOTION = (V4L2_CID_USER_IMX_BASE + 0),
+   V4L2_CID_IMX_FIM_ENABLE,
+   V4L2_CID_IMX_FIM_NUM,
+   V4L2_CID_IMX_FIM_TOLERANCE_MIN,
+   V4L2_CID_IMX_FIM_TOLERANCE_MAX,
+   V4L2_CID_IMX_FIM_NUM_SKIP,
+};
+
+#endif
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 18/36] media: Add i.MX media core driver

2017-02-15 Thread Steve Longerbeam
Add the core media driver for i.MX SOC.

Signed-off-by: Steve Longerbeam 
---
 Documentation/media/v4l-drivers/imx.rst   | 542 +
 drivers/staging/media/Kconfig |   2 +
 drivers/staging/media/Makefile|   1 +
 drivers/staging/media/imx/Kconfig |   7 +
 drivers/staging/media/imx/Makefile|   6 +
 drivers/staging/media/imx/TODO|  36 ++
 drivers/staging/media/imx/imx-media-dev.c | 487 +++
 drivers/staging/media/imx/imx-media-fim.c | 471 +++
 drivers/staging/media/imx/imx-media-internal-sd.c | 349 +++
 drivers/staging/media/imx/imx-media-of.c  | 267 
 drivers/staging/media/imx/imx-media-utils.c   | 701 ++
 drivers/staging/media/imx/imx-media.h | 297 +
 include/media/imx.h   |  15 +
 include/uapi/linux/v4l2-controls.h|   4 +
 14 files changed, 3185 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx.rst
 create mode 100644 drivers/staging/media/imx/Kconfig
 create mode 100644 drivers/staging/media/imx/Makefile
 create mode 100644 drivers/staging/media/imx/TODO
 create mode 100644 drivers/staging/media/imx/imx-media-dev.c
 create mode 100644 drivers/staging/media/imx/imx-media-fim.c
 create mode 100644 drivers/staging/media/imx/imx-media-internal-sd.c
 create mode 100644 drivers/staging/media/imx/imx-media-of.c
 create mode 100644 drivers/staging/media/imx/imx-media-utils.c
 create mode 100644 drivers/staging/media/imx/imx-media.h
 create mode 100644 include/media/imx.h

diff --git a/Documentation/media/v4l-drivers/imx.rst 
b/Documentation/media/v4l-drivers/imx.rst
new file mode 100644
index 000..f085e43
--- /dev/null
+++ b/Documentation/media/v4l-drivers/imx.rst
@@ -0,0 +1,542 @@
+i.MX Video Capture Driver
+=
+
+Introduction
+
+
+The Freescale i.MX5/6 contains an Image Processing Unit (IPU), which
+handles the flow of image frames to and from capture devices and
+display devices.
+
+For image capture, the IPU contains the following internal subunits:
+
+- Image DMA Controller (IDMAC)
+- Camera Serial Interface (CSI)
+- Image Converter (IC)
+- Sensor Multi-FIFO Controller (SMFC)
+- Image Rotator (IRT)
+- Video De-Interlacing or Combining Block (VDIC)
+
+The IDMAC is the DMA controller for transfer of image frames to and from
+memory. Various dedicated DMA channels exist for both video capture and
+display paths. During transfer, the IDMAC is also capable of vertical
+image flip, 8x8 block transfer (see IRT description), pixel component
+re-ordering (for example UYVY to YUYV) within the same colorspace, and
+even packed <--> planar conversion. It can also perform a simple
+de-interlacing by interleaving even and odd lines during transfer
+(without motion compensation which requires the VDIC).
+
+The CSI is the backend capture unit that interfaces directly with
+camera sensors over Parallel, BT.656/1120, and MIPI CSI-2 busses.
+
+The IC handles color-space conversion, resizing (downscaling and
+upscaling), horizontal flip, and 90/270 degree rotation operations.
+
+There are three independent "tasks" within the IC that can carry out
+conversions concurrently: pre-process encoding, pre-process viewfinder,
+and post-processing. Within each task, conversions are split into three
+sections: downsizing section, main section (upsizing, flip, colorspace
+conversion, and graphics plane combining), and rotation section.
+
+The IPU time-shares the IC task operations. The time-slice granularity
+is one burst of eight pixels in the downsizing section, one image line
+in the main processing section, one image frame in the rotation section.
+
+The SMFC is composed of four independent FIFOs that each can transfer
+captured frames from sensors directly to memory concurrently via four
+IDMAC channels.
+
+The IRT carries out 90 and 270 degree image rotation operations. The
+rotation operation is carried out on 8x8 pixel blocks at a time. This
+operation is supported by the IDMAC which handles the 8x8 block transfer
+along with block reordering, in coordination with vertical flip.
+
+The VDIC handles the conversion of interlaced video to progressive, with
+support for different motion compensation modes (low, medium, and high
+motion). The deinterlaced output frames from the VDIC can be sent to the
+IC pre-process viewfinder task for further conversions. The VDIC also
+contains a Combiner that combines two image planes, with alpha blending
+and color keying.
+
+In addition to the IPU internal subunits, there are also two units
+outside the IPU that are also involved in video capture on i.MX:
+
+- MIPI CSI-2 Receiver for camera sensors with the MIPI CSI-2 bus
+  interface. This is a Synopsys DesignWare core.
+- Two video multiplexers for selecting among multiple sensor inputs
+  to send to a CSI.
+
+For more info, ref

[PATCH v4 19/36] media: imx: Add Capture Device Interface

2017-02-15 Thread Steve Longerbeam
This is the capture device interface driver that provides the v4l2
user interface. Frames can be received from various sources:

- directly from CSI for capturing unconverted images directly from
  camera sensors.

- from the IC pre-process encode task.

- from the IC pre-process viewfinder task.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/Makefile|   2 +-
 drivers/staging/media/imx/imx-media-capture.c | 654 ++
 2 files changed, 655 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/media/imx/imx-media-capture.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index ba8e4fb..4606a3a 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -3,4 +3,4 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
-
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
diff --git a/drivers/staging/media/imx/imx-media-capture.c 
b/drivers/staging/media/imx/imx-media-capture.c
new file mode 100644
index 000..fbf6067
--- /dev/null
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -0,0 +1,654 @@
+/*
+ * Video Capture Subdev for Freescale i.MX5/6 SOC
+ *
+ * Copyright (c) 2012-2016 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "imx-media.h"
+
+struct capture_priv {
+   struct imx_media_video_dev vdev;
+
+   struct v4l2_subdev*src_sd;
+   int   src_sd_pad;
+   struct device *dev;
+
+   struct media_pipeline mp;
+   struct imx_media_dev  *md;
+
+   struct media_pad  vdev_pad;
+
+   struct mutex  mutex;   /* capture device mutex */
+
+   /* the videobuf2 queue */
+   struct vb2_queue   q;
+   /* list of ready imx_media_buffer's from q */
+   struct list_head   ready_q;
+   /* protect ready_q */
+   spinlock_t q_lock;
+
+   /* controls inherited from subdevs */
+   struct v4l2_ctrl_handler ctrl_hdlr;
+
+   /* misc status */
+   bool  stop;  /* streaming is stopping */
+};
+
+#define to_capture_priv(v) container_of(v, struct capture_priv, vdev)
+
+/* In bytes, per queue */
+#define VID_MEM_LIMIT  SZ_64M
+
+static struct vb2_ops capture_qops;
+
+/*
+ * Video ioctls follow
+ */
+
+static int vidioc_querycap(struct file *file, void *fh,
+  struct v4l2_capability *cap)
+{
+   struct capture_priv *priv = video_drvdata(file);
+
+   strncpy(cap->driver, "imx-media-capture", sizeof(cap->driver) - 1);
+   strncpy(cap->card, "imx-media-capture", sizeof(cap->card) - 1);
+   snprintf(cap->bus_info, sizeof(cap->bus_info),
+"platform:%s", dev_name(priv->dev));
+
+   return 0;
+}
+
+static int capture_enum_fmt_vid_cap(struct file *file, void *fh,
+   struct v4l2_fmtdesc *f)
+{
+   u32 fourcc;
+   int ret;
+
+   ret = imx_media_enum_format(&fourcc, NULL, f->index, true, true);
+   if (ret)
+   return ret;
+
+   f->pixelformat = fourcc;
+
+   return 0;
+}
+
+static int capture_g_fmt_vid_cap(struct file *file, void *fh,
+struct v4l2_format *f)
+{
+   struct capture_priv *priv = video_drvdata(file);
+
+   *f = priv->vdev.fmt;
+
+   return 0;
+}
+
+static int capture_try_fmt_vid_cap(struct file *file, void *fh,
+  struct v4l2_format *f)
+{
+   struct capture_priv *priv = video_drvdata(file);
+   struct v4l2_subdev_format fmt_src;
+   const struct imx_media_pixfmt *cc, *src_cc;
+   u32 fourcc;
+   int ret;
+
+   fourcc = f->fmt.pix.pixelformat;
+   cc = imx_media_find_format(fourcc, 0, true, true);
+   if (!cc) {
+   imx_media_enum_format(&fourcc, NULL, 0, true, true);
+   cc = imx_media_find_format(fourcc, 0, true, true);
+   }
+
+   /*
+* user frame dimensions are the same as src_sd's pad.
+*/
+   fmt_src.pad = priv->src_sd_pad;
+   fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+   ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src);
+   if (ret)
+   return ret;
+
+   /*
+* but we can allow planar pixel formats if the src_sd's
+* pad configured a YUV format
+*/
+   src_cc = imx_media_find_format(0, fmt_src.format.code, true

[PATCH v4 21/36] media: imx: Add VDIC subdev driver

2017-02-15 Thread Steve Longerbeam
This is a media entity subdevice driver for the i.MX Video De-Interlacing
or Combining Block. So far this entity does not implement the Combining
function but only motion compensated deinterlacing. Video frames are
received from the CSI and are routed to the IC PRPVF entity.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/Makefile |   1 +
 drivers/staging/media/imx/imx-media-vdic.c | 886 +
 2 files changed, 887 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx-media-vdic.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index c054490..1f01520 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -4,5 +4,6 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
diff --git a/drivers/staging/media/imx/imx-media-vdic.c 
b/drivers/staging/media/imx/imx-media-vdic.c
new file mode 100644
index 000..5bb21e9
--- /dev/null
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -0,0 +1,886 @@
+/*
+ * V4L2 Deinterlacer Subdev for Freescale i.MX5/6 SOC
+ *
+ * Copyright (c) 2017 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "imx-media.h"
+
+/*
+ * This subdev implements two different video pipelines:
+ *
+ * CSI -> VDIC
+ *
+ * In this pipeline, the CSI sends a single interlaced field F(n-1)
+ * directly to the VDIC (and optionally the following field F(n)
+ * can be sent to memory via IDMAC channel 13). This pipeline only works
+ * in VDIC's high motion mode, which only requires a single field for
+ * processing. The other motion modes (low and medium) require three
+ * fields, so this pipeline does not work in those modes. Also, it is
+ * not clear how this pipeline can deal with the various field orders
+ * (sequential BT/TB, interlaced BT/TB).
+ *
+ * MEM -> CH8,9,10 -> VDIC
+ *
+ * In this pipeline, previous field F(n-1), current field F(n), and next
+ * field F(n+1) are transferred to the VDIC via IDMAC channels 8,9,10.
+ * These memory buffers can come from a video output or mem2mem device.
+ * All motion modes are supported by this pipeline.
+ *
+ * The "direct" CSI->VDIC pipeline requires no DMA, but it can only be
+ * used in high motion mode.
+ */
+
+struct vdic_priv;
+
+struct vdic_pipeline_ops {
+   int (*setup)(struct vdic_priv *priv);
+   void (*start)(struct vdic_priv *priv);
+   void (*stop)(struct vdic_priv *priv);
+   void (*disable)(struct vdic_priv *priv);
+};
+
+/*
+ * Min/Max supported width and heights.
+ */
+#define MIN_W   176
+#define MIN_H   144
+#define MAX_W_VDIC  968
+#define MAX_H_VDIC 2048
+#define W_ALIGN4 /* multiple of 16 pixels */
+#define H_ALIGN1 /* multiple of 2 lines */
+#define S_ALIGN1 /* multiple of 2 */
+
+struct vdic_priv {
+   struct device*dev;
+   struct ipu_soc   *ipu;
+   struct imx_media_dev *md;
+   struct v4l2_subdev   sd;
+   int ipu_id;
+
+   /* IPU units we require */
+   struct ipu_vdi *vdi;
+
+   struct media_pad pad[VDIC_NUM_PADS];
+   int active_input_pad;
+
+   struct ipuv3_channel *vdi_in_ch_p; /* F(n-1) transfer channel */
+   struct ipuv3_channel *vdi_in_ch;   /* F(n) transfer channel */
+   struct ipuv3_channel *vdi_in_ch_n; /* F(n+1) transfer channel */
+
+   /* pipeline operations */
+   struct vdic_pipeline_ops *ops;
+
+   /* current and previous input buffers indirect path */
+   struct imx_media_buffer *curr_in_buf;
+   struct imx_media_buffer *prev_in_buf;
+
+   /*
+* translated field type, input line stride, and field size
+* for indirect path
+*/
+   u32 fieldtype;
+   u32 in_stride;
+   u32 field_size;
+
+   /* the source (a video device or subdev) */
+   struct media_entity *src;
+   /* the sink that will receive the progressive out buffers */
+   struct v4l2_subdev *sink_sd;
+
+   /* the attached sensor at stream on */
+   struct imx_media_subdev *sensor;
+
+   /* the video standard from sensor at time of streamon */
+   v4l2_std_id std;
+
+   struct v4l2_mbus_framefmt format_mbus[VDIC_NUM_PADS];
+   const struct imx_media_pixfmt *cc[VDIC_NUM_PADS];
+
+   /* the video device at IDMAC input pad */
+   struct imx_media_video_dev *vdev;
+
+   bool csi_direct; 

[PATCH v4 23/36] media: imx: Add MIPI CSI-2 Receiver subdev driver

2017-02-15 Thread Steve Longerbeam
Adds MIPI CSI-2 Receiver subdev driver. This subdev is required
for sensors with a MIPI CSI2 interface.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/Makefile |   1 +
 drivers/staging/media/imx/imx6-mipi-csi2.c | 573 +
 2 files changed, 574 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx6-mipi-csi2.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 878a126..3569625 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
+obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c 
b/drivers/staging/media/imx/imx6-mipi-csi2.c
new file mode 100644
index 000..23dca80
--- /dev/null
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -0,0 +1,573 @@
+/*
+ * MIPI CSI-2 Receiver Subdev for Freescale i.MX6 SOC.
+ *
+ * Copyright (c) 2012-2017 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "imx-media.h"
+
+/*
+ * there must be 5 pads: 1 input pad from sensor, and
+ * the 4 virtual channel output pads
+ */
+#define CSI2_SINK_PAD   0
+#define CSI2_NUM_SINK_PADS  1
+#define CSI2_NUM_SRC_PADS   4
+#define CSI2_NUM_PADS   5
+
+struct csi2_dev {
+   struct device  *dev;
+   struct v4l2_subdev  sd;
+   struct media_pad   pad[CSI2_NUM_PADS];
+   struct v4l2_mbus_framefmt format_mbus;
+   struct clk *dphy_clk;
+   struct clk *cfg_clk;
+   struct clk *pix_clk; /* what is this? */
+   void __iomem   *base;
+   struct v4l2_of_bus_mipi_csi2 bus;
+   boolon;
+   boolstream_on;
+   boolsrc_linked;
+   boolsink_linked[CSI2_NUM_SRC_PADS];
+};
+
+#define DEVICE_NAME "imx6-mipi-csi2"
+
+/* Register offsets */
+#define CSI2_VERSION0x000
+#define CSI2_N_LANES0x004
+#define CSI2_PHY_SHUTDOWNZ  0x008
+#define CSI2_DPHY_RSTZ  0x00c
+#define CSI2_RESETN 0x010
+#define CSI2_PHY_STATE  0x014
+#define PHY_STOPSTATEDATA_BIT   4
+#define PHY_STOPSTATEDATA(n)BIT(PHY_STOPSTATEDATA_BIT + (n))
+#define PHY_RXCLKACTIVEHS   BIT(8)
+#define PHY_RXULPSCLKNOTBIT(9)
+#define PHY_STOPSTATECLKBIT(10)
+#define CSI2_DATA_IDS_1 0x018
+#define CSI2_DATA_IDS_2 0x01c
+#define CSI2_ERR1   0x020
+#define CSI2_ERR2   0x024
+#define CSI2_MSK1   0x028
+#define CSI2_MSK2   0x02c
+#define CSI2_PHY_TST_CTRL0  0x030
+#define PHY_TESTCLRBIT(0)
+#define PHY_TESTCLKBIT(1)
+#define CSI2_PHY_TST_CTRL1  0x034
+#define PHY_TESTEN BIT(16)
+#define CSI2_SFT_RESET  0xf00
+
+static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev *sdev)
+{
+   return container_of(sdev, struct csi2_dev, sd);
+}
+
+static void csi2_enable(struct csi2_dev *csi2, bool enable)
+{
+   if (enable) {
+   writel(0x1, csi2->base + CSI2_PHY_SHUTDOWNZ);
+   writel(0x1, csi2->base + CSI2_DPHY_RSTZ);
+   writel(0x1, csi2->base + CSI2_RESETN);
+   } else {
+   writel(0x0, csi2->base + CSI2_PHY_SHUTDOWNZ);
+   writel(0x0, csi2->base + CSI2_DPHY_RSTZ);
+   writel(0x0, csi2->base + CSI2_RESETN);
+   }
+}
+
+static void csi2_set_lanes(struct csi2_dev *csi2)
+{
+   int lanes = csi2->bus.num_data_lanes;
+
+   writel(lanes - 1, csi2->base + CSI2_N_LANES);
+}
+
+static void dw_mipi_csi2_phy_write(struct csi2_dev *csi2,
+  u32 test_code, u32 test_data)
+{
+   /* Clear PHY test interface */
+   writel(PHY_TESTCLR, csi2->base + CSI2_PHY_TST_CTRL0);
+   writel(0x0, csi2->base + CSI2_PHY_TST_CTRL1);
+   writel(0x0, csi2->base + CSI2_PHY_TST_CTRL0);
+
+   /* Raise test interface strobe signal */
+   writel(PHY_TESTCLK, csi2->base + CSI2_PHY_TST_CTRL0);
+
+   /* Configure address write on falling edge and lower strobe signal */
+   writel(PHY_TESTEN | test_code, csi2->base + CSI2_PHY_TST_CTRL1);
+   writel(0x0, csi2->base + CSI2_PHY_TST_CTRL0);
+
+   /* Configure data write on rising edge and raise strobe signal */
+   writel(test_data, csi2->base + CSI2_PHY_TST_CTRL1);
+   writel(PHY_TESTCLK, csi2->base + CSI2_PHY_TST_CTRL0);
+
+   /* Clear strobe signa

[PATCH v4 22/36] media: imx: Add IC subdev drivers

2017-02-15 Thread Steve Longerbeam
This is a set of four media entity subdevice drivers for the i.MX
Image Converter:

- Pre-process Router: Takes input frames from CSI0, CSI1, or VDIC.
  Two output pads enable either or both of the preprocess tasks
  below. If the input is from one of the CSIs, both proprocess task
  links can be enabled to process frames from that CSI simultaneously.
  If the input is the VDIC, only the Pre-processing Viewfinder task
  link can be enabled.

- Pre-processing Encode task: video frames are routed directly from
  the CSI and can be scaled, color-space converted, and rotated.
  Scaled output is limited to 1024x1024 resolution. Output frames
  are routed to the capture device.

- Pre-processing Viewfinder task: this task can perform the same
  conversions as the pre-process encode task, but in addition can
  be used for hardware motion compensated deinterlacing. Frames can
  come either directly from the CSI or from the VDIC. Scaled output
  is limited to 1024x1024 resolution. Output frames are routed to
  the capture device.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/Makefile  |2 +
 drivers/staging/media/imx/imx-ic-common.c   |  113 +++
 drivers/staging/media/imx/imx-ic-prp.c  |  427 ++
 drivers/staging/media/imx/imx-ic-prpencvf.c | 1116 +++
 drivers/staging/media/imx/imx-ic.h  |   38 +
 5 files changed, 1696 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx-ic-common.c
 create mode 100644 drivers/staging/media/imx/imx-ic-prp.c
 create mode 100644 drivers/staging/media/imx/imx-ic-prpencvf.c
 create mode 100644 drivers/staging/media/imx/imx-ic.h

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 1f01520..878a126 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -1,9 +1,11 @@
 imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o
 imx-media-common-objs := imx-media-utils.o imx-media-fim.o
+imx-media-ic-objs := imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o
 
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
diff --git a/drivers/staging/media/imx/imx-ic-common.c 
b/drivers/staging/media/imx/imx-ic-common.c
new file mode 100644
index 000..cfdd490
--- /dev/null
+++ b/drivers/staging/media/imx/imx-ic-common.c
@@ -0,0 +1,113 @@
+/*
+ * V4L2 Image Converter Subdev for Freescale i.MX5/6 SOC
+ *
+ * Copyright (c) 2014-2016 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include "imx-media.h"
+#include "imx-ic.h"
+
+#define IC_TASK_PRP IC_NUM_TASKS
+#define IC_NUM_OPS  (IC_NUM_TASKS + 1)
+
+static struct imx_ic_ops *ic_ops[IC_NUM_OPS] = {
+   [IC_TASK_PRP]= &imx_ic_prp_ops,
+   [IC_TASK_ENCODER]= &imx_ic_prpencvf_ops,
+   [IC_TASK_VIEWFINDER] = &imx_ic_prpencvf_ops,
+};
+
+static int imx_ic_probe(struct platform_device *pdev)
+{
+   struct imx_media_internal_sd_platformdata *pdata;
+   struct imx_ic_priv *priv;
+   int ret;
+
+   priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+   if (!priv)
+   return -ENOMEM;
+
+   platform_set_drvdata(pdev, &priv->sd);
+   priv->dev = &pdev->dev;
+
+   /* get our ipu_id, grp_id and IC task id */
+   pdata = priv->dev->platform_data;
+   priv->ipu_id = pdata->ipu_id;
+   switch (pdata->grp_id) {
+   case IMX_MEDIA_GRP_ID_IC_PRP:
+   priv->task_id = IC_TASK_PRP;
+   break;
+   case IMX_MEDIA_GRP_ID_IC_PRPENC:
+   priv->task_id = IC_TASK_ENCODER;
+   break;
+   case IMX_MEDIA_GRP_ID_IC_PRPVF:
+   priv->task_id = IC_TASK_VIEWFINDER;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   v4l2_subdev_init(&priv->sd, ic_ops[priv->task_id]->subdev_ops);
+   v4l2_set_subdevdata(&priv->sd, priv);
+   priv->sd.internal_ops = ic_ops[priv->task_id]->internal_ops;
+   priv->sd.entity.ops = ic_ops[priv->task_id]->entity_ops;
+   priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_SCALER;
+   priv->sd.dev = &pdev->dev;
+   priv->sd.owner = THIS_MODULE;
+   priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+   priv->sd.grp_id = pdata->grp_id;
+   strncpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name));
+
+   ret = ic_ops[priv->task_id]->init(priv);
+   if (ret)
+   return ret;
+
+   re

[PATCH v4 25/36] ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers

2017-02-15 Thread Steve Longerbeam
Enable i.MX v4l2 media staging driver. For video capture on i.MX, the
video multiplexer subdev is required. On the SabreAuto, the ADV7180
video decoder is required along with i2c-mux-gpio. The Sabrelite
and SabreSD require the OV5640 and the SabreLite requires PWM clocks
for the OV5640.

Increase max zoneorder to allow larger video buffer allocations.

Signed-off-by: Steve Longerbeam 
---
 arch/arm/configs/imx_v6_v7_defconfig | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index cbe7faf..daeb164 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -51,6 +51,7 @@ CONFIG_PREEMPT_VOLUNTARY=y
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_CMA=y
+CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_CMDLINE="noinitrd console=ttymxc0,115200"
 CONFIG_KEXEC=y
 CONFIG_CPU_FREQ=y
@@ -174,13 +175,13 @@ CONFIG_INPUT_MISC=y
 CONFIG_INPUT_MMA8450=y
 CONFIG_SERIO_SERPORT=m
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_IMX=y
 CONFIG_SERIAL_IMX_CONSOLE=y
 CONFIG_SERIAL_FSL_LPUART=y
 CONFIG_SERIAL_FSL_LPUART_CONSOLE=y
 # CONFIG_I2C_COMPAT is not set
 CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_MUX=y
 CONFIG_I2C_MUX_GPIO=y
 # CONFIG_I2C_HELPER_AUTO is not set
 CONFIG_I2C_ALGOPCF=m
@@ -194,11 +195,11 @@ CONFIG_GPIO_SYSFS=y
 CONFIG_GPIO_MC9S08DZ60=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_GPIO_STMPE=y
-CONFIG_POWER_SUPPLY=y
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_IMX=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_POWER_RESET_SYSCON_POWEROFF=y
+CONFIG_POWER_SUPPLY=y
 CONFIG_SENSORS_GPIO_FAN=y
 CONFIG_SENSORS_IIO_HWMON=y
 CONFIG_THERMAL=y
@@ -221,14 +222,20 @@ CONFIG_REGULATOR_PFUZE100=y
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_CAMERA_SUPPORT=y
 CONFIG_MEDIA_RC_SUPPORT=y
+CONFIG_MEDIA_CONTROLLER=y
+CONFIG_VIDEO_V4L2_SUBDEV_API=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
 CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_VIDEO_MULTIPLEXER=y
 CONFIG_SOC_CAMERA=y
 CONFIG_V4L_MEM2MEM_DRIVERS=y
 CONFIG_VIDEO_CODA=y
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+CONFIG_VIDEO_ADV7180=m
+CONFIG_VIDEO_OV5640=m
 CONFIG_SOC_CAMERA_OV2640=y
 CONFIG_IMX_IPUV3_CORE=y
 CONFIG_DRM=y
@@ -338,6 +345,9 @@ CONFIG_FSL_EDMA=y
 CONFIG_IMX_SDMA=y
 CONFIG_MXS_DMA=y
 CONFIG_STAGING=y
+CONFIG_STAGING_MEDIA=y
+CONFIG_VIDEO_IMX_MEDIA=y
+CONFIG_COMMON_CLK_PWM=y
 CONFIG_IIO=y
 CONFIG_VF610_ADC=y
 CONFIG_MPL3115=y
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 26/36] media: imx: add support for bayer formats

2017-02-15 Thread Steve Longerbeam
From: Russell King 

Add the bayer formats to imx-media's list of supported pixel and bus
formats.

Signed-off-by: Russell King 

- added a bayer boolean to struct imx_media_pixfmt.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-utils.c | 68 +
 drivers/staging/media/imx/imx-media.h   |  1 +
 2 files changed, 69 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-utils.c 
b/drivers/staging/media/imx/imx-media-utils.c
index 55603d9..6855560 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -61,6 +61,74 @@ static const struct imx_media_pixfmt imx_media_formats[] = {
.cs = IPUV3_COLORSPACE_RGB,
.bpp= 32,
.ipufmt = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SBGGR8,
+   .codes  = {MEDIA_BUS_FMT_SBGGR8_1X8},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 8,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGBRG8,
+   .codes  = {MEDIA_BUS_FMT_SGBRG8_1X8},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 8,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGRBG8,
+   .codes  = {MEDIA_BUS_FMT_SGRBG8_1X8},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 8,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SRGGB8,
+   .codes  = {MEDIA_BUS_FMT_SRGGB8_1X8},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 8,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SBGGR16,
+   .codes  = {
+   MEDIA_BUS_FMT_SBGGR10_1X10,
+   MEDIA_BUS_FMT_SBGGR12_1X12,
+   MEDIA_BUS_FMT_SBGGR14_1X14,
+   MEDIA_BUS_FMT_SBGGR16_1X16
+   },
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGBRG16,
+   .codes  = {
+   MEDIA_BUS_FMT_SGBRG10_1X10,
+   MEDIA_BUS_FMT_SGBRG12_1X12,
+   MEDIA_BUS_FMT_SGBRG14_1X14,
+   MEDIA_BUS_FMT_SGBRG16_1X16,
+   },
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGRBG16,
+   .codes  = {
+   MEDIA_BUS_FMT_SGRBG10_1X10,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SGRBG14_1X14,
+   MEDIA_BUS_FMT_SGRBG16_1X16,
+   },
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SRGGB16,
+   .codes  = {
+   MEDIA_BUS_FMT_SRGGB10_1X10,
+   MEDIA_BUS_FMT_SRGGB12_1X12,
+   MEDIA_BUS_FMT_SRGGB14_1X14,
+   MEDIA_BUS_FMT_SRGGB16_1X16,
+   },
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
},
/*** non-mbus formats start here ***/
{
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index 3d4f3c7..ae3af0d 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -91,6 +91,7 @@ struct imx_media_pixfmt {
int bpp; /* total bpp */
enum ipu_color_space cs;
boolplanar;  /* is a planar format */
+   boolbayer;   /* is a raw bayer format */
boolipufmt;  /* is one of the IPU internal formats */
 };
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 29/36] media: imx: mipi-csi2: enable setting and getting of frame rates

2017-02-15 Thread Steve Longerbeam
From: Russell King 

Setting and getting frame rates is part of the negotiation mechanism
between subdevs.  The lack of support means that a frame rate at the
sensor can't be negotiated through the subdev path.

Add support at MIPI CSI2 level for handling this part of the
negotiation.

Signed-off-by: Russell King 
Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx6-mipi-csi2.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c 
b/drivers/staging/media/imx/imx6-mipi-csi2.c
index 23dca80..c62f14e 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -34,6 +34,7 @@ struct csi2_dev {
struct v4l2_subdev  sd;
struct media_pad   pad[CSI2_NUM_PADS];
struct v4l2_mbus_framefmt format_mbus;
+   struct v4l2_fract  frame_interval;
struct clk *dphy_clk;
struct clk *cfg_clk;
struct clk *pix_clk; /* what is this? */
@@ -397,6 +398,30 @@ static int csi2_set_fmt(struct v4l2_subdev *sd,
return 0;
 }
 
+static int csi2_g_frame_interval(struct v4l2_subdev *sd,
+struct v4l2_subdev_frame_interval *fi)
+{
+   struct csi2_dev *csi2 = sd_to_dev(sd);
+
+   fi->interval = csi2->frame_interval;
+
+   return 0;
+}
+
+static int csi2_s_frame_interval(struct v4l2_subdev *sd,
+struct v4l2_subdev_frame_interval *fi)
+{
+   struct csi2_dev *csi2 = sd_to_dev(sd);
+
+   /* Output pads mirror active input pad, no limits on input pads */
+   if (fi->pad != CSI2_SINK_PAD)
+   fi->interval = csi2->frame_interval;
+
+   csi2->frame_interval = fi->interval;
+
+   return 0;
+}
+
 /*
  * retrieve our pads parsed from the OF graph by the media device
  */
@@ -430,6 +455,8 @@ static struct v4l2_subdev_core_ops csi2_core_ops = {
 
 static struct v4l2_subdev_video_ops csi2_video_ops = {
.s_stream = csi2_s_stream,
+   .g_frame_interval = csi2_g_frame_interval,
+   .s_frame_interval = csi2_s_frame_interval,
 };
 
 static struct v4l2_subdev_pad_ops csi2_pad_ops = {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 28/36] media: imx: csi: fix crop rectangle changes in set_fmt

2017-02-15 Thread Steve Longerbeam
From: Philipp Zabel 

The cropping rectangle was being modified by the output pad's
set_fmt, which is the wrong pad to do this. The crop rectangle
should not be modified by the output pad set_fmt. It instead
should be reset to the full input frame when the input pad format
is set.

The output pad set_fmt should set width/height to the current
crop dimensions, or 1/2 the crop width/height to enable
downscaling.

So the other part of this patch is to enable downscaling if
the output pad dimension(s) are 1/2 the crop dimension(s) at
csi_setup() time.

Signed-off-by: Philipp Zabel 
Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 35 ---
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index ae24b42..3cb97e2 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -531,6 +531,10 @@ static int csi_setup(struct csi_priv *priv)
 
ipu_csi_set_window(priv->csi, &priv->crop);
 
+   ipu_csi_set_downsize(priv->csi,
+priv->crop.width == 2 * outfmt->width,
+priv->crop.height == 2 * outfmt->height);
+
ipu_csi_init_interface(priv->csi, &sensor_mbus_cfg, &if_fmt);
 
ipu_csi_set_dest(priv->csi, priv->dest);
@@ -890,15 +894,15 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
switch (sdformat->pad) {
case CSI_SRC_PAD_DIRECT:
case CSI_SRC_PAD_IDMAC:
-   crop.left = priv->crop.left;
-   crop.top = priv->crop.top;
-   crop.width = sdformat->format.width;
-   crop.height = sdformat->format.height;
-   ret = csi_try_crop(priv, &crop, sensor);
-   if (ret)
-   return ret;
-   sdformat->format.width = crop.width;
-   sdformat->format.height = crop.height;
+   if (sdformat->format.width < priv->crop.width * 3 / 4)
+   sdformat->format.width = priv->crop.width / 2;
+   else
+   sdformat->format.width = priv->crop.width;
+
+   if (sdformat->format.height < priv->crop.height * 3 / 4)
+   sdformat->format.height = priv->crop.height / 2;
+   else
+   sdformat->format.height = priv->crop.height;
 
if (sdformat->pad == CSI_SRC_PAD_IDMAC) {
cc = imx_media_find_format(0, sdformat->format.code,
@@ -948,6 +952,14 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
}
break;
case CSI_SINK_PAD:
+   crop.left = 0;
+   crop.top = 0;
+   crop.width = sdformat->format.width;
+   crop.height = sdformat->format.height;
+   ret = csi_try_crop(priv, &crop, sensor);
+   if (ret)
+   return ret;
+
cc = imx_media_find_format(0, sdformat->format.code,
   true, false);
if (!cc) {
@@ -965,9 +977,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
} else {
priv->format_mbus[sdformat->pad] = sdformat->format;
priv->cc[sdformat->pad] = cc;
-   /* Update the crop window if this is an output pad  */
-   if (sdformat->pad == CSI_SRC_PAD_DIRECT ||
-   sdformat->pad == CSI_SRC_PAD_IDMAC)
+   /* Reset the crop window if this is the input pad */
+   if (sdformat->pad == CSI_SINK_PAD)
priv->crop = crop;
}
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 32/36] media: imx: csi/fim: add support for frame intervals

2017-02-15 Thread Steve Longerbeam
Add support to CSI for negotiation of frame intervals, and use this
information to configure the frame interval monitor.

Signed-off-by: Russell King 
Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 36 ---
 drivers/staging/media/imx/imx-media-fim.c | 28 +---
 drivers/staging/media/imx/imx-media.h |  2 +-
 3 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index b0aac82..040cca6 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -56,6 +56,7 @@ struct csi_priv {
 
struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS];
const struct imx_media_pixfmt *cc[CSI_NUM_PADS];
+   struct v4l2_fract frame_interval;
struct v4l2_rect crop;
 
/* the video device at IDMAC output pad */
@@ -565,7 +566,8 @@ static int csi_start(struct csi_priv *priv)
 
/* start the frame interval monitor */
if (priv->fim) {
-   ret = imx_media_fim_set_stream(priv->fim, priv->sensor, true);
+   ret = imx_media_fim_set_stream(priv->fim,
+  &priv->frame_interval, true);
if (ret)
goto idmac_stop;
}
@@ -580,7 +582,8 @@ static int csi_start(struct csi_priv *priv)
 
 fim_off:
if (priv->fim)
-   imx_media_fim_set_stream(priv->fim, priv->sensor, false);
+   imx_media_fim_set_stream(priv->fim,
+&priv->frame_interval, false);
 idmac_stop:
if (priv->dest == IPU_CSI_DEST_IDMAC)
csi_idmac_stop(priv);
@@ -594,11 +597,36 @@ static void csi_stop(struct csi_priv *priv)
 
/* stop the frame interval monitor */
if (priv->fim)
-   imx_media_fim_set_stream(priv->fim, priv->sensor, false);
+   imx_media_fim_set_stream(priv->fim,
+&priv->frame_interval, false);
 
ipu_csi_disable(priv->csi);
 }
 
+static int csi_g_frame_interval(struct v4l2_subdev *sd,
+   struct v4l2_subdev_frame_interval *fi)
+{
+   struct csi_priv *priv = v4l2_get_subdevdata(sd);
+
+   fi->interval = priv->frame_interval;
+
+   return 0;
+}
+
+static int csi_s_frame_interval(struct v4l2_subdev *sd,
+   struct v4l2_subdev_frame_interval *fi)
+{
+   struct csi_priv *priv = v4l2_get_subdevdata(sd);
+
+   /* Output pads mirror active input pad, no limits on input pads */
+   if (fi->pad == CSI_SRC_PAD_IDMAC || fi->pad == CSI_SRC_PAD_DIRECT)
+   fi->interval = priv->frame_interval;
+
+   priv->frame_interval = fi->interval;
+
+   return 0;
+}
+
 static int csi_s_stream(struct v4l2_subdev *sd, int enable)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
@@ -1187,6 +1215,8 @@ static struct v4l2_subdev_core_ops csi_core_ops = {
 };
 
 static struct v4l2_subdev_video_ops csi_video_ops = {
+   .g_frame_interval = csi_g_frame_interval,
+   .s_frame_interval = csi_s_frame_interval,
.s_stream = csi_s_stream,
 };
 
diff --git a/drivers/staging/media/imx/imx-media-fim.c 
b/drivers/staging/media/imx/imx-media-fim.c
index acc7e39..a6ed57e 100644
--- a/drivers/staging/media/imx/imx-media-fim.c
+++ b/drivers/staging/media/imx/imx-media-fim.c
@@ -67,26 +67,18 @@ struct imx_media_fim {
 };
 
 static void update_fim_nominal(struct imx_media_fim *fim,
-  struct imx_media_subdev *sensor)
+  const struct v4l2_fract *fi)
 {
-   struct v4l2_streamparm parm;
-   struct v4l2_fract tpf;
-   int ret;
-
-   parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-   ret = v4l2_subdev_call(sensor->sd, video, g_parm, &parm);
-   tpf = parm.parm.capture.timeperframe;
-
-   if (ret || tpf.denominator == 0) {
-   dev_dbg(fim->sd->dev, "no tpf from sensor, FIM disabled\n");
+   if (fi->denominator == 0) {
+   dev_dbg(fim->sd->dev, "no frame interval, FIM disabled\n");
fim->enabled = false;
return;
}
 
-   fim->nominal = DIV_ROUND_CLOSEST(1000 * 1000 * tpf.numerator,
-tpf.denominator);
+   fim->nominal = DIV_ROUND_CLOSEST_ULL(100ULL * (u64)fi->numerator,
+fi->denominator);
 
-   dev_dbg(fim->sd->dev, "sensor FI=%lu usec\n", fim->nominal);
+   dev_dbg(fim->sd->dev, "FI=%lu usec\n", fim->nominal);
 }
 
 static void reset_fim(struct imx_media_fim *fim, bool curval)
@@ -130,8 +122,8 @@ static void send_fim_event(struct imx_media_fim *fim, 
unsigned long error)
 
 /*
  * Monitor an averaged frame interval. If the average deviates too much
- * from the sensor's nominal frame rate, send the frame inter

[PATCH v4 31/36] media: imx: csi: add __csi_get_fmt

2017-02-15 Thread Steve Longerbeam
Add __csi_get_fmt() and use it to return the correct mbus format
(active or try) in get_fmt. Use it in other places as well.

Signed-off-by: Steve Longerbeam 
Suggested-by: Russell King 
---
 drivers/staging/media/imx/imx-media-csi.c | 52 ---
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 63555dc..b0aac82 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -788,7 +788,20 @@ static int csi_eof_isr(struct v4l2_subdev *sd, u32 status, 
bool *handled)
return 0;
 }
 
-static int csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop,
+static struct v4l2_mbus_framefmt *
+__csi_get_fmt(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg,
+ unsigned int pad, enum v4l2_subdev_format_whence which)
+{
+   if (which == V4L2_SUBDEV_FORMAT_TRY)
+   return v4l2_subdev_get_try_format(&priv->sd, cfg, pad);
+   else
+   return &priv->format_mbus[pad];
+}
+
+static int csi_try_crop(struct csi_priv *priv,
+   struct v4l2_rect *crop,
+   struct v4l2_subdev_pad_config *cfg,
+   enum v4l2_subdev_format_whence which,
struct imx_media_subdev *sensor)
 {
struct v4l2_of_endpoint *sensor_ep;
@@ -796,7 +809,7 @@ static int csi_try_crop(struct csi_priv *priv, struct 
v4l2_rect *crop,
v4l2_std_id std;
int ret;
 
-   infmt = &priv->format_mbus[CSI_SINK_PAD];
+   infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, which);
sensor_ep = &sensor->sensor_ep;
 
crop->width = min_t(__u32, infmt->width, crop->width);
@@ -852,11 +865,16 @@ static int csi_get_fmt(struct v4l2_subdev *sd,
   struct v4l2_subdev_format *sdformat)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
+   struct v4l2_mbus_framefmt *fmt;
 
if (sdformat->pad >= CSI_NUM_PADS)
return -EINVAL;
 
-   sdformat->format = priv->format_mbus[sdformat->pad];
+   fmt = __csi_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
+   if (!fmt)
+   return -EINVAL;
+
+   sdformat->format = *fmt;
 
return 0;
 }
@@ -880,8 +898,6 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
if (priv->stream_on)
return -EBUSY;
 
-   infmt = &priv->format_mbus[CSI_SINK_PAD];
-
sensor = imx_media_find_sensor(priv->md, &priv->sd.entity);
if (IS_ERR(sensor)) {
v4l2_err(&priv->sd, "no sensor attached\n");
@@ -895,6 +911,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
switch (sdformat->pad) {
case CSI_SRC_PAD_DIRECT:
case CSI_SRC_PAD_IDMAC:
+   infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
+
if (sdformat->format.width < priv->crop.width * 3 / 4)
sdformat->format.width = priv->crop.width / 2;
else
@@ -957,7 +975,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
crop.top = 0;
crop.width = sdformat->format.width;
crop.height = sdformat->format.height;
-   ret = csi_try_crop(priv, &crop, sensor);
+   ret = csi_try_crop(priv, &crop, cfg,
+  sdformat->which, sensor);
if (ret)
return ret;
 
@@ -1004,7 +1023,9 @@ static int csi_get_selection(struct v4l2_subdev *sd,
if (sel->pad >= CSI_NUM_PADS || sel->pad == CSI_SINK_PAD)
return -EINVAL;
 
-   infmt = &priv->format_mbus[CSI_SINK_PAD];
+   infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sel->which);
+   if (!infmt)
+   return -EINVAL;
 
switch (sel->target) {
case V4L2_SEL_TGT_CROP_BOUNDS:
@@ -1014,7 +1035,14 @@ static int csi_get_selection(struct v4l2_subdev *sd,
sel->r.height = infmt->height;
break;
case V4L2_SEL_TGT_CROP:
-   sel->r = priv->crop;
+   if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
+   struct v4l2_rect *try_crop =
+   v4l2_subdev_get_try_crop(&priv->sd,
+cfg, sel->pad);
+   sel->r = *try_crop;
+   } else {
+   sel->r = priv->crop;
+   }
break;
default:
return -EINVAL;
@@ -1028,7 +1056,6 @@ static int csi_set_selection(struct v4l2_subdev *sd,
 struct v4l2_subdev_selection *sel)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
-   struct v4l2_mbus_framefmt *outfmt;
struct imx_media_subdev *sensor;
int ret;
 
@@ -1058,15 +1085,16 @@ static int csi_set_selection(struct v4l2_subdev *sd,
 

[PATCH v4 24/36] [media] add Omnivision OV5640 sensor driver

2017-02-15 Thread Steve Longerbeam
This driver is based on ov5640_mipi.c from Freescale imx_3.10.17_1.0.0_beta
branch, modified heavily to bring forward to latest interfaces and code
cleanup.

Signed-off-by: Steve Longerbeam 
---
 .../devicetree/bindings/media/i2c/ov5640.txt   |   43 +
 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5640.c | 2109 
 4 files changed, 2160 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5640.txt
 create mode 100644 drivers/media/i2c/ov5640.c

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5640.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5640.txt
new file mode 100644
index 000..4607bbe
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5640.txt
@@ -0,0 +1,43 @@
+* Omnivision OV5640 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: should be "ovti,ov5640"
+- clocks: reference to the xclk input clock.
+- clock-names: should be "xclk".
+- DOVDD-supply: Digital I/O voltage supply, 1.8 volts
+- AVDD-supply: Analog voltage supply, 2.8 volts
+- DVDD-supply: Digital core voltage supply, 1.5 volts
+
+Optional Properties:
+- reset-gpios: reference to the GPIO connected to the reset pin, if any.
+- pwdn-gpios: reference to the GPIO connected to the pwdn pin, if any.
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+
+&i2c1 {
+   ov5640: camera@3c {
+   compatible = "ovti,ov5640";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ov5640>;
+   reg = <0x3c>;
+   clocks = <&clks IMX6QDL_CLK_CKO>;
+   clock-names = "xclk";
+   DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+   AVDD-supply = <&vgen3_reg>;  /* 2.8v */
+   DVDD-supply = <&vgen2_reg>;  /* 1.5v */
+   pwdn-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>;
+   reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
+
+   port {
+   ov5640_to_mipi_csi2: endpoint {
+   remote-endpoint = <&mipi_csi2_from_ov5640>;
+   clock-lanes = <0>;
+   data-lanes = <1 2>;
+   };
+   };
+   };
+};
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index cee1dae..bf67661 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -531,6 +531,13 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV5640
+   tristate "OmniVision OV5640 sensor support"
+   depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
+   ---help---
+ This is a V4L2 sensor-level driver for the Omnivision
+ OV5640 camera sensor with a MIPI CSI-2 interface.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 5bc7bbe..3a9d73a 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
 obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
+obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
new file mode 100644
index 000..b3535af
--- /dev/null
+++ b/drivers/media/i2c/ov5640.c
@@ -0,0 +1,2109 @@
+/*
+ * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2014-2017 Mentor Graphics Inc.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* min/typical/max system clock (xclk) frequencies */
+#define OV5640_XCLK_MIN  600
+#define OV5640_XCLK_MAX 2400
+
+/*
+ * FIXME: there is no subdev API to set the MIPI CSI-2
+ * virtual channel yet, so this is hardcoded for now.
+ */
+#define OV5640_MIPI_VC 1
+
+#define OV5640_DEFAULT_SLAVE_ID 0x3c
+
+#define OV5640_REG_CHIP_ID 0x300a
+#define OV5640_REG_PAD_OUTPUT000x3019
+#define OV5640_REG_SC_PLL_CTRL0

[PATCH v4 34/36] media: imx: csi: add frame skipping support

2017-02-15 Thread Steve Longerbeam
From: Philipp Zabel 

The CSI can skip any out of up to 6 input frames, allowing to reduce the
frame rate at the output pads by small fractions.

Signed-off-by: Philipp Zabel 
Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 119 +-
 1 file changed, 115 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 1d4e746..6284f99 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -9,6 +9,7 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  */
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,18 @@
 #define H_ALIGN1 /* multiple of 2 lines */
 #define S_ALIGN1 /* multiple of 2 */
 
+/*
+ * struct csi_skip_desc - CSI frame skipping descriptor
+ * @keep - number of frames kept per max_ratio frames
+ * @max_ratio - width of skip_smfc, written to MAX_RATIO bitfield
+ * @skip_smfc - skip pattern written to the SKIP_SMFC bitfield
+ */
+struct csi_skip_desc {
+   u8 keep;
+   u8 max_ratio;
+   u8 skip_smfc;
+};
+
 struct csi_priv {
struct device *dev;
struct ipu_soc *ipu;
@@ -58,6 +71,7 @@ struct csi_priv {
const struct imx_media_pixfmt *cc[CSI_NUM_PADS];
struct v4l2_fract frame_interval;
struct v4l2_rect crop;
+   const struct csi_skip_desc *skip[CSI_NUM_PADS - 1];
 
/* the video device at IDMAC output pad */
struct imx_media_video_dev *vdev;
@@ -512,10 +526,12 @@ static int csi_setup(struct csi_priv *priv)
struct v4l2_mbus_config sensor_mbus_cfg;
struct v4l2_of_endpoint *sensor_ep;
struct v4l2_mbus_framefmt if_fmt;
+   const struct csi_skip_desc *skip;
 
infmt = &priv->format_mbus[CSI_SINK_PAD];
outfmt = &priv->format_mbus[priv->active_output_pad];
sensor_ep = &priv->sensor->sensor_ep;
+   skip = priv->skip[priv->active_output_pad - 1];
 
/* compose mbus_config from sensor endpoint */
sensor_mbus_cfg.type = sensor_ep->bus_type;
@@ -540,6 +556,9 @@ static int csi_setup(struct csi_priv *priv)
 
ipu_csi_set_dest(priv->csi, priv->dest);
 
+   ipu_csi_set_skip_smfc(priv->csi, skip->skip_smfc, skip->max_ratio - 1,
+ 0);
+
ipu_csi_dump(priv->csi);
 
return 0;
@@ -603,26 +622,115 @@ static void csi_stop(struct csi_priv *priv)
ipu_csi_disable(priv->csi);
 }
 
+static const struct csi_skip_desc csi_skip[12] = {
+   { 1, 1, 0x00 }, /* Keep all frames */
+   { 5, 6, 0x10 }, /* Skip every sixth frame */
+   { 4, 5, 0x08 }, /* Skip every fifth frame */
+   { 3, 4, 0x04 }, /* Skip every fourth frame */
+   { 2, 3, 0x02 }, /* Skip every third frame */
+   { 3, 5, 0x0a }, /* Skip frames 1 and 3 of every 5 */
+   { 1, 2, 0x01 }, /* Skip every second frame */
+   { 2, 5, 0x0b }, /* Keep frames 1 and 4 of every 5 */
+   { 1, 3, 0x03 }, /* Keep one in three frames */
+   { 1, 4, 0x07 }, /* Keep one in four frames */
+   { 1, 5, 0x0f }, /* Keep one in five frames */
+   { 1, 6, 0x1f }, /* Keep one in six frames */
+};
+
+static void csi_apply_skip_interval(const struct csi_skip_desc *skip,
+   struct v4l2_fract *interval)
+{
+   unsigned int div;
+
+   interval->numerator *= skip->max_ratio;
+   interval->denominator *= skip->keep;
+
+   /* Reduce fraction to lowest terms */
+   div = gcd(interval->numerator, interval->denominator);
+   if (div > 1) {
+   interval->numerator /= div;
+   interval->denominator /= div;
+   }
+}
+
 static int csi_g_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_frame_interval *fi)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
 
+   if (fi->pad >= CSI_NUM_PADS)
+   return -EINVAL;
+
fi->interval = priv->frame_interval;
 
+   if (fi->pad != CSI_SINK_PAD)
+   csi_apply_skip_interval(priv->skip[fi->pad - 1], &fi->interval);
+
return 0;
 }
 
+/*
+ * Find the skip pattern to produce the output frame interval closest to the
+ * requested one, for the given input frame interval. Updates the output frame
+ * interval to the exact value.
+ */
+static const struct csi_skip_desc *csi_find_best_skip(struct v4l2_fract *in,
+ struct v4l2_fract *out)
+{
+   const struct csi_skip_desc *skip = &csi_skip[0], *best_skip = skip;
+   u32 min_err = UINT_MAX;
+   u64 want_us;
+   int i;
+
+   /* Default to 1:1 ratio */
+   if (out->numerator == 0 || out->denominator == 0 ||
+   in->numerator == 0 || in->denominator == 0)
+   return best_skip;
+
+   want_us = div_u64((u64)USEC_PER_SEC * out->numerator, out->denominator);
+
+  

[PATCH v4 33/36] media: imx: redo pixel format enumeration and negotiation

2017-02-15 Thread Steve Longerbeam
The previous API and negotiation of mbus codes and pixel formats
was broken, and has been completely redone.

The negotiation of media bus codes should be as follows:

CSI:

sink pad direct src pad  IDMAC src pad
 -
RGB (any)IPU RGB   RGB (any)
YUV (any)IPU YUV   YUV (any)
Bayer  N/A must be same bayer code as sink

VDIC:

direct sink padIDMAC sink paddirect src pad
-------
IPU YUV only   YUV (any) IPU YUV only

PRP:

direct sink paddirect src pads
------
IPU (any)  same as sink code

PRP ENC/VF:

direct sink padIDMAC src pads
-----
IPU (any)  any RGB or YUV

Given the above, a new internal API is created:

enum codespace_sel {
   CS_SEL_YUV = 0, /* find or enumerate only YUV codes */
   CS_SEL_RGB, /* find or enumerate only RGB codes */
   CS_SEL_ANY, /* find or enumerate both YUV and RGB codes */
};

/* Find and enumerate fourcc pixel formats */
const struct imx_media_pixfmt *
imx_media_find_format(u32 fourcc, enum codespace_sel cs_sel);
int imx_media_enum_format(u32 *fourcc, u32 index, enum codespace_sel cs_sel);

/* Find and enumerate media bus codes */
const struct imx_media_pixfmt *
imx_media_find_mbus_format(u32 code, enum codespace_sel cs_sel,
  bool allow_bayer);
int imx_media_enum_mbus_format(u32 *code, u32 index, enum codespace_sel cs_sel,
  bool allow_bayer);

/* Find and enumerate IPU internal media bus codes */
const struct imx_media_pixfmt *
imx_media_find_ipu_format(u32 code, enum codespace_sel cs_sel);
int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel);

The tables have been split into separate tables for YUV and RGB formats
to support the implementation of the above.

The subdev's .enum_mbus_code() and .set_fmt() operations have
been rewritten using the above APIs.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-ic-prp.c|  72 --
 drivers/staging/media/imx/imx-ic-prpencvf.c   |  53 ++--
 drivers/staging/media/imx/imx-media-capture.c |  77 +++---
 drivers/staging/media/imx/imx-media-csi.c | 107 +---
 drivers/staging/media/imx/imx-media-utils.c   | 357 +++---
 drivers/staging/media/imx/imx-media-vdic.c| 100 +---
 drivers/staging/media/imx/imx-media.h |  27 +-
 7 files changed, 528 insertions(+), 265 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 3683f7c..b9ee8fb 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -96,16 +96,6 @@ static void prp_stop(struct prp_priv *priv)
 {
 }
 
-static int prp_enum_mbus_code(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
- struct v4l2_subdev_mbus_code_enum *code)
-{
-   if (code->pad >= PRP_NUM_PADS)
-   return -EINVAL;
-
-   return imx_media_enum_ipu_format(NULL, &code->code, code->index, true);
-}
-
 static struct v4l2_mbus_framefmt *
 __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_pad_config *cfg,
  unsigned int pad, enum v4l2_subdev_format_whence which)
@@ -118,6 +108,33 @@ __prp_get_fmt(struct prp_priv *priv, struct 
v4l2_subdev_pad_config *cfg,
return &priv->format_mbus[pad];
 }
 
+static int prp_enum_mbus_code(struct v4l2_subdev *sd,
+ struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_mbus_code_enum *code)
+{
+   struct prp_priv *priv = sd_to_priv(sd);
+   struct v4l2_mbus_framefmt *infmt;
+   int ret = 0;
+
+   switch (code->pad) {
+   case PRP_SINK_PAD:
+   ret = imx_media_enum_ipu_format(&code->code, code->index,
+   CS_SEL_ANY);
+   break;
+   case PRP_SRC_PAD_PRPENC:
+   case PRP_SRC_PAD_PRPVF:
+   if (code->index != 0)
+   return -EINVAL;
+   infmt = __prp_get_fmt(priv, cfg, PRP_SINK_PAD, code->which);
+   code->code = infmt->code;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   return ret;
+}
+
 static int prp_get_fmt(struct v4l2_subdev *sd,
   struct v4l2_subdev_pad_config *cfg,
   struct v4l2_subdev_format *sdformat)
@@ -152,23 +169,28 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
if (priv->stream_on)
return -EBUSY;
 
-   cc = imx_media_find_ipu_format(0, sdformat->format.code, true);
-   if (!cc) {
-   imx_media_enum_ipu_format(NULL, &code, 0, true);
-   cc = imx_media_find_ipu_format(0, code, true);
-   sdformat->fo

[PATCH v4 16/36] UAPI: Add media UAPI Kbuild file

2017-02-15 Thread Steve Longerbeam
Add an empty UAPI Kbuild file for media UAPI headers.

Signed-off-by: Steve Longerbeam 
---
 include/uapi/Kbuild   | 1 +
 include/uapi/media/Kbuild | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 include/uapi/media/Kbuild

diff --git a/include/uapi/Kbuild b/include/uapi/Kbuild
index 245aa6e..9a51957 100644
--- a/include/uapi/Kbuild
+++ b/include/uapi/Kbuild
@@ -6,6 +6,7 @@
 header-y += asm-generic/
 header-y += linux/
 header-y += sound/
+header-y += media/
 header-y += mtd/
 header-y += rdma/
 header-y += video/
diff --git a/include/uapi/media/Kbuild b/include/uapi/media/Kbuild
new file mode 100644
index 000..aafaa5a
--- /dev/null
+++ b/include/uapi/media/Kbuild
@@ -0,0 +1 @@
+# UAPI Header export list
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 36/36] media: imx: propagate sink pad formats to source pads

2017-02-15 Thread Steve Longerbeam
Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-ic-prp.c  | 11 ++-
 drivers/staging/media/imx/imx-ic-prpencvf.c | 22 ++
 drivers/staging/media/imx/imx-media-csi.c   | 26 +-
 drivers/staging/media/imx/imx-media-vdic.c  | 15 ++-
 4 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index b9ee8fb..5c57d2b 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -196,8 +196,17 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) {
cfg->try_fmt = sdformat->format;
} else {
-   priv->format_mbus[sdformat->pad] = sdformat->format;
+   struct v4l2_mbus_framefmt *f =
+   &priv->format_mbus[sdformat->pad];
+
+   *f = sdformat->format;
priv->cc[sdformat->pad] = cc;
+
+   /* propagate format to source pads */
+   if (sdformat->pad == PRP_SINK_PAD) {
+   priv->format_mbus[PRP_SRC_PAD_PRPENC] = *f;
+   priv->format_mbus[PRP_SRC_PAD_PRPVF] = *f;
+   }
}
 
return 0;
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index dd9d499..c43f85f 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -806,16 +806,22 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) {
cfg->try_fmt = sdformat->format;
} else {
-   priv->format_mbus[sdformat->pad] = sdformat->format;
+   struct v4l2_mbus_framefmt *f =
+   &priv->format_mbus[sdformat->pad];
+   struct v4l2_mbus_framefmt *outf =
+   &priv->format_mbus[PRPENCVF_SRC_PAD];
+
+   *f = sdformat->format;
priv->cc[sdformat->pad] = cc;
-   if (sdformat->pad == PRPENCVF_SRC_PAD) {
-   /*
-* update the capture device format if this is
-* the IDMAC output pad
-*/
-   imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix,
- &sdformat->format, cc);
+
+   /* propagate format to source pad */
+   if (sdformat->pad == PRPENCVF_SINK_PAD) {
+   outf->width = f->width;
+   outf->height = f->height;
}
+
+   /* update the capture device format from output pad */
+   imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix, outf, cc);
}
 
return 0;
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 3e6b607..9d9ec03 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1161,19 +1161,27 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) {
cfg->try_fmt = sdformat->format;
} else {
+   struct v4l2_mbus_framefmt *f_direct, *f_idmac;
+
priv->format_mbus[sdformat->pad] = sdformat->format;
priv->cc[sdformat->pad] = cc;
-   /* Reset the crop window if this is the input pad */
-   if (sdformat->pad == CSI_SINK_PAD)
+
+   f_direct = &priv->format_mbus[CSI_SRC_PAD_DIRECT];
+   f_idmac = &priv->format_mbus[CSI_SRC_PAD_IDMAC];
+
+   if (sdformat->pad == CSI_SINK_PAD) {
+   /* reset the crop window */
priv->crop = crop;
-   else if (sdformat->pad == CSI_SRC_PAD_IDMAC) {
-   /*
-* update the capture device format if this is
-* the IDMAC output pad
-*/
-   imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix,
- &sdformat->format, cc);
+
+   /* propagate format to source pads */
+   f_direct->width = crop.width;
+   f_direct->height = crop.height;
+   f_idmac->width = crop.width;
+   f_idmac->height = crop.height;
}
+
+   /* update the capture device format from IDMAC output pad */
+   imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix, f_idmac, cc);
}
 
return 0;
diff --git a/drivers/staging/media/imx/imx-media-vdic.c 
b/drivers/staging/media/imx/imx-media-vdic.c
index 61e6017..55fb522 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/sta

[PATCH v4 35/36] media: imx: csi: fix crop rectangle reset in sink set_fmt

2017-02-15 Thread Steve Longerbeam
From: Philipp Zabel 

The csi_try_crop call in set_fmt should compare the cropping rectangle
to the currently set input format, not to the previous input format.

Signed-off-by: Philipp Zabel 
Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 6284f99..3e6b607 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -937,15 +937,13 @@ __csi_get_fmt(struct csi_priv *priv, struct 
v4l2_subdev_pad_config *cfg,
 static int csi_try_crop(struct csi_priv *priv,
struct v4l2_rect *crop,
struct v4l2_subdev_pad_config *cfg,
-   enum v4l2_subdev_format_whence which,
+   struct v4l2_mbus_framefmt *infmt,
struct imx_media_subdev *sensor)
 {
struct v4l2_of_endpoint *sensor_ep;
-   struct v4l2_mbus_framefmt *infmt;
v4l2_std_id std;
int ret;
 
-   infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, which);
sensor_ep = &sensor->sensor_ep;
 
crop->width = min_t(__u32, infmt->width, crop->width);
@@ -1142,8 +1140,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
crop.top = 0;
crop.width = sdformat->format.width;
crop.height = sdformat->format.height;
-   ret = csi_try_crop(priv, &crop, cfg,
-  sdformat->which, sensor);
+   ret = csi_try_crop(priv, &crop, cfg, &sdformat->format, sensor);
if (ret)
return ret;
 
@@ -1225,6 +1222,7 @@ static int csi_set_selection(struct v4l2_subdev *sd,
 struct v4l2_subdev_selection *sel)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
+   struct v4l2_mbus_framefmt *infmt;
struct imx_media_subdev *sensor;
int ret;
 
@@ -1254,7 +1252,8 @@ static int csi_set_selection(struct v4l2_subdev *sd,
return 0;
}
 
-   ret = csi_try_crop(priv, &sel->r, cfg, sel->which, sensor);
+   infmt = __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sel->which);
+   ret = csi_try_crop(priv, &sel->r, cfg, infmt, sensor);
if (ret)
return ret;
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 30/36] media: imx: update capture dev format on IDMAC output pad set_fmt

2017-02-15 Thread Steve Longerbeam
When configuring the IDMAC output pad formats (in ipu_csi,
ipu_ic_prpenc, and ipu_ic_prpvf subdevs), the attached capture
device format must also be updated.

Signed-off-by: Steve Longerbeam 
Suggested-by: Philipp Zabel 
---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 9 +
 drivers/staging/media/imx/imx-media-csi.c   | 9 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 2be8845..6e45975 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -739,6 +739,7 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
   struct v4l2_subdev_format *sdformat)
 {
struct prp_priv *priv = sd_to_priv(sd);
+   struct imx_media_video_dev *vdev = priv->vdev;
const struct imx_media_pixfmt *cc;
struct v4l2_mbus_framefmt *infmt;
u32 code;
@@ -800,6 +801,14 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
} else {
priv->format_mbus[sdformat->pad] = sdformat->format;
priv->cc[sdformat->pad] = cc;
+   if (sdformat->pad == PRPENCVF_SRC_PAD) {
+   /*
+* update the capture device format if this is
+* the IDMAC output pad
+*/
+   imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix,
+ &sdformat->format, cc);
+   }
}
 
return 0;
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 3cb97e2..63555dc 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -866,6 +866,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
   struct v4l2_subdev_format *sdformat)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
+   struct imx_media_video_dev *vdev = priv->vdev;
const struct imx_media_pixfmt *cc, *incc;
struct v4l2_mbus_framefmt *infmt;
struct imx_media_subdev *sensor;
@@ -980,6 +981,14 @@ static int csi_set_fmt(struct v4l2_subdev *sd,
/* Reset the crop window if this is the input pad */
if (sdformat->pad == CSI_SINK_PAD)
priv->crop = crop;
+   else if (sdformat->pad == CSI_SRC_PAD_IDMAC) {
+   /*
+* update the capture device format if this is
+* the IDMAC output pad
+*/
+   imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix,
+ &sdformat->format, cc);
+   }
}
 
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 27/36] media: imx: csi: add support for bayer formats

2017-02-15 Thread Steve Longerbeam
From: Russell King 

Bayer formats must be treated as generic data and passthrough mode must
be used.  Add the correct setup for these formats.

Signed-off-by: Russell King 

- added check to csi_link_validate() to verify that destination is
  IDMAC output pad when passthrough conditions exist: bayer formats
  and 16-bit parallel buses.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 50 ++-
 1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 0343fc3..ae24b42 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -2,6 +2,7 @@
  * V4L2 Capture CSI Subdev for Freescale i.MX5/6 SOC
  *
  * Copyright (c) 2014-2016 Mentor Graphics Inc.
+ * Copyright (C) 2017 Pengutronix, Philipp Zabel 
  *
  * 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
@@ -271,10 +272,11 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
struct imx_media_video_dev *vdev = priv->vdev;
struct v4l2_of_endpoint *sensor_ep;
struct v4l2_mbus_framefmt *infmt;
-   unsigned int burst_size;
struct ipu_image image;
+   u32 passthrough_bits;
dma_addr_t phys[2];
bool passthrough;
+   u32 burst_size;
int ret;
 
infmt = &priv->format_mbus[CSI_SINK_PAD];
@@ -301,15 +303,38 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
ipu_cpmem_set_burstsize(priv->idmac_ch, burst_size);
 
/*
-* If the sensor uses 16-bit parallel CSI bus, we must handle
-* the data internally in the IPU as 16-bit generic, aka
-* passthrough mode.
+* Check for conditions that require the IPU to handle the
+* data internally as generic data, aka passthrough mode:
+* - raw bayer formats
+* - the sensor bus is 16-bit parallel
 */
-   passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 &&
-  sensor_ep->bus.parallel.bus_width >= 16);
+   switch (image.pix.pixelformat) {
+   case V4L2_PIX_FMT_SBGGR8:
+   case V4L2_PIX_FMT_SGBRG8:
+   case V4L2_PIX_FMT_SGRBG8:
+   case V4L2_PIX_FMT_SRGGB8:
+   burst_size = 8;
+   passthrough = true;
+   passthrough_bits = 8;
+   break;
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
+   burst_size = 4;
+   passthrough = true;
+   passthrough_bits = 16;
+   break;
+   default:
+   passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 &&
+  sensor_ep->bus.parallel.bus_width >= 16);
+   passthrough_bits = 16;
+   break;
+   }
 
if (passthrough)
-   ipu_cpmem_set_format_passthrough(priv->idmac_ch, 16);
+   ipu_cpmem_set_format_passthrough(priv->idmac_ch,
+passthrough_bits);
 
/*
 * Set the channel for the direct CSI-->memory via SMFC
@@ -695,6 +720,7 @@ static int csi_link_validate(struct v4l2_subdev *sd,
 struct v4l2_subdev_format *sink_fmt)
 {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
+   const struct imx_media_pixfmt *incc;
struct v4l2_of_endpoint *sensor_ep;
bool is_csi2;
int ret;
@@ -713,8 +739,16 @@ static int csi_link_validate(struct v4l2_subdev *sd,
}
 
sensor_ep = &priv->sensor->sensor_ep;
-
is_csi2 = (sensor_ep->bus_type == V4L2_MBUS_CSI2);
+   incc = priv->cc[CSI_SINK_PAD];
+
+   if (priv->dest != IPU_CSI_DEST_IDMAC &&
+   (incc->bayer || (!is_csi2 &&
+sensor_ep->bus.parallel.bus_width >= 16))) {
+   v4l2_err(&priv->sd,
+"bayer/16-bit parallel buses must go to IDMAC pad\n");
+   return -EINVAL;
+   }
 
if (is_csi2) {
int vc_num = 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4 32/36] media: imx: csi/fim: add support for frame intervals

2017-02-15 Thread Steve Longerbeam

Sorry, I forgot to change authorship on this patch. It should
be authored by Russell King .

Steve

On 02/15/2017 06:19 PM, Steve Longerbeam wrote:

Add support to CSI for negotiation of frame intervals, and use this
information to configure the frame interval monitor.

Signed-off-by: Russell King 
Signed-off-by: Steve Longerbeam 
---
  drivers/staging/media/imx/imx-media-csi.c | 36 ---
  drivers/staging/media/imx/imx-media-fim.c | 28 +---
  drivers/staging/media/imx/imx-media.h |  2 +-
  3 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index b0aac82..040cca6 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -56,6 +56,7 @@ struct csi_priv {
  
  	struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS];

const struct imx_media_pixfmt *cc[CSI_NUM_PADS];
+   struct v4l2_fract frame_interval;
struct v4l2_rect crop;
  
  	/* the video device at IDMAC output pad */

@@ -565,7 +566,8 @@ static int csi_start(struct csi_priv *priv)
  
  	/* start the frame interval monitor */

if (priv->fim) {
-   ret = imx_media_fim_set_stream(priv->fim, priv->sensor, true);
+   ret = imx_media_fim_set_stream(priv->fim,
+  &priv->frame_interval, true);
if (ret)
goto idmac_stop;
}
@@ -580,7 +582,8 @@ static int csi_start(struct csi_priv *priv)
  
  fim_off:

if (priv->fim)
-   imx_media_fim_set_stream(priv->fim, priv->sensor, false);
+   imx_media_fim_set_stream(priv->fim,
+&priv->frame_interval, false);
  idmac_stop:
if (priv->dest == IPU_CSI_DEST_IDMAC)
csi_idmac_stop(priv);
@@ -594,11 +597,36 @@ static void csi_stop(struct csi_priv *priv)
  
  	/* stop the frame interval monitor */

if (priv->fim)
-   imx_media_fim_set_stream(priv->fim, priv->sensor, false);
+   imx_media_fim_set_stream(priv->fim,
+&priv->frame_interval, false);
  
  	ipu_csi_disable(priv->csi);

  }
  
+static int csi_g_frame_interval(struct v4l2_subdev *sd,

+   struct v4l2_subdev_frame_interval *fi)
+{
+   struct csi_priv *priv = v4l2_get_subdevdata(sd);
+
+   fi->interval = priv->frame_interval;
+
+   return 0;
+}
+
+static int csi_s_frame_interval(struct v4l2_subdev *sd,
+   struct v4l2_subdev_frame_interval *fi)
+{
+   struct csi_priv *priv = v4l2_get_subdevdata(sd);
+
+   /* Output pads mirror active input pad, no limits on input pads */
+   if (fi->pad == CSI_SRC_PAD_IDMAC || fi->pad == CSI_SRC_PAD_DIRECT)
+   fi->interval = priv->frame_interval;
+
+   priv->frame_interval = fi->interval;
+
+   return 0;
+}
+
  static int csi_s_stream(struct v4l2_subdev *sd, int enable)
  {
struct csi_priv *priv = v4l2_get_subdevdata(sd);
@@ -1187,6 +1215,8 @@ static struct v4l2_subdev_core_ops csi_core_ops = {
  };
  
  static struct v4l2_subdev_video_ops csi_video_ops = {

+   .g_frame_interval = csi_g_frame_interval,
+   .s_frame_interval = csi_s_frame_interval,
.s_stream = csi_s_stream,
  };
  
diff --git a/drivers/staging/media/imx/imx-media-fim.c b/drivers/staging/media/imx/imx-media-fim.c

index acc7e39..a6ed57e 100644
--- a/drivers/staging/media/imx/imx-media-fim.c
+++ b/drivers/staging/media/imx/imx-media-fim.c
@@ -67,26 +67,18 @@ struct imx_media_fim {
  };
  
  static void update_fim_nominal(struct imx_media_fim *fim,

-  struct imx_media_subdev *sensor)
+  const struct v4l2_fract *fi)
  {
-   struct v4l2_streamparm parm;
-   struct v4l2_fract tpf;
-   int ret;
-
-   parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-   ret = v4l2_subdev_call(sensor->sd, video, g_parm, &parm);
-   tpf = parm.parm.capture.timeperframe;
-
-   if (ret || tpf.denominator == 0) {
-   dev_dbg(fim->sd->dev, "no tpf from sensor, FIM disabled\n");
+   if (fi->denominator == 0) {
+   dev_dbg(fim->sd->dev, "no frame interval, FIM disabled\n");
fim->enabled = false;
return;
}
  
-	fim->nominal = DIV_ROUND_CLOSEST(1000 * 1000 * tpf.numerator,

-tpf.denominator);
+   fim->nominal = DIV_ROUND_CLOSEST_ULL(100ULL * (u64)fi->numerator,
+fi->denominator);
  
-	dev_dbg(fim->sd->dev, "sensor FI=%lu usec\n", fim->nominal);

+   dev_dbg(fim->sd->dev, "FI=%lu usec\n", fim->nominal);
  }
  
  static void reset_fim(struct imx_media_fim *fim, bool curval)

@@ -130,8 +122,8 @@ static void send_fim_event(struct imx_media_fim *fim, 
unsigne

[PATCH] staging: vt6656: rxtx.c Removed multiple dereferencing

2017-02-15 Thread Michael S. Hansen
Fixes checkpatch warning: Avoid multiple line dereference

Signed-off-by: Michael S. Hansen 
---
 drivers/staging/vt6656/rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index aa59e7f..7f526c0 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -692,8 +692,8 @@ static u16 vnt_generate_tx_parameter(struct 
vnt_usb_send_context *tx_context,
tx_context->pkt_type == PK_TYPE_11GA) {
if (need_rts) {
if (need_mic)
-   *mic_hdr = &tx_buffer->
-   tx_head.tx_rts.tx.mic.hdr;
+   *mic_hdr =
+   &tx_buffer->tx_head.tx_rts.tx.mic.hdr;
 
return vnt_rxtx_rts(tx_context, &tx_buffer->tx_head,
need_mic);
-- 
2.7.4



___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] greybus: fw-management: Replace strncpy with strlcpy

2017-02-15 Thread Viresh Kumar
Hi Tobin,

On Wed, Feb 15, 2017 at 5:39 AM, Tobin C. Harding  wrote:
> Greybus currently uses strncpy() coupled with a check for '\0' on the
> last byte of various buffers. strncpy() is passed size parameter equal
> to the size of the buffer in all instances. If the source string is
> larger than the destination buffer the check catches this and, after
> logging the error, returns an error value. In one instance the
> immediate return is not required. Using strncpy() with the manual check
> adds code that could be removed by the use of strlcpy(), although truncation
> then needs to be checked.
>
> Replace calls to strncpy() with calls to strlcpy(). Replace null
> termination checks  with checks for truncated string. Add log message
> if string is truncated but do not return an error code.
>
> Signed-off-by: Tobin C. Harding 
> ---
>  drivers/staging/greybus/fw-management.c | 59 
> +++--
>  1 file changed, 19 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/staging/greybus/fw-management.c 
> b/drivers/staging/greybus/fw-management.c
> index 3cd6cf0..1cd5a45 100644
> --- a/drivers/staging/greybus/fw-management.c
> +++ b/drivers/staging/greybus/fw-management.c
> @@ -108,6 +108,7 @@ static int fw_mgmt_interface_fw_version_operation(struct 
> fw_mgmt *fw_mgmt,
> struct gb_connection *connection = fw_mgmt->connection;
> struct gb_fw_mgmt_interface_fw_version_response response;
> int ret;
> +   size_t len;
>
> ret = gb_operation_sync(connection,
> GB_FW_MGMT_TYPE_INTERFACE_FW_VERSION, NULL, 0,
> @@ -121,18 +122,11 @@ static int 
> fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt,
> fw_info->major = le16_to_cpu(response.major);
> fw_info->minor = le16_to_cpu(response.minor);
>
> -   strncpy(fw_info->firmware_tag, response.firmware_tag,
> +   len = strlcpy(fw_info->firmware_tag, response.firmware_tag,
> GB_FIRMWARE_TAG_MAX_SIZE);
> -
> -   /*
> -* The firmware-tag should be NULL terminated, otherwise throw error 
> but
> -* don't fail.
> -*/
> -   if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
> +   if (len >= GB_FIRMWARE_TAG_MAX_SIZE)

I am not sure if the new code you have written is any better than what
was already there.
We still have a strcpy variant followed by a check. What has improved ?


> @@ -142,6 +136,7 @@ static int fw_mgmt_load_and_validate_operation(struct 
> fw_mgmt *fw_mgmt,
>  {
> struct gb_fw_mgmt_load_and_validate_fw_request request;
> int ret;
> +   size_t len;
>
> if (load_method != GB_FW_LOAD_METHOD_UNIPRO &&
> load_method != GB_FW_LOAD_METHOD_INTERNAL) {
> @@ -151,16 +146,10 @@ static int fw_mgmt_load_and_validate_operation(struct 
> fw_mgmt *fw_mgmt,
> }
>
> request.load_method = load_method;
> -   strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE);
> -
> -   /*
> -* The firmware-tag should be NULL terminated, otherwise throw error 
> and
> -* fail.
> -*/
> -   if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
> -   dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is 
> not NULL terminated\n");
> -   return -EINVAL;

Sorry but the error returns here and at other places were very intentional. I
wrote them to make sure the protocol is followed properly, and the other
side doesn't break it.

So far its a NAK from me.

--
viresh
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: speakup: Clean up checkpatch warnings

2017-02-15 Thread Olav Haugan
Fix checkpatch warnings.

Signed-off-by: Olav Haugan 
---
 drivers/staging/speakup/synth.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index a61c02ba06da..8340748ae9cb 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -51,7 +51,7 @@ int spk_serial_synth_probe(struct spk_synth *synth)
 
if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) {
ser = spk_serial_init(synth->ser);
-   if (ser == NULL) {
+   if (!ser) {
failed = -1;
} else {
outb_p(0, ser->port);
@@ -272,7 +272,7 @@ void spk_reset_index_count(int sc)
 
 int synth_supports_indexing(void)
 {
-   if (synth->get_index != NULL)
+   if (synth->get_index)
return 1;
return 0;
 }
@@ -350,7 +350,7 @@ int synth_init(char *synth_name)
int ret = 0;
struct spk_synth *synth = NULL;
 
-   if (synth_name == NULL)
+   if (!synth_name)
return 0;
 
if (strcmp(synth_name, "none") == 0) {
@@ -362,7 +362,7 @@ int synth_init(char *synth_name)
 
mutex_lock(&spk_mutex);
/* First, check if we already have it loaded. */
-   for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
+   for (i = 0; i < MAXSYNTHS && synths[i]; i++)
if (strcmp(synths[i]->name, synth_name) == 0)
synth = synths[i];
 
@@ -406,8 +406,8 @@ static int do_synth_init(struct spk_synth *in_synth)
speakup_register_var(var);
if (!spk_quiet_boot)
synth_printf("%s found\n", synth->long_name);
-   if (synth->attributes.name && sysfs_create_group(speakup_kobj,
-&synth->attributes) < 
0)
+   if (synth->attributes.name &&
+   sysfs_create_group(speakup_kobj, &synth->attributes) < 0)
return -ENOMEM;
synth_flags = synth->flags;
wake_up_interruptible_all(&speakup_event);
@@ -421,7 +421,7 @@ void synth_release(void)
struct var_t *var;
unsigned long flags;
 
-   if (synth == NULL)
+   if (!synth)
return;
spin_lock_irqsave(&speakup_info.spinlock, flags);
pr_info("releasing synth %s\n", synth->name);
@@ -444,7 +444,7 @@ int synth_add(struct spk_synth *in_synth)
int status = 0;
 
mutex_lock(&spk_mutex);
-   for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
+   for (i = 0; i < MAXSYNTHS && synths[i]; i++)
/* synth_remove() is responsible for rotating the array down */
if (in_synth == synths[i]) {
mutex_unlock(&spk_mutex);
@@ -471,11 +471,11 @@ void synth_remove(struct spk_synth *in_synth)
mutex_lock(&spk_mutex);
if (synth == in_synth)
synth_release();
-   for (i = 0; synths[i] != NULL; i++) {
+   for (i = 0; synths[i]; i++) {
if (in_synth == synths[i])
break;
}
-   for ( ; synths[i] != NULL; i++) /* compress table */
+   for ( ; synths[i]; i++) /* compress table */
synths[i] = synths[i + 1];
module_status = 0;
mutex_unlock(&spk_mutex);
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/15] Staging: rtl8192u - fixed block comments

2017-02-15 Thread Derek Robson
Fixed style of block comments across all of the rtl8192u driver
This driver has a lot of code commented out that could be deleted, I have not 
changed that.

This is a new series as only some of the 25 set sent last week got applied.

Derek Robson (15):
  Staging: rtl8192u: ieee80211: ieee80211_wx.c - style fix
  Staging: rtl8192u: r819xU_cmdpkt.c - style fix
  Staging: rtl8192u: r8192U_dm.c - style fix
  Staging: rtl8192u: r8192U_core.c - style fix
  Staging: rtl8192u: r8192U.h - style fix
  Staging: rtl8192u: ieee80211: rtl819x_TSProc.c - style fix
  Staging: rtl8192u: ieee80211: ieee80211_softmac.c - style fix
  Staging: rtl8192u: ieee80211: ieee80211_module.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_HTProc.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_BAProc.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_HT.h - style fix
  Staging: rtl8192u: ieee80211: rtl819x_BA.h - style fix
  Staging: rtl8192u: ieee80211: ieee80211_tx.c - style fix
  Staging: rtl8192u: ieee80211: ieee80211_rx.c - style fix
  Staging: rtl8192u: ieee80211: ieee80211.h - style fix

 drivers/staging/rtl8192u/ieee80211/ieee80211.h |  61 +++--
 .../staging/rtl8192u/ieee80211/ieee80211_module.c  |  60 ++---
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |  91 ---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |  71 ++---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  | 290 +++--
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c  |  87 ---
 drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h|  12 +-
 .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c|  28 +-
 drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h|  69 ++---
 .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c| 164 ++--
 .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c|   4 +-
 drivers/staging/rtl8192u/r8192U.h  |  39 ++-
 drivers/staging/rtl8192u/r8192U_core.c |  70 ++---
 drivers/staging/rtl8192u/r8192U_dm.c   | 175 +++--
 drivers/staging/rtl8192u/r819xU_cmdpkt.c   |  82 +++---
 15 files changed, 706 insertions(+), 597 deletions(-)

-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/15] Staging: rtl8192u: ieee80211: ieee80211_wx.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 87 ---
 1 file changed, 47 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index 563d7fed6e1c..0d24158e038a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -1,34 +1,34 @@
 /**
-
-  Copyright(c) 2004 Intel Corporation. All rights reserved.
-
-  Portions of this file are based on the WEP enablement code provided by the
-  Host AP project hostap-drivers v0.1.3
-  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
-  
-  Copyright (c) 2002-2003, Jouni Malinen 
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms of version 2 of the GNU General Public License as
-  published by the Free Software Foundation.
-
-  This program is distributed in the hope that it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc., 59
-  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-  The full GNU General Public License is included in this distribution in the
-  file called LICENSE.
-
-  Contact Information:
-  James P. Ketrenos 
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-**/
+ *
+ *  Copyright(c) 2004 Intel Corporation. All rights reserved.
+ *
+ *  Portions of this file are based on the WEP enablement code provided by the
+ *  Host AP project hostap-drivers v0.1.3
+ *  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ *  
+ *  Copyright (c) 2002-2003, Jouni Malinen 
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of version 2 of the GNU General Public License as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *  You should have received a copy of the GNU General Public License along 
with
+ *  this program; if not, write to the Free Software Foundation, Inc., 59
+ *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *  The full GNU General Public License is included in this distribution in the
+ *  file called LICENSE.
+ *
+ *  Contact Information:
+ *  James P. Ketrenos 
+ *  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ 
**/
 #include 
 #include 
 #include 
@@ -108,7 +108,8 @@ static inline char *rtl819x_translate_scan(struct 
ieee80211_device *ieee,
/* Add frequency/channel */
iwe.cmd = SIOCGIWFREQ;
 /* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode);
-   iwe.u.freq.e = 3; */
+ * iwe.u.freq.e = 3;
+ */
iwe.u.freq.m = network->channel;
iwe.u.freq.e = 0;
iwe.u.freq.i = 0;
@@ -227,7 +228,8 @@ static inline char *rtl819x_translate_scan(struct 
ieee80211_device *ieee,
 
 
/* Add EXTRA: Age to display seconds since last beacon/probe response
-* for given network. */
+* for given network.
+*/
iwe.cmd = IWEVCUSTOM;
p = custom;
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
@@ -325,7 +327,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
IEEE80211_DEBUG_WX("Disabling encryption.\n");
 
/* Check all the keys to see if any are still configured,
-* and if no key index was provided, de-init them all */
+* and if no key index was provided, de-init them all
+*/
for (i = 0; i < WEP_KEYS; i++) {
if (ieee->crypt[i] != NULL) {
if (key_provided)
@@ -352,7 +355,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
if (*crypt != NULL && (*crypt)->ops != NULL &&
strcmp((*crypt)->ops->name, "WEP") != 0) {
/* changing to use WEP; deinit previously used algorithm
-* on this key */
+* on this key
+*/
ieee80211_crypt_delayed_deinit(ieee, crypt);
}
 
@@ -399,7 +403,8 @@ int ieee80211_wx_set_encode(struct 

[PATCH 03/15] Staging: rtl8192u: r8192U_dm.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/r8192U_dm.c | 175 +++
 1 file changed, 97 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 9209aad0515e..9f05280e557b 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -1,18 +1,18 @@
-/*++
-Copyright-c Realtek Semiconductor Corp. All rights reserved.
-
-Module Name:
-   r8192U_dm.c
-
-Abstract:
-   HW dynamic mechanism.
-
-Major Change History:
-   WhenWho What
-   --  --- ---
-   2008-05-14  amy create version 0 porting from 
windows code.
-
---*/
+/*
+ * Copyright-c Realtek Semiconductor Corp. All rights reserved.
+ *
+ * Module Name:
+ *  r8192U_dm.c
+ *
+ * Abstract:
+ * HW dynamic mechanism.
+ *
+ * Major Change History:
+ * WhenWho What
+ * --  --- ---
+ * 2008-05-14  amy create version 0 porting from 
windows code.
+ *
+ */
 #include "r8192U.h"
 #include "r8192U_dm.h"
 #include "r8192U_hw.h"
@@ -158,20 +158,20 @@ void dm_CheckRxAggregation(struct net_device *dev)
unsigned long   curRxOkCnt = 0;
 
 /*
-   if (pHalData->bForcedUsbRxAggr) {
-   if (pHalData->ForcedUsbRxAggrInfo == 0) {
-   if (pHalData->bCurrentRxAggrEnable) {
-   Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, 
FALSE);
-   }
-   } else {
-   if (!pHalData->bCurrentRxAggrEnable || 
(pHalData->ForcedUsbRxAggrInfo != pHalData->LastUsbRxAggrInfoSetting)) {
-   Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, 
TRUE);
-   }
-   }
-   return;
-   }
-
-*/
+ * if (pHalData->bForcedUsbRxAggr) {
+ * if (pHalData->ForcedUsbRxAggrInfo == 0) {
+ * if (pHalData->bCurrentRxAggrEnable) {
+ * Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, 
FALSE);
+ * }
+ * } else {
+ * if (!pHalData->bCurrentRxAggrEnable || 
(pHalData->ForcedUsbRxAggrInfo != pHalData->LastUsbRxAggrInfoSetting)) {
+ * Adapter->HalFunc.HalUsbRxAggrHandler(Adapter, 
TRUE);
+ * }
+ * }
+ * return;
+ * }
+ *
+ */
curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
 
@@ -293,7 +293,8 @@ void init_rate_adaptive(struct net_device *dev)
  * WhenWho Remark
  * 05/26/08amy Create version 0 porting from windows code.
  *
- *---*/
+ *---
+ */
 static void dm_check_rate_adaptive(struct net_device *dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -347,9 +348,10 @@ static void dm_check_rate_adaptive(struct net_device *dev)
((bshort_gi_enabled) ? BIT(31) : 0);
 
/* 2007/10/08 MH We support RA smooth scheme now. When it is 
the first
-  time to link with AP. We will not change upper/lower 
threshold. If
-  STA stay in high or low level, we must change two different 
threshold
-  to prevent jumping frequently. */
+* time to link with AP. We will not change upper/lower 
threshold. If
+* STA stay in high or low level, we must change two different 
threshold
+* to prevent jumping frequently.
+*/
if (pra->ratr_state == DM_RATR_STA_HIGH) {
HighRSSIThreshForRA = 
pra->high2low_rssi_thresh_for_ra;
LowRSSIThreshForRA  = (priv->CurrentChannelBW != 
HT_CHANNEL_WIDTH_20) ?
@@ -391,7 +393,8 @@ static void dm_check_rate_adaptive(struct net_device *dev)
ping_rssi_state = 1;
}
/*else
-   DbgPrint("TestRSSI is between the 
range.\n");*/
+*  DbgPrint("TestRSSI is between the 
range.\n");
+*/
} else {
/*DbgPrint("TestRSSI Recover to 0x%x\n", 
targetRATR);*/
ping_rssi_state = 0;
@@ -732,8 +735,9 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct 
net_device *dev)
tmpCCK40Mindex = 0;
   

[PATCH 02/15] Staging: rtl8192u: r819xU_cmdpkt.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 82 
 1 file changed, 52 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c 
b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
index 370d97a18dce..3e0731b04619 100644
--- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c
+++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
@@ -34,7 +34,8 @@ rt_status SendTxCommandPacket(struct net_device *dev, void 
*pData, u32 DataLen)
unsigned char   *ptr_buf;
 
/* Get TCB and local buffer from common pool.
-  (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) */
+* (It is shared by CmdQ, MgntQ, and USB coalesce DataQ)
+*/
skb  = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4);
if (!skb)
return RT_STATUS_FAILURE;
@@ -76,7 +77,8 @@ rt_status SendTxCommandPacket(struct net_device *dev, void 
*pData, u32 DataLen)
  *  When   Who Remark
  *  05/12/2008 amy Create Version 0 porting from windows code.
  *
- *---*/
+ *---
+ */
 static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t 
*pstx_fb)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -87,8 +89,9 @@ static void cmpk_count_txstatistic(struct net_device *dev, 
cmpk_txfb_t *pstx_fb)
  (pu1Byte)(&rtState));
 
/* When RF is off, we should not count the packet for hw/sw synchronize
-  reason, ie. there may be a duration while sw switch is changed and
-  hw switch is being changed. */
+* reason, ie. there may be a duration while sw switch is changed and
+* hw switch is being changed.
+*/
if (rtState == eRfOff)
return;
 #endif
@@ -98,8 +101,9 @@ static void cmpk_count_txstatistic(struct net_device *dev, 
cmpk_txfb_t *pstx_fb)
return;
 #endif
/* We can not know the packet length and transmit type:
-  broadcast or uni or multicast. So the relative statistics
-  must be collected in tx feedback info. */
+* broadcast or uni or multicast. So the relative statistics
+* must be collected in tx feedback info.
+*/
if (pstx_fb->tok) {
priv->stats.txfeedbackok++;
priv->stats.txoktotal++;
@@ -155,7 +159,8 @@ static void cmpk_count_txstatistic(struct net_device *dev, 
cmpk_txfb_t *pstx_fb)
  *  When   Who Remark
  *  05/08/2008 amy Create Version 0 porting from windows code.
  *
- *---*/
+ *---
+ */
 static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -165,8 +170,9 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, 
u8 *pmsg)
 
/* 1. Extract TX feedback info from RFD to temp structure buffer. */
/* It seems that FW use big endian(MIPS) and DRV use little endian in
-  windows OS. So we have to read the content byte by byte or transfer
-  endian type before copy the message copy. */
+* windows OS. So we have to read the content byte by byte or transfer
+* endian type before copy the message copy.
+*/
/* Use pointer to transfer structure memory. */
memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t));
/* 2. Use tx feedback info to count TX statistics. */
@@ -174,7 +180,8 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, 
u8 *pmsg)
/* Comment previous method for TX statistic function. */
/* Collect info TX feedback packet to fill TCB. */
/* We can not know the packet length and transmit type: broadcast or uni
-  or multicast. */
+* or multicast.
+*/
 }
 
 static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev)
@@ -215,7 +222,8 @@ static void cmdpkt_beacontimerinterrupt_819xusb(struct 
net_device *dev)
  *  When   Who Remark
  *  05/12/2008 amy Add this for rtl8192 porting from windows code.
  *
- *---*/
+ *---
+ */
 static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg)
 {
cmpk_intr_sta_t rx_intr_status; /* */
@@ -225,8 +233,9 @@ static void cmpk_handle_interrupt_status(struct net_device 
*dev, u8 *pmsg)
 
/* 1. Extract TX feedback info from RFD to temp structure buffer. */
/* It seems that FW use big endian(MIPS) and DRV use little endian in
-  w

[PATCH 04/15] Staging: rtl8192u: r8192U_core.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/r8192U_core.c | 70 +-
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
b/drivers/staging/rtl8192u/r8192U_core.c
index d8dea0337de8..b631990b4969 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -503,8 +503,7 @@ static void watch_dog_timer_callback(unsigned long data);
 
 /
  *   -PROCFS STUFF-
-*
- */
+ /
 
 static struct proc_dir_entry *rtl8192_proc;
 
@@ -715,8 +714,8 @@ static void rtl8192_proc_remove_one(struct net_device *dev)
 }
 
 /
-   -MISC STUFF-
-*/
+ *  -MISC STUFF-
+ */
 
 short check_nic_enough_desc(struct net_device *dev, int queue_index)
 {
@@ -1328,7 +1327,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct 
sk_buff *skb)
  * 2006.10.30 by Emily
  *
  * \param QUEUEID   Software Queue
-*/
+ */
 static u8 MapHwQueueToFirmwareQueue(u8 QueueID)
 {
u8 QueueSelect = 0x0;   /* default set to */
@@ -1499,7 +1498,7 @@ static void tx_zero_isr(struct urb *tx_urb)
  * The tx procedure is just as following,
  * skb->cb will contain all the following information,
  * priority, morefrag, rate, &dev.
- * */
+ */
 short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -1840,8 +1839,8 @@ static void rtl8192_update_beacon(struct work_struct 
*work)
 }
 
 /*
-* background support to run QoS activate functionality
-*/
+ * background support to run QoS activate functionality
+ */
 static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK,
 EDCAPARA_VI, EDCAPARA_VO};
 static void rtl8192_qos_activate(struct work_struct *work)
@@ -1946,10 +1945,10 @@ static int rtl8192_handle_beacon(struct net_device *dev,
 }
 
 /*
-* handling the beaconing responses. if we get different QoS setting
-* off the network from the associated setting, adjust the QoS
-* setting
-*/
+ * handling the beaconing responses. if we get different QoS setting
+ * off the network from the associated setting, adjust the QoS
+ * setting
+ */
 static int rtl8192_qos_association_resp(struct r8192_priv *priv,
struct ieee80211_network *network)
 {
@@ -3045,8 +3044,8 @@ static bool rtl8192_adapter_start(struct net_device *dev)
  * be used to stop beacon transmission
  */
 /***
----NET STUFF---
-***/
+ *   ---NET STUFF---
+ ***/
 
 static struct net_device_stats *rtl8192_stats(struct net_device *dev)
 {
@@ -3074,9 +3073,9 @@ static bool HalTxCheckStuck819xUsb(struct net_device *dev)
 }
 
 /*
-*  
-*  First added: 2006.11.19 by emily
-*/
+ * 
+ * First added: 2006.11.19 by emily
+ */
 static RESET_TYPE TxCheckStuck(struct net_device *dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -4156,7 +4155,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv 
*priv, u8 *buffer,
  * Output: NONE
  *
  * Return: 0-100 percentage
- *---*/
+ *---
+ */
 static u8 rtl819x_query_rxpwrpercentage(s8 antpower)
 {
if ((antpower <= -100) || (antpower >= 20))
@@ -4529,19 +4529,19 @@ static void TranslateRxSignalStuff819xUsb(struct 
sk_buff *skb,
 }
 
 /**
-* Function:UpdateReceivedRateHistogramStatistics
-* Overview:Record the received data rate
-*
-* Input:
-*  struct net_device *dev
-*  struct ieee80211_rx_stats *stats
-*
-* Output:
-*
-*  (priv->stats.ReceivedRateHistogram[] is updated)
-* Return:
-*  None
-*/
+ * Function:   UpdateReceivedRateHistogramStatistics
+ * Overview:   Record the received data rate
+ *
+ * Input:
+ * struct net_device *dev
+ * struct ieee80211_rx_stats *stats
+ *
+ * Output:
+ *
+ * (priv->stats.ReceivedRateHistogram[] is updated)
+ * Return:
+ *

[PATCH 05/15] Staging: rtl8192u: r8192U.h - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/r8192U.h | 39 ++-
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U.h 
b/drivers/staging/rtl8192u/r8192U.h
index 0b7b04ea0910..a7ba8f37384e 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -626,7 +626,8 @@ typedef struct Stats {
long signal_quality;
long last_signal_strength_inpercent;
/* Correct smoothed ss in dbm, only used in driver
-* to report real power now */
+* to report real power now
+*/
long recv_signal_power;
u8 rx_rssi_percentage[4];
u8 rx_evm_percentage[2];
@@ -672,32 +673,40 @@ typedef struct _BB_REGISTER_DEFINITION {
/* Tx gain stage:   0x80c~0x80f [4 bytes]  */
u32 rfTxGainStage;
/* wire parameter control1: 0x820~0x823, 0x828~0x82b,
-*  0x830~0x833, 0x838~0x83b [16 bytes] */
+*  0x830~0x833, 0x838~0x83b [16 bytes]
+*/
u32 rfHSSIPara1;
/* wire parameter control2: 0x824~0x827, 0x82c~0x82f,
-*  0x834~0x837, 0x83c~0x83f [16 bytes] */
+*  0x834~0x837, 0x83c~0x83f [16 bytes]
+*/
u32 rfHSSIPara2;
/* Tx Rx antenna control:   0x858~0x85f [16 bytes] */
u32 rfSwitchControl;
/* AGC parameter control1:  0xc50~0xc53, 0xc58~0xc5b,
-*  0xc60~0xc63, 0xc68~0xc6b [16 bytes] */
+*  0xc60~0xc63, 0xc68~0xc6b [16 bytes]
+*/
u32 rfAGCControl1;
/* AGC parameter control2:  0xc54~0xc57, 0xc5c~0xc5f,
-*  0xc64~0xc67, 0xc6c~0xc6f [16 bytes] */
+*  0xc64~0xc67, 0xc6c~0xc6f [16 bytes]
+*/
u32 rfAGCControl2;
/* OFDM Rx IQ imbalance matrix: 0xc14~0xc17, 0xc1c~0xc1f,
-*  0xc24~0xc27, 0xc2c~0xc2f [16 bytes] */
+*  0xc24~0xc27, 0xc2c~0xc2f [16 bytes]
+*/
u32 rfRxIQImbalance;
/* Rx IQ DC offset and Rx digital filter, Rx DC notch filter:
 *  0xc10~0xc13, 0xc18~0xc1b,
-*  0xc20~0xc23, 0xc28~0xc2b [16 bytes] */
+*  0xc20~0xc23, 0xc28~0xc2b [16 bytes]
+*/
u32 rfRxAFE;
/* OFDM Tx IQ imbalance matrix: 0xc80~0xc83, 0xc88~0xc8b,
-*  0xc90~0xc93, 0xc98~0xc9b [16 bytes] */
+*  0xc90~0xc93, 0xc98~0xc9b [16 bytes]
+*/
u32 rfTxIQImbalance;
/* Tx IQ DC Offset and Tx DFIR type:
 *  0xc84~0xc87, 0xc8c~0xc8f,
-*  0xc94~0xc97, 0xc9c~0xc9f [16 bytes] */
+*  0xc94~0xc97, 0xc9c~0xc9f [16 bytes]
+*/
u32 rfTxAFE;
/* LSSI RF readback data:   0x8a0~0x8af [16 bytes] */
u32 rfLSSIReadBack;
@@ -776,7 +785,8 @@ typedef struct _phy_ofdm_rx_status_report_819xusb {
 typedef struct _phy_cck_rx_status_report_819xusb {
/* For CCK rate descriptor. This is an unsigned 8:1 variable.
 * LSB bit presend 0.5. And MSB 7 bts presend a signed value.
-* Range from -64~+63.5. */
+* Range from -64~+63.5.
+*/
u8  adc_pwdb_X[4];
u8  sq_rpt;
u8  cck_agc_rpt;
@@ -991,7 +1001,8 @@ typedef struct r8192_priv {
/* Control channel sub-carrier */
u8  nCur40MhzPrimeSC;
/* Test for shorten RF configuration time.
-* We save RF reg0 in this variable to reduce RF reading. */
+* We save RF reg0 in this variable to reduce RF reading.
+*/
u32 RfReg0Value[4];
u8  NumTotalRFPath;
boolbrfpath_rxenable[4];
@@ -1009,11 +1020,13 @@ typedef struct r8192_priv {
 
boolbstore_last_dtpflag;
/* Define to discriminate on High power State or
-* on sitesurvey to change Tx gain index */
+* on sitesurvey to change Tx gain index
+*/
boolbstart_txctrl_bydtp;
rate_adaptive rate_adaptive;
/* TX power tracking
-* OPEN/CLOSE TX POWER TRACKING */
+* OPEN/CLOSE TX POWER TRACKING
+*/
txbbgain_struct txbbgain_table[TxBBGainTableLength];
u8  txpower_count; /* For 6 sec do tracking again */
boolbtxpower_trackingInit;
-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.o

[PATCH 06/15] Staging: rtl8192u: ieee80211: rtl819x_TSProc.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index b9ff8fec2edf..b4c13fff2c65 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -21,7 +21,7 @@ static void TsInactTimeout(unsigned long data)
  *   input:  unsigned long  data   //acturally we send 
TX_TS_RECORD or RX_TS_RECORD to these timer
  *  return:  NULL
  *  notice:
-/
+ 
/
 static void RxPktPendingTimeout(unsigned long data)
 {
PRX_TS_RECORD   pRxTs = (PRX_TS_RECORD)data;
@@ -95,7 +95,7 @@ static void RxPktPendingTimeout(unsigned long data)
  *   input:  unsigned long  data   //acturally we send 
TX_TS_RECORD or RX_TS_RECORD to these timer
  *  return:  NULL
  *  notice:
-/
+ 
/
 static void TsAddBaProcess(unsigned long data)
 {
PTX_TS_RECORD   pTxTs = (PTX_TS_RECORD)data;
-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/15] Staging: rtl8192u: ieee80211: ieee80211_softmac.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 71 +++---
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 1bff0e91cc0c..58df6910584c 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -204,14 +204,14 @@ static u8 MgntQuery_MgntFrameTxRate(struct 
ieee80211_device *ieee)
}
 
/*
-   // Data rate of ProbeReq is already decided. Annie, 2005-03-31
-   if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) )
-   {
-   if(pMgntInfo->dot11CurrentWirelessMode==WIRELESS_MODE_A)
-   rate = 0x0c;
-   else
-   rate = 0x02;
-   }
+*  //Data rate of ProbeReq is already decided. Annie, 2005-03-31
+* if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) )
+* {
+* if(pMgntInfo->dot11CurrentWirelessMode==WIRELESS_MODE_A)
+* rate = 0x0c;
+* else
+* rate = 0x02;
+* }
 */
return rate;
 }
@@ -272,10 +272,10 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct 
ieee80211_device *ieee

if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\

(skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\
(ieee->queue_stop) ) {
-   /* insert the skb packet to the management queue */
-   /* as for the completion function, it does not need
+   /* insert the skb packet to the management queue
+* as for the completion function, it does not need
 * to check it any more.
-* */
+*/
printk("%s():insert to waitqueue!\n",__func__);
skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], 
skb);
} else {
@@ -1460,8 +1460,8 @@ inline void ieee80211_softmac_new_net(struct 
ieee80211_device *ieee, struct ieee
(!apset && ssidset && ssidbroad && ssidmatch)
){
/* if the essid is hidden replace it with the
-   * essid provided by the user.
-   */
+* essid provided by the user.
+*/
if (!ssidbroad) {
strncpy(tmp_ssid, 
ieee->current_network.ssid, IW_ESSID_MAX_SIZE);
tmp_ssid_len = 
ieee->current_network.ssid_len;
@@ -1731,11 +1731,10 @@ static short ieee80211_sta_ps_sleep(struct 
ieee80211_device *ieee, u32 *time_h,
int timeout = ieee->ps_timeout;
u8 dtim;
/*if(ieee->ps == IEEE80211_PS_DISABLED ||
-   ieee->iw_mode != IW_MODE_INFRA ||
-   ieee->state != IEEE80211_LINKED)
-
-   return 0;
-   */
+*  ieee->iw_mode != IW_MODE_INFRA ||
+*  ieee->state != IEEE80211_LINKED)
+*  return 0;
+*/
dtim = ieee->current_network.dtim_data;
if(!(dtim & IEEE80211_DTIM_VALID))
return 0;
@@ -2097,8 +2096,8 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, 
struct sk_buff *skb,
case IEEE80211_STYPE_DISASSOC:
case IEEE80211_STYPE_DEAUTH:
/* FIXME for now repeat all the association procedure
-   * both for disassociation and deauthentication
-   */
+* both for disassociation and deauthentication
+*/
if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
ieee->state == IEEE80211_LINKED &&
ieee->iw_mode == IW_MODE_INFRA){
@@ -2173,7 +2172,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, 
struct ieee80211_device *
/* insert the skb packet to the wait queue */
/* as for the completion function, it does not need
 * to check it any more.
-* */
+*/
//printk("error:no descriptor left@queue_index %d\n", 
queue_index);
//ieee80211_stop_queue(ieee);
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
@@ -2522,18 +2521,18 @@ static void ieee80211_associate_retry_wq(struct 
work_struct *work)
goto exit;
 
/* until we do not set the state to IEEE80211_NOLINK
-   * there are no possibility to have someone else trying
-   * to start an association procedure (we get here with
-   * ieee->state = IEEE

[PATCH 08/15] Staging: rtl8192u: ieee80211: ieee80211_module.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 .../staging/rtl8192u/ieee80211/ieee80211_module.c  | 60 +++---
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index a9a92d8e6ab0..5fdfff0816c5 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -1,34 +1,34 @@
 
/***
-
-  Copyright(c) 2004 Intel Corporation. All rights reserved.
-
-  Portions of this file are based on the WEP enablement code provided by the
-  Host AP project hostap-drivers v0.1.3
-  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
-  
-  Copyright (c) 2002-2003, Jouni Malinen 
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms of version 2 of the GNU General Public License as
-  published by the Free Software Foundation.
-
-  This program is distributed in the hope that it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc., 59
-  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-  The full GNU General Public License is included in this distribution in the
-  file called LICENSE.
-
-  Contact Information:
-  James P. Ketrenos 
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-***/
+ *
+ *  Copyright(c) 2004 Intel Corporation. All rights reserved.
+ *
+ *  Portions of this file are based on the WEP enablement code provided by the
+ *  Host AP project hostap-drivers v0.1.3
+ *  Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
+ *  
+ *  Copyright (c) 2002-2003, Jouni Malinen 
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of version 2 of the GNU General Public License as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *  You should have received a copy of the GNU General Public License along 
with
+ *  this program; if not, write to the Free Software Foundation, Inc., 59
+ *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *  The full GNU General Public License is included in this distribution in the
+ *  file called LICENSE.
+ *
+ *  Contact Information:
+ *  James P. Ketrenos 
+ *  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ 
***/
 
 #include 
 /* #include  */
-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/15] Staging: rtl8192u: ieee80211: rtl819x_BAProc.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c| 28 +++---
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index 51503ee0dce7..6619b8fb9700 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -14,7 +14,7 @@
  *   input:  PBA_RECORDpBA  //BA entry to be enabled
  *  u16Time //indicate time delay.
  *  output:  none
-/
+ 
/
 static void ActivateBAEntry(struct ieee80211_device *ieee, PBA_RECORD pBA, u16 
Time)
 {
pBA->bValid = true;
@@ -26,7 +26,7 @@ static void ActivateBAEntry(struct ieee80211_device *ieee, 
PBA_RECORD pBA, u16 T
  *function:  deactivate BA entry, including its timer.
  *   input:  PBA_RECORDpBA  //BA entry to be disabled
  *  output:  none
-/
+ 
/
 static void DeActivateBAEntry(struct ieee80211_device *ieee, PBA_RECORD pBA)
 {
pBA->bValid = false;
@@ -38,7 +38,7 @@ static void DeActivateBAEntry(struct ieee80211_device *ieee, 
PBA_RECORD pBA)
  *  PTX_TS_RECORD  pTxTs //Tx Ts which is to deactivate BA 
entry.
  *  output:  none
  *  notice:  As PTX_TS_RECORD structure will be defined in QOS, so wait to be 
merged. //FIXME
-/
+ 
/
 static u8 TxTsDeleteBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTs)
 {
PBA_RECORD  pAdmittedBa = &pTxTs->TxAdmittedBARecord;  
//These two BA entries must exist in TS structure
@@ -66,7 +66,7 @@ static u8 TxTsDeleteBA(struct ieee80211_device *ieee, 
PTX_TS_RECORD pTxTs)
  *  PRX_TS_RECORD  pRxTs //Rx Ts which is to deactivate BA 
entry.
  *  output:  none
  *  notice:  As PRX_TS_RECORD structure will be defined in QOS, so wait to be 
merged. //FIXME, same with above
-/
+ 
/
 static u8 RxTsDeleteBA(struct ieee80211_device *ieee, PRX_TS_RECORD pRxTs)
 {
PBA_RECORD  pBa = &pRxTs->RxAdmittedBARecord;
@@ -85,7 +85,7 @@ static u8 RxTsDeleteBA(struct ieee80211_device *ieee, 
PRX_TS_RECORD pRxTs)
  *   input:
  *  PBA_RECORD pBA //entry to be reset
  *  output:  none
-/
+ 
/
 void ResetBaEntry(PBA_RECORD pBA)
 {
pBA->bValid = false;
@@ -103,7 +103,7 @@ void ResetBaEntry(PBA_RECORD pBA)
  *  u8 type//indicate whether it's 
RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
  *  output:  none
  *  return:  sk_buff*  skb //return constructed skb to xmit
-***/
+ 
***/
 static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, 
PBA_RECORD pBA, u16 StatusCode, u8 type)
 {
struct sk_buff *skb = NULL;
@@ -177,7 +177,7 @@ static struct sk_buff *ieee80211_ADDBA(struct 
ieee80211_device *ieee, u8 *Dst, P
  *  u16ReasonCode  //status code.
  *  output:  none
  *  return:  sk_buff*  skb //return constructed skb to xmit
-/
+ 
/
 static struct sk_buff *ieee80211_DELBA(
struct ieee80211_device  *ieee,
u8   *dst,
@@ -242,7 +242,7 @@ static struct sk_buff *ieee80211_DELBA(
  *  PBA_RECORD pBA //BA_RECORD entry whi

[PATCH 09/15] Staging: rtl8192u: ieee80211: rtl819x_HTProc.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c| 164 ++---
 1 file changed, 82 insertions(+), 82 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
index c27397b14adb..9e8ed8c2e21e 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
@@ -217,8 +217,8 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString)
 }
 
 /*
-*  Return: true if station in half n mode and AP supports 40 bw
-*/
+ * Return: true if station in half n mode and AP supports 40 bw
+ */
 static bool IsHTHalfNmode40Bandwidth(struct ieee80211_device *ieee)
 {
boolretValue = false;
@@ -412,7 +412,7 @@ static void HTIOTPeerDetermine(struct ieee80211_device 
*ieee)
  *  u8 *   PeerMacAddr
  *  output:  none
  *  return:  return 1 if driver should declare MCS13 only(otherwise return 0)
-  * 
*/
+ 
**/
 static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 
*PeerMacAddr)
 {
return 0;
@@ -420,17 +420,17 @@ static u8 HTIOTActIsDisableMCS14(struct ieee80211_device 
*ieee, u8 *PeerMacAddr)
 
 
 /**
-* Function:HTIOTActIsDisableMCS15
-*
-* Overview:Check whether driver should declare capability of receiving 
MCS15
-*
-* Input:
-*  PADAPTERAdapter,
-*
-* Output:  None
-* Return:  true if driver should disable MCS15
-* 2008.04.15   Emily
-*/
+ * Function:   HTIOTActIsDisableMCS15
+ *
+ * Overview:   Check whether driver should declare capability of receiving 
MCS15
+ *
+ * Input:
+ * PADAPTERAdapter,
+ *
+ * Output: None
+ * Return: true if driver should disable MCS15
+ * 2008.04.15  Emily
+ */
 static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee)
 {
bool retValue = false;
@@ -457,17 +457,17 @@ static bool HTIOTActIsDisableMCS15(struct 
ieee80211_device *ieee)
 }
 
 /**
-* Function:HTIOTActIsDisableMCSTwoSpatialStream
-*
-* Overview:Check whether driver should declare capability of receiving All 
2 ss packets
-*
-* Input:
-*  PADAPTERAdapter,
-*
-* Output:  None
-* Return:  true if driver should disable all two spatial stream packet
-* 2008.04.21   Emily
-*/
+ * Function:   HTIOTActIsDisableMCSTwoSpatialStream
+ *
+ * Overview:   Check whether driver should declare capability of receiving All 
2 ss packets
+ *
+ * Input:
+ * PADAPTERAdapter,
+ *
+ * Output: None
+ * Return: true if driver should disable all two spatial stream packet
+ * 2008.04.21  Emily
+ */
 static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee,
 u8 *PeerMacAddr)
 {
@@ -483,7 +483,7 @@ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct 
ieee80211_device *ieee,
  *  u8*PeerMacAddr
  *  output:  none
  *  return:  return 1 if driver should disable EDCA turbo mode(otherwise 
return 0)
-  * 
*/
+ 
**/
 static u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device *ieee,
 u8 *PeerMacAddr)
 {  /* default enable EDCA Turbo mode. */
@@ -495,7 +495,7 @@ static u8 HTIOTActIsDisableEDCATurbo(struct 
ieee80211_device *ieee,
  *   input:  struct ieee80211_network *network   //current network we live
  *  output:  none
  *  return:  return 1 if true
-  * 
*/
+ 
*/
 static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
 {
u8  retValue = 0;
@@ -542,7 +542,7 @@ void HTResetIOTSetting(
  *  output:  none
  *  return:  none
  *  notice:  posHTCap can't be null and should be initialized before.
-  * 
*/
+ 
**/
 void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, 
u8 *len, u8 IsEncrypt)
 {
PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;

[PATCH 11/15] Staging: rtl8192u: ieee80211: rtl819x_HT.h - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h | 69 +
 1 file changed, 35 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h
index c3aabbaac7ae..d270c8ac807c 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h
@@ -86,38 +86,38 @@ typedef enum _CHNLOP{
((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
 
 /*
-typedefunion _HT_CAPABILITY{
-   u16 ShortData;
-   u8  CharData[2];
-   struct
-   {
-   u16 AdvCoding:1;
-   u16 ChlWidth:1;
-   u16 MimoPwrSave:2;
-   u16 GreenField:1;
-   u16 ShortGI20Mhz:1;
-   u16 ShortGI40Mhz:1;
-   u16 STBC:1;
-   u16 BeamForm:1;
-   u16 DelayBA:1;
-   u16 MaxAMSDUSize:1;
-   u16 DssCCk:1;
-   u16 PSMP:1;
-   u16 Rsvd:3;
-   }Field;
-}HT_CAPABILITY, *PHT_CAPABILITY;
-
-typedefunion _HT_CAPABILITY_MACPARA{
-   u8  ShortData;
-   u8  CharData[1];
-   struct
-   {
-   u8  MaxRxAMPDU:2;
-   u8  MPDUDensity:2;
-   u8  Rsvd:4;
-   }Field;
-}HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA;
-*/
+ * typedef union _HT_CAPABILITY{
+ * u16 ShortData;
+ * u8  CharData[2];
+ * struct
+ * {
+ * u16 AdvCoding:1;
+ * u16 ChlWidth:1;
+ * u16 MimoPwrSave:2;
+ * u16 GreenField:1;
+ * u16 ShortGI20Mhz:1;
+ * u16 ShortGI40Mhz:1;
+ * u16 STBC:1;
+ * u16 BeamForm:1;
+ * u16 DelayBA:1;
+ * u16 MaxAMSDUSize:1;
+ * u16 DssCCk:1;
+ * u16 PSMP:1;
+ * u16 Rsvd:3;
+ * }Field;
+ * }HT_CAPABILITY, *PHT_CAPABILITY;
+ *
+ * typedef union _HT_CAPABILITY_MACPARA{
+ * u8  ShortData;
+ * u8  CharData[1];
+ * struct
+ * {
+ * u8  MaxRxAMPDU:2;
+ * u8  MPDUDensity:2;
+ * u8  Rsvd:4;
+ * }Field;
+ * }HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA;
+ */
 
 typedef enum _HT_ACTION{
ACT_RECOMMAND_WIDTH = 0,
@@ -421,8 +421,9 @@ extern u8 MCS_FILTER_ALL[16];
 extern u8 MCS_FILTER_1SS[16];
 
 /* 2007/07/11 MH Modify the macro. Becaus STA may link with a N-AP. If we set
-   STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We 
have
-   to add a macro to judge wireless mode. */
+ * STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We 
have
+ * to add a macro to judge wireless mode.
+ */
 #define PICK_RATE(_nLegacyRate, _nMcsRate) \
(_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate)
 /* 2007/07/12 MH We only define legacy and HT wireless mode now. */
-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/15] Staging: rtl8192u: ieee80211: rtl819x_BA.h - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h
index 2c398ca9a8ac..e61f608718b1 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h
@@ -19,12 +19,12 @@
 #defineDELBA_REASON_UNKNOWN_BA 38
 #defineDELBA_REASON_TIMEOUT39
 /*  whether need define BA Action frames here?
-struct ieee80211_ADDBA_Req{
-   struct ieee80211_header_data header;
-   u8  category;
-   u8
-} __attribute__ ((packed));
-*/
+ *struct ieee80211_ADDBA_Req{
+ * struct ieee80211_header_data header;
+ * u8  category;
+ * u8
+ *} __attribute__ ((packed));
+ */
 //Is this need?I put here just to make it easier to define structure BA_RECORD 
//WB
 typedef union _SEQUENCE_CONTROL{
u16 ShortData;
-- 
2.11.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/15] Staging: rtl8192u: ieee80211: ieee80211.h - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 61 +++---
 1 file changed, 36 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 1bba5170e25a..0d247058bce4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -329,12 +329,13 @@ typedef struct ieee_param {
 // linux under 2.6.9 release may not support it, so modify it for common use
 #define IEEE80211_DATA_LEN 2304
 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
-   6.2.1.1.2.
-
-   The figure in section 7.1.2 suggests a body size of up to 2312
-   bytes is allowed, which is a bit confusing, I suspect this
-   represents the 2304 bytes of real data, plus a possible 8 bytes of
-   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
+ *   6.2.1.1.2.
+ *
+ *   The figure in section 7.1.2 suggests a body size of up to 2312
+ *   bytes is allowed, which is a bit confusing, I suspect this
+ *   represents the 2304 bytes of real data, plus a possible 8 bytes of
+ *   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
+ */
 #define IEEE80211_1ADDR_LEN 10
 #define IEEE80211_2ADDR_LEN 16
 #define IEEE80211_3ADDR_LEN 24
@@ -685,7 +686,8 @@ struct ieee_ibss_seq {
 
 /* NOTE: This data is for statistical purposes; not all hardware provides this
  *   information for frames received.  Not setting these will not cause
- *   any adverse affects. */
+ *   any adverse affects.
+ */
 struct ieee80211_rx_stats {
u32 mac_time[2];
s8 rssi;
@@ -754,7 +756,8 @@ struct ieee80211_rx_stats {
 /* IEEE 802.11 requires that STA supports concurrent reception of at least
  * three fragmented frames. This define can be increased to support more
  * concurrent frames, but it should be noted that each entry can consume about
- * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
+ * 2 kB of RAM and increasing cache size will slow down frame reassembly.
+ */
 #define IEEE80211_FRAG_CACHE_LEN 4
 
 struct ieee80211_frag_entry {
@@ -836,15 +839,15 @@ struct ieee80211_security {
 
 
 /*
- 802.11 data frame from AP
-  ,---.
-Bytes |  2   |  2   |6|6|6|  2   | 0..2312 |   4  |
-  |--|--|-|-|-|--|-|--|
-Desc. | ctrl | dura |  DA/RA  |   TA|SA   | Sequ |  frame  |  fcs |
-  |  | tion | (BSSID) | | | ence |  data   |  |
-  `---'
-Total: 28-2340 bytes
-*/
+ *  802.11 data frame from AP
+ *   ,---.
+ * Bytes |  2   |  2   |6|6|6|  2   | 0..2312 |   4  |
+ *   |--|--|-|-|-|--|-|--|
+ * Desc. | ctrl | dura |  DA/RA  |   TA|SA   | Sequ |  frame  |  fcs |
+ *   |  | tion | (BSSID) | | | ence |  data   |  |
+ *   `---'
+ *  Total: 28-2340 bytes
+ */
 
 /* Management Frame Information Element Types */
 enum ieee80211_mfie {
@@ -882,7 +885,8 @@ enum ieee80211_mfie {
 
 /* Minimal header; can be used for passing 802.11 frames with sufficient
  * information to determine what type of underlying data type is actually
- * stored in the data. */
+ * stored in the data.
+ */
 struct rtl_80211_hdr {
__le16 frame_ctl;
__le16 duration_id;
@@ -980,7 +984,8 @@ struct ieee80211_probe_response {
__le16 beacon_interval;
__le16 capability;
/* SSID, supported rates, FH params, DS params,
-* CF params, IBSS params, TIM (if beacon), RSN */
+* CF params, IBSS params, TIM (if beacon), RSN
+*/
struct ieee80211_info_element info_element[0];
 } __packed;
 
@@ -1055,7 +1060,8 @@ typedef union _frameqos {
 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
  * only use 8, and then use extended rates for the remaining supported
  * rates.  Other APs, however, stick all of their supported rates on the
- * main rates information element... */
+ * main rates information element...
+ */
 #define MAX_RATES_LENGTH  ((u8)12)
 #define MAX_RATES_EX_LENGTH   ((u8)16)
 #define MAX_NETWORK_COUNT  128
@@ -1677,14 +1683,16 @@ struct ieee80211_device {
spinlock_t wpax_suitlist_lock;
 
int tx_headroom; /* Set to size of any additional room needed at front
- * of allocated Tx SKBs */
+ * of allocated Tx SKBs
+ */
u32 config;
 
/* WEP and other encrypti

[PATCH 14/15] Staging: rtl8192u: ieee80211: ieee80211_rx.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 91 +++
 1 file changed, 58 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index d1057b13549d..6bf362b21a27 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -148,7 +148,8 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
} else {
/* received a fragment of a frame for which the head fragment
-* should have already been received */
+* should have already been received
+*/
entry = ieee80211_frag_cache_find(ieee, seq, frag, 
tid,hdr->addr2,
  hdr->addr1);
if (entry != NULL) {
@@ -207,7 +208,8 @@ static int ieee80211_frag_cache_invalidate(struct 
ieee80211_device *ieee,
  *
  * Responsible for handling management control frames
  *
- * Called by ieee80211_rx */
+ * Called by ieee80211_rx
+ */
 static inline int
 ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats, u16 type,
@@ -240,8 +242,9 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, 
struct sk_buff *skb,
   ieee->dev->name);
return 0;
 /*
-  hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
-  skb->data);*/
+ *  hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
+ *  skb->data);
+ */
}
 
if (ieee->hostapd && type == IEEE80211_TYPE_MGMT) {
@@ -249,14 +252,16 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, 
struct sk_buff *skb,
ieee->iw_mode == IW_MODE_MASTER) {
struct sk_buff *skb2;
/* Process beacon frames also in kernel driver to
-* update STA(AP) table statistics */
+* update STA(AP) table statistics
+*/
skb2 = skb_clone(skb, GFP_ATOMIC);
if (skb2)
hostap_rx(skb2->dev, skb2, rx_stats);
}
 
/* send management frames to the user space daemon for
-* processing */
+* processing
+*/
ieee->apdevstats.rx_packets++;
ieee->apdevstats.rx_bytes += skb->len;
prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
@@ -554,7 +559,8 @@ void ieee80211_indicate_packets(struct ieee80211_device 
*ieee, struct ieee80211_
  ethertype != ETH_P_AARP && ethertype != 
ETH_P_IPX) ||
 memcmp(sub_skb->data, bridge_tunnel_header, 
SNAP_SIZE) == 0)) {
/* remove RFC1042 or Bridge-Tunnel encapsulation and
-* replace EtherType */
+* replace EtherType
+*/
skb_pull(sub_skb, SNAP_SIZE);
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, 
ETH_ALEN);
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, 
ETH_ALEN);
@@ -885,7 +891,8 @@ static u8 parse_subframe(struct sk_buff *skb,
 
 /* All received frames are sent to this function. @skb contains the frame in
  * IEEE 802.11 format, i.e., in the format it was sent over air.
- * This function is called only as a tasklet (software IRQ). */
+ * This function is called only as a tasklet (software IRQ).
+ */
 int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 struct ieee80211_rx_stats *rx_stats)
 {
@@ -949,7 +956,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct 
sk_buff *skb,
//IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
 #ifdef NOT_YET
/* Put this code here so that we avoid duplicating it in all
-* Rx paths. - Jean II */
+* Rx paths. - Jean II
+*/
 #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
/* If spy monitoring on */
if (iface->spy_data.spy_number > 0) {
@@ -984,7 +992,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct 
sk_buff *skb,
 * bcrx_sta_key parameter is set, station specific key is used
 * even with broad/multicast targets (this is against IEEE
 * 802.11, but makes it easier to use different keys with
-* stations that do not support WEP key mapping). */
+* stations that do not support WEP key mapping).
+*/
 
if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
  

[PATCH 13/15] Staging: rtl8192u: ieee80211: ieee80211_tx.c - style fix

2017-02-15 Thread Derek Robson
Fixed style of block comments
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 290 +++---
 1 file changed, 150 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 949c496084fd..5704e4d7aa68 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -1,35 +1,34 @@
 /**
-
-  Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms of version 2 of the GNU General Public License as
-  published by the Free Software Foundation.
-
-  This program is distributed in the hope that it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc., 59
-  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-  The full GNU General Public License is included in this distribution in the
-  file called LICENSE.
-
-  Contact Information:
-  James P. Ketrenos 
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-**
-
-  Few modifications for Realtek's Wi-Fi drivers by
-  Andrea Merello 
-
-  A special thanks goes to Realtek for their support !
-
-**/
+ *
+ *  Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of version 2 of the GNU General Public License as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ *
+ *  You should have received a copy of the GNU General Public License along 
with
+ *  this program; if not, write to the Free Software Foundation, Inc., 59
+ *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *  The full GNU General Public License is included in this distribution in the
+ *  file called LICENSE.
+ *
+ *  Contact Information:
+ *  James P. Ketrenos 
+ *  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ *
+ *  Few modifications for Realtek's Wi-Fi drivers by
+ *  Andrea Merello 
+ *
+ *  A special thanks goes to Realtek for their support !
+ *
+ 
**/
 
 #include 
 #include 
@@ -55,101 +54,101 @@
 
 
 /*
-
-
-802.11 Data Frame
-
-
-802.11 frame_contorl for data frames - 2 bytes
- 
,-.
-bits | 0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  a  |  b  |  
c  |  d  |  e   |
- 
||-|-|-|-|-|-|-|-|-|-|-|-|-|--|
-val  | 0  |  0  |  0  |  1  |  x  |  0  |  0  |  0  |  1  |  0  |  x  |  x  |  
x  |  x  |  x   |
- 
||-|-|-|-|-|-|-|-|-|-|-|-|-|--|
-desc | ^-ver-^  |  ^type-^  |  ^-subtype-^  | to  |from |more |retry| 
pwr |more |wep   |
- |  |   | x=0 data,x=1 data+ack | DS  | DS  |frag | | 
mgm |data |  |
- 
'-'
-/\
-|
-802.11 Data Frame   |
-   ,- 'ctrl' expands to >---'
-  |
-  ,--'---,-.
-Bytes |  2   |  2   |6|6|6|  2   | 0..2312 |   4  |
-  |--|--|-|-|-|--|-|--|
-Desc. | ctrl | dura |  DA/RA  |   TA|SA   | Sequ |  Frame  |  fcs |
-  |  | tion | (BSSID) | | | ence |  data   |  |
-  `--| |--'
-Total: 28 non-data bytes `.'
-  |
-   .- 'Frame data' expands to <---'
-   |
-   V
-  ,---.
-Bytes |  1   |  1   |1|