Advertisement
Thjap_dev

6.1.B.0.544_6.1.1.B.0.253_diff

Nov 9th, 2012
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 130.43 KB | None | 0 0
  1. diff -ruN a/arch/arm/configs/riogrande_kumquat_defconfig b/arch/arm/configs/riogrande_kumquat_defconfig
  2. --- a/arch/arm/configs/riogrande_kumquat_defconfig  2012-10-27 17:12:40.107556197 +0900
  3. +++ b/arch/arm/configs/riogrande_kumquat_defconfig  2012-11-07 19:01:47.000000000 +0900
  4. @@ -1,6 +1,5 @@
  5.  CONFIG_EXPERIMENTAL=y
  6.  # CONFIG_LOCALVERSION_AUTO is not set
  7. -# CONFIG_SWAP is not set
  8.  CONFIG_SYSVIPC=y
  9.  CONFIG_BSD_PROCESS_ACCT=y
  10.  CONFIG_TASKSTATS=y
  11. @@ -28,7 +27,6 @@
  12.  CONFIG_MODVERSIONS=y
  13.  CONFIG_MODULE_SRCVERSION_ALL=y
  14.  # CONFIG_BLK_DEV_BSG is not set
  15. -CONFIG_DEFAULT_DEADLINE=y
  16.  CONFIG_ARCH_U8500=y
  17.  CONFIG_UX500_SOC_DB8500=y
  18.  CONFIG_MACH_U8500_KUMQUAT=y
  19. @@ -42,6 +40,7 @@
  20.  CONFIG_UX500_SUSPEND_MEM=y
  21.  CONFIG_UX500_SUSPEND_DBG=y
  22.  CONFIG_UX500_SUSPEND_DBG_WAKE_ON_UART=y
  23. +CONFIG_SONY_SSM=y
  24.  CONFIG_NO_HZ=y
  25.  CONFIG_HIGH_RES_TIMERS=y
  26.  CONFIG_SMP=y
  27. @@ -351,6 +350,7 @@
  28.  CONFIG_ANDROID_RAM_CONSOLE=y
  29.  CONFIG_ANDROID_TIMED_GPIO=y
  30.  CONFIG_ANDROID_LOW_MEMORY_KILLER=y
  31. +CONFIG_ZRAM=y
  32.  CONFIG_CG2900=y
  33.  CONFIG_CG2900_CHIP=y
  34.  CONFIG_STLC2690_CHIP=y
  35. diff -ruN a/arch/arm/configs/riogrande_lotus_defconfig b/arch/arm/configs/riogrande_lotus_defconfig
  36. --- a/arch/arm/configs/riogrande_lotus_defconfig    2012-10-27 17:12:40.075555580 +0900
  37. +++ b/arch/arm/configs/riogrande_lotus_defconfig    2012-11-07 19:01:47.000000000 +0900
  38. @@ -1,6 +1,5 @@
  39.  CONFIG_EXPERIMENTAL=y
  40.  # CONFIG_LOCALVERSION_AUTO is not set
  41. -# CONFIG_SWAP is not set
  42.  CONFIG_SYSVIPC=y
  43.  CONFIG_BSD_PROCESS_ACCT=y
  44.  CONFIG_TASKSTATS=y
  45. @@ -28,7 +27,6 @@
  46.  CONFIG_MODVERSIONS=y
  47.  CONFIG_MODULE_SRCVERSION_ALL=y
  48.  # CONFIG_BLK_DEV_BSG is not set
  49. -CONFIG_DEFAULT_DEADLINE=y
  50.  CONFIG_ARCH_U8500=y
  51.  CONFIG_UX500_SOC_DB8500=y
  52.  CONFIG_U8500_SD_MMC_CARD_SUPPORT=y
  53. @@ -43,6 +41,7 @@
  54.  CONFIG_UX500_SUSPEND_MEM=y
  55.  CONFIG_UX500_SUSPEND_DBG=y
  56.  CONFIG_UX500_SUSPEND_DBG_WAKE_ON_UART=y
  57. +CONFIG_SONY_SSM=y
  58.  CONFIG_NO_HZ=y
  59.  CONFIG_HIGH_RES_TIMERS=y
  60.  CONFIG_SMP=y
  61. @@ -353,6 +352,7 @@
  62.  CONFIG_ANDROID_RAM_CONSOLE=y
  63.  CONFIG_ANDROID_TIMED_GPIO=y
  64.  CONFIG_ANDROID_LOW_MEMORY_KILLER=y
  65. +CONFIG_ZRAM=y
  66.  CONFIG_CG2900=y
  67.  CONFIG_CG2900_CHIP=y
  68.  CONFIG_STLC2690_CHIP=y
  69. diff -ruN a/arch/arm/configs/riogrande_nypon_defconfig b/arch/arm/configs/riogrande_nypon_defconfig
  70. --- a/arch/arm/configs/riogrande_nypon_defconfig    2012-10-27 17:12:40.095555964 +0900
  71. +++ b/arch/arm/configs/riogrande_nypon_defconfig    2012-10-24 23:38:08.000000000 +0900
  72. @@ -28,7 +28,6 @@
  73.  CONFIG_MODVERSIONS=y
  74.  CONFIG_MODULE_SRCVERSION_ALL=y
  75.  # CONFIG_BLK_DEV_BSG is not set
  76. -CONFIG_DEFAULT_DEADLINE=y
  77.  CONFIG_ARCH_U8500=y
  78.  CONFIG_UX500_SOC_DB8500=y
  79.  CONFIG_MACH_U8500_NYPON=y
  80. diff -ruN a/arch/arm/configs/riogrande_pdp_defconfig b/arch/arm/configs/riogrande_pdp_defconfig
  81. --- a/arch/arm/configs/riogrande_pdp_defconfig  2012-10-27 17:12:40.079555656 +0900
  82. +++ b/arch/arm/configs/riogrande_pdp_defconfig  2012-10-24 23:38:08.000000000 +0900
  83. @@ -28,7 +28,6 @@
  84.  CONFIG_MODVERSIONS=y
  85.  CONFIG_MODULE_SRCVERSION_ALL=y
  86.  # CONFIG_BLK_DEV_BSG is not set
  87. -CONFIG_DEFAULT_DEADLINE=y
  88.  CONFIG_ARCH_U8500=y
  89.  CONFIG_UX500_SOC_DB8500=y
  90.  CONFIG_U8500_SD_MMC_CARD_SUPPORT=y
  91. diff -ruN a/arch/arm/configs/riogrande_pdp_r2_defconfig b/arch/arm/configs/riogrande_pdp_r2_defconfig
  92. --- a/arch/arm/configs/riogrande_pdp_r2_defconfig   2012-10-27 17:12:40.087555813 +0900
  93. +++ b/arch/arm/configs/riogrande_pdp_r2_defconfig   2012-10-24 23:38:08.000000000 +0900
  94. @@ -28,7 +28,6 @@
  95.  CONFIG_MODVERSIONS=y
  96.  CONFIG_MODULE_SRCVERSION_ALL=y
  97.  # CONFIG_BLK_DEV_BSG is not set
  98. -CONFIG_DEFAULT_DEADLINE=y
  99.  CONFIG_ARCH_U8500=y
  100.  CONFIG_UX500_SOC_DB8500=y
  101.  CONFIG_U8500_SD_MMC_CARD_SUPPORT=y
  102. diff -ruN a/arch/arm/configs/riogrande_pepper_defconfig b/arch/arm/configs/riogrande_pepper_defconfig
  103. --- a/arch/arm/configs/riogrande_pepper_defconfig   2012-10-27 17:12:40.103556118 +0900
  104. +++ b/arch/arm/configs/riogrande_pepper_defconfig   2012-11-07 19:01:47.000000000 +0900
  105. @@ -1,6 +1,5 @@
  106.  CONFIG_EXPERIMENTAL=y
  107.  # CONFIG_LOCALVERSION_AUTO is not set
  108. -# CONFIG_SWAP is not set
  109.  CONFIG_SYSVIPC=y
  110.  CONFIG_BSD_PROCESS_ACCT=y
  111.  CONFIG_TASKSTATS=y
  112. @@ -28,7 +27,6 @@
  113.  CONFIG_MODVERSIONS=y
  114.  CONFIG_MODULE_SRCVERSION_ALL=y
  115.  # CONFIG_BLK_DEV_BSG is not set
  116. -CONFIG_DEFAULT_DEADLINE=y
  117.  CONFIG_ARCH_U8500=y
  118.  CONFIG_UX500_SOC_DB8500=y
  119.  CONFIG_U8500_SD_MMC_CARD_SUPPORT=y
  120. @@ -43,6 +41,7 @@
  121.  CONFIG_UX500_SUSPEND_MEM=y
  122.  CONFIG_UX500_SUSPEND_DBG=y
  123.  CONFIG_UX500_SUSPEND_DBG_WAKE_ON_UART=y
  124. +CONFIG_SONY_SSM=y
  125.  CONFIG_NO_HZ=y
  126.  CONFIG_HIGH_RES_TIMERS=y
  127.  CONFIG_SMP=y
  128. @@ -353,6 +352,7 @@
  129.  CONFIG_ANDROID_RAM_CONSOLE=y
  130.  CONFIG_ANDROID_TIMED_GPIO=y
  131.  CONFIG_ANDROID_LOW_MEMORY_KILLER=y
  132. +CONFIG_ZRAM=y
  133.  CONFIG_CG2900=y
  134.  CONFIG_CG2900_CHIP=y
  135.  CONFIG_STLC2690_CHIP=y
  136. diff -ruN a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
  137. --- a/arch/arm/mach-ux500/Makefile  2012-10-27 17:12:41.915590819 +0900
  138. +++ b/arch/arm/mach-ux500/Makefile  2012-10-24 23:38:08.000000000 +0900
  139. @@ -5,7 +5,8 @@
  140.  obj-y              := clock.o cpu.o devices.o dcache.o \
  141.                    devices-common.o id.o pins.o \
  142.                    usb.o reboot_reasons.o timer.o \
  143. -                  uart-db8500.o clock-debug.o
  144. +                  uart-db8500.o clock-debug.o \
  145. +                  irq-trigger.o
  146.  obj-y              += pm/ test/
  147.  
  148.  
  149. diff -ruN a/arch/arm/mach-ux500/board-rio-grande.c b/arch/arm/mach-ux500/board-rio-grande.c
  150. --- a/arch/arm/mach-ux500/board-rio-grande.c    2012-10-27 17:12:41.791588443 +0900
  151. +++ b/arch/arm/mach-ux500/board-rio-grande.c    2012-10-24 23:38:08.000000000 +0900
  152. @@ -1011,8 +1011,8 @@
  153.     .als_name = "tsl2772_als",
  154.     .raw_settings = NULL,
  155.     .parameters = {
  156. -       .prox_th_min = 500,
  157. -       .prox_th_max = 520,
  158. +       .prox_th_min = 255,
  159. +       .prox_th_max = 480,
  160.         .als_gate = 10,
  161.     },
  162.     .als_can_wake = false,
  163. diff -ruN a/arch/arm/mach-ux500/clock-db8500.c b/arch/arm/mach-ux500/clock-db8500.c
  164. --- a/arch/arm/mach-ux500/clock-db8500.c    2012-10-27 17:12:41.959591657 +0900
  165. +++ b/arch/arm/mach-ux500/clock-db8500.c    2012-10-24 23:38:08.000000000 +0900
  166. @@ -69,18 +69,8 @@
  167.  
  168.  static int sysclk_enable(struct clk *clk)
  169.  {
  170. -   static bool swat_enable;
  171.     int r;
  172.  
  173. -   if (!swat_enable) {
  174. -       r = ab8500_sysctrl_set(AB8500_SWATCTRL,
  175. -           AB8500_SWATCTRL_SWATENABLE);
  176. -       if (r)
  177. -           return r;
  178. -
  179. -       swat_enable = true;
  180. -   }
  181. -
  182.     r = request_sysclk(true);
  183.     if (r)
  184.         return r;
  185. @@ -926,6 +916,10 @@
  186.                 goto err_sysclk;
  187.         }
  188.     }
  189. +   /* Disable SWAT  */
  190. +   if (ab8500_sysctrl_clear(AB8500_SWATCTRL, AB8500_SWATCTRL_SWATENABLE))
  191. +       goto err_swat;
  192. +
  193.     goto unlock_and_exit;
  194.  
  195.  err_sysclk:
  196. diff -ruN a/arch/arm/mach-ux500/hwmem-int.c b/arch/arm/mach-ux500/hwmem-int.c
  197. --- a/arch/arm/mach-ux500/hwmem-int.c   2012-10-27 17:12:41.763587914 +0900
  198. +++ b/arch/arm/mach-ux500/hwmem-int.c   2012-10-24 23:38:08.000000000 +0900
  199. @@ -23,6 +23,13 @@
  200.  void *cona_get_alloc_kaddr(void *instance, void *alloc);
  201.  size_t cona_get_alloc_size(void *alloc);
  202.  
  203. +/* SCATT API */
  204. +void *scatt_create(const char *name);
  205. +void *scatt_alloc(void *instance, size_t size);
  206. +void scatt_free(void *instance, void *alloc);
  207. +size_t scatt_get_alloc_size(void *alloc);
  208. +struct page **scatt_get_alloc_sglist(void *alloc);
  209. +
  210.  struct hwmem_mem_type_struct *hwmem_mem_types;
  211.  unsigned int hwmem_num_mem_types;
  212.  
  213. @@ -89,22 +96,28 @@
  214.         return -ENOMEM;
  215.  
  216.     hwmem_mem_types[0].id = HWMEM_MEM_SCATTERED_SYS;
  217. -   hwmem_mem_types[0].allocator_api.alloc = cona_alloc;
  218. -   hwmem_mem_types[0].allocator_api.free = cona_free;
  219. -   hwmem_mem_types[0].allocator_api.get_alloc_paddr =
  220. -                           cona_get_alloc_paddr;
  221. -   hwmem_mem_types[0].allocator_api.get_alloc_kaddr =
  222. -                           cona_get_alloc_kaddr;
  223. -   hwmem_mem_types[0].allocator_api.get_alloc_size = cona_get_alloc_size;
  224. -   hwmem_mem_types[0].allocator_instance = cona_create("hwmem",
  225. -                       hwmem_paddr, hwmem_size);
  226. +   hwmem_mem_types[0].allocator_api.alloc = scatt_alloc;
  227. +   hwmem_mem_types[0].allocator_api.free = scatt_free;
  228. +   hwmem_mem_types[0].allocator_api.get_alloc_size = scatt_get_alloc_size;
  229. +   hwmem_mem_types[0].allocator_api.get_alloc_sglist = scatt_get_alloc_sglist;
  230. +   hwmem_mem_types[0].allocator_instance = scatt_create("hwmem_scatt");
  231.     if (IS_ERR(hwmem_mem_types[0].allocator_instance)) {
  232.         ret = PTR_ERR(hwmem_mem_types[0].allocator_instance);
  233.         goto hwmem_ima_init_failed;
  234.     }
  235.  
  236. -   hwmem_mem_types[1] = hwmem_mem_types[0];
  237.     hwmem_mem_types[1].id = HWMEM_MEM_CONTIGUOUS_SYS;
  238. +   hwmem_mem_types[1].allocator_api.alloc = cona_alloc;
  239. +   hwmem_mem_types[1].allocator_api.free = cona_free;
  240. +   hwmem_mem_types[1].allocator_api.get_alloc_paddr = cona_get_alloc_paddr;
  241. +   hwmem_mem_types[1].allocator_api.get_alloc_kaddr = cona_get_alloc_kaddr;
  242. +   hwmem_mem_types[1].allocator_api.get_alloc_size = cona_get_alloc_size;
  243. +   hwmem_mem_types[1].allocator_instance = cona_create("hwmem_cona",
  244. +                       hwmem_paddr, hwmem_size);
  245. +   if (IS_ERR(hwmem_mem_types[1].allocator_instance)) {
  246. +       ret = PTR_ERR(hwmem_mem_types[1].allocator_instance);
  247. +       goto hwmem_ima_init_failed;
  248. +   }
  249.  
  250.     hwmem_mem_types[2] = hwmem_mem_types[1];
  251.     hwmem_mem_types[2].id = HWMEM_MEM_PROTECTED_SYS;
  252. diff -ruN a/arch/arm/mach-ux500/include/mach/irq-trigger.h b/arch/arm/mach-ux500/include/mach/irq-trigger.h
  253. --- a/arch/arm/mach-ux500/include/mach/irq-trigger.h    1970-01-01 09:00:00.000000000 +0900
  254. +++ b/arch/arm/mach-ux500/include/mach/irq-trigger.h    2012-10-24 23:38:08.000000000 +0900
  255. @@ -0,0 +1,28 @@
  256. +/* kernel/arch/arm/mach-ux500/include/mach/irq-trigger.h
  257. + *
  258. + * Copyright (C) 2012 Sony Mobile Communications AB.
  259. + *
  260. + * Author: Krzysztof Antonowicz <krzysztof.antonowicz@sonymobile.com>
  261. + *
  262. + * This program is free software; you can redistribute it and/or modify
  263. + * it under the terms of the GNU General Public License version 2, as
  264. + * published by the Free Software Foundation; either version 2
  265. + * of the License, or (at your option) any later version.
  266. + */
  267. +
  268. +#ifndef IRQ_TRIGGER_H
  269. +#define IRQ_TRIGGER_H
  270. +
  271. +/**
  272. + * irq_trigger_set_gic_spi_pending_interrupt(unsigned int int_id)
  273. + *
  274. + * @int_id: INTID for SPI (Shared Peripheral Interrupt).
  275. + *          Minimum INTID for SPI is 32 and maximum 255.
  276. + *          The Interrupt Distributor ignores writes to unused INTIDs.
  277. + *
  278. + * Set an interrupt to the pending or active-and-pending state.
  279. + * Returns 0 if write succeeded.
  280. + */
  281. +int irq_trigger_set_gic_spi_pending_interrupt(unsigned int int_id);
  282. +
  283. +#endif
  284. diff -ruN a/arch/arm/mach-ux500/irq-trigger.c b/arch/arm/mach-ux500/irq-trigger.c
  285. --- a/arch/arm/mach-ux500/irq-trigger.c 1970-01-01 09:00:00.000000000 +0900
  286. +++ b/arch/arm/mach-ux500/irq-trigger.c 2012-10-24 23:38:08.000000000 +0900
  287. @@ -0,0 +1,33 @@
  288. +/* kernel/arch/arm/mach-ux500/irq-trigger.c
  289. + *
  290. + * Copyright (C) 2012 Sony Mobile Communications AB.
  291. + *
  292. + * Author: Krzysztof Antonowicz <krzysztof.antonowicz@sonymobile.com>
  293. + *
  294. + * This program is free software; you can redistribute it and/or modify
  295. + * it under the terms of the GNU General Public License version 2, as
  296. + * published by the Free Software Foundation; either version 2
  297. + * of the License, or (at your option) any later version.
  298. + */
  299. +
  300. +#include <linux/io.h>
  301. +#include <linux/errno.h>
  302. +#include <mach/hardware.h>
  303. +#include <asm/hardware/gic.h>
  304. +
  305. +#define MIN_SPI_INTID  (32)
  306. +#define MAX_SPI_INTID  (255)
  307. +
  308. +int irq_trigger_set_gic_spi_pending_interrupt(unsigned int int_id)
  309. +{
  310. +
  311. +   if (int_id < MIN_SPI_INTID || int_id > MAX_SPI_INTID)
  312. +       return -EINVAL;
  313. +
  314. +   writel_relaxed(1 << (int_id % 32),
  315. +       __io_address(U8500_GIC_DIST_BASE) +
  316. +       GIC_DIST_PENDING_SET + 4 * (int_id / 32));
  317. +
  318. +   return 0;
  319. +}
  320. +
  321. diff -ruN a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/ump_kernel_api_hwmem.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/ump_kernel_api_hwmem.c
  322. --- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/ump_kernel_api_hwmem.c    2012-10-27 17:12:10.506969845 +0900
  323. +++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/ump_kernel_api_hwmem.c    2012-10-24 23:38:10.000000000 +0900
  324. @@ -10,6 +10,7 @@
  325.  
  326.  #include <linux/hwmem.h>
  327.  #include <linux/err.h>
  328. +#include <linux/slab.h>
  329.  
  330.  
  331.  /* The UMP kernel API for hwmem has been mapped so that
  332. @@ -63,7 +64,14 @@
  333.  
  334.  unsigned long ump_dd_phys_block_count_get(ump_dd_handle memh)
  335.  {
  336. -   return 1;
  337. +   size_t hwmem_mem_chunk_length;
  338. +   int hwmem_result = 0;
  339. +   struct hwmem_alloc *alloc = (struct hwmem_alloc *)memh;
  340. +
  341. +   /* Call hwmem_pin with mem_chunks set to NULL to get hwmem_mem_chunk_length */
  342. +   hwmem_result = hwmem_pin(alloc, NULL, &hwmem_mem_chunk_length);
  343. +
  344. +   return hwmem_mem_chunk_length;
  345.  }
  346.  
  347.  
  348. @@ -72,34 +80,40 @@
  349.                                            ump_dd_physical_block * blocks,
  350.                                            unsigned long num_blocks)
  351.  {
  352. -   struct hwmem_mem_chunk hwmem_mem_chunk;
  353. -   size_t hwmem_mem_chunk_length = 1;
  354. +   struct hwmem_mem_chunk *hwmem_mem_chunks;
  355. +   size_t hwmem_mem_chunk_length = num_blocks;
  356.  
  357.     int hwmem_result;
  358. +   int i;
  359. +
  360.     struct hwmem_alloc *alloc = (struct hwmem_alloc *)memh;
  361.  
  362. +   hwmem_mem_chunks = (struct hwmem_mem_chunk *)kmalloc(sizeof(struct hwmem_mem_chunk)*num_blocks, GFP_KERNEL);
  363. +
  364.     if (unlikely(blocks == NULL)) {
  365.         MALI_DEBUG_PRINT(1, ("%s: blocks == NULL\n",__func__));
  366.         return UMP_DD_INVALID;
  367.     }
  368.  
  369. -   if (unlikely(1 != num_blocks)) {
  370. -       MALI_DEBUG_PRINT(1, ("%s: num_blocks == %d (!= 1)\n",__func__, num_blocks));
  371. -       return UMP_DD_INVALID;
  372. -   }
  373. -
  374. -   MALI_DEBUG_PRINT(5, ("Returning physical block information. Alloc: 0x%x\n", memh));
  375. +   MALI_DEBUG_PRINT(5, ("Returning physical block information. Alloc: 0x%x num_blocks=%d\n", memh, num_blocks));
  376.  
  377.     /* It might not look natural to pin here, but it matches the usage by the mali kernel module */
  378. -   hwmem_result = hwmem_pin(alloc, &hwmem_mem_chunk, &hwmem_mem_chunk_length);
  379. +   hwmem_result = hwmem_pin(alloc, hwmem_mem_chunks, &hwmem_mem_chunk_length);
  380.  
  381.     if (unlikely(hwmem_result < 0)) {
  382.         MALI_DEBUG_PRINT(1, ("%s: Pin failed. Alloc: 0x%x\n",__func__, memh));
  383. +       kfree(hwmem_mem_chunks);
  384.         return UMP_DD_INVALID;
  385.     }
  386.  
  387. -   blocks[0].addr = hwmem_mem_chunk.paddr;
  388. -   blocks[0].size = hwmem_mem_chunk.size;
  389. +   /* Scattered: Currently every page is one mem chunk. It's probably more
  390. +      efficient to create bigger mem chunks if possible when allocated pages
  391. +      are next to each other in memory */
  392. +   for(i = 0; i < hwmem_mem_chunk_length; i++) {
  393. +       blocks[i].addr = hwmem_mem_chunks[i].paddr;
  394. +       blocks[i].size = hwmem_mem_chunks[i].size;
  395. +   }
  396. +   kfree(hwmem_mem_chunks);
  397.  
  398.     hwmem_set_domain(alloc, HWMEM_ACCESS_READ | HWMEM_ACCESS_WRITE,
  399.         HWMEM_DOMAIN_SYNC, NULL);
  400. diff -ruN a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
  401. --- a/drivers/mfd/ab8500-core.c 2012-10-27 17:12:10.066964721 +0900
  402. +++ b/drivers/mfd/ab8500-core.c 2012-10-24 23:38:12.000000000 +0900
  403. @@ -22,7 +22,7 @@
  404.  #include <linux/mfd/abx500.h>
  405.  #include <linux/mfd/ab8500.h>
  406.  #include <linux/regulator/ab8500.h>
  407. -
  408. +#include <mach/irq-trigger.h>
  409.  /*
  410.   * Interrupt register offsets
  411.   * Bank : 0x0E
  412. @@ -298,11 +298,14 @@
  413.  {
  414.     struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data);
  415.     int i;
  416. +   bool trigger_irq = false;
  417. +   int ret_val;
  418.  
  419.     for (i = 0; i < ab8500->mask_size; i++) {
  420.         u8 old = ab8500->oldmask[i];
  421.         u8 new = ab8500->mask[i];
  422.         int reg;
  423. +       u8 value;
  424.  
  425.         if (new == old)
  426.             continue;
  427. @@ -315,11 +318,38 @@
  428.             is_ab8500_1p1_or_earlier(ab8500))
  429.             continue;
  430.  
  431. +       mutex_lock(&ab8500->latch_lock);
  432. +
  433. +       /*
  434. +        * Clear old latched interrupts, but remember interrupts which
  435. +        * are still valid to handle them when interrupt will be
  436. +        * triggered.
  437. +        */
  438. +       get_register_interruptible(ab8500, AB8500_INTERRUPT,
  439. +           AB8500_IT_LATCH1_REG + ab8500_irq_regoffset[i], &value);
  440. +
  441. +       ab8500->latch[i] = (ab8500->latch[i] | value) & ~old;
  442. +
  443. +       if (ab8500->latch[i] && !trigger_irq)
  444. +           trigger_irq = true;
  445. +
  446. +       mutex_unlock(&ab8500->latch_lock);
  447. +
  448.         ab8500->oldmask[i] = new;
  449.  
  450.         reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i];
  451.         set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new);
  452.     }
  453. +
  454. +   if (unlikely(trigger_irq)) {
  455. +       ret_val = irq_trigger_set_gic_spi_pending_interrupt(
  456. +           IRQ_DB8500_AB8500);
  457. +
  458. +       if (ret_val)
  459. +           dev_err(ab8500->dev, "cannot re-trigger %d interrupt!\n",
  460. +               IRQ_DB8500_AB8500);
  461. +   }
  462. +
  463.     atomic_dec(&ab8500->transfer_ongoing);
  464.     mutex_unlock(&ab8500->irq_lock);
  465.  }
  466. @@ -436,9 +466,25 @@
  467.         if (regoffset == 11 && is_ab8500_1p1_or_earlier(ab8500))
  468.             continue;
  469.  
  470. +       mutex_lock(&ab8500->latch_lock);
  471. +
  472.         status = get_register_interruptible(ab8500, AB8500_INTERRUPT,
  473.             AB8500_IT_LATCH1_REG + regoffset, &value);
  474. -       if (status < 0 || value == 0)
  475. +
  476. +       if (status < 0) {
  477. +           mutex_unlock(&ab8500->latch_lock);
  478. +           continue;
  479. +       }
  480. +
  481. +       /*
  482. +        * OR with cached latch register value
  483. +        */
  484. +       value |= ab8500->latch[i];
  485. +       ab8500->latch[i] = 0;
  486. +
  487. +       mutex_unlock(&ab8500->latch_lock);
  488. +
  489. +       if (value == 0)
  490.             continue;
  491.  
  492.         do {
  493. @@ -1172,6 +1218,7 @@
  494.         ab8500->irq_base = plat->irq_base;
  495.  
  496.     mutex_init(&ab8500->lock);
  497. +   mutex_init(&ab8500->latch_lock);
  498.     mutex_init(&ab8500->irq_lock);
  499.     atomic_set(&ab8500->transfer_ongoing, 0);
  500.  
  501. @@ -1214,6 +1261,12 @@
  502.         ret = -ENOMEM;
  503.         goto out_freemask;
  504.     }
  505. +   ab8500->latch = kzalloc(ab8500->mask_size, GFP_KERNEL);
  506. +   if (!ab8500->latch) {
  507. +       ret = -ENOMEM;
  508. +       goto out_freeoldmask;
  509. +   }
  510. +
  511.     /*
  512.      * ab8500 has switched off due to (SWITCH_OFF_STATUS):
  513.      * 0x01 Swoff bit programming
  514. @@ -1267,7 +1320,7 @@
  515.  
  516.     ret = abx500_register_ops(ab8500->dev, &ab8500_ops);
  517.     if (ret)
  518. -       goto out_freeoldmask;
  519. +       goto out_freelatch;
  520.  
  521.     for (i = 0; i < ab8500->mask_size; i++)
  522.         ab8500->mask[i] = ab8500->oldmask[i] = 0xff;
  523. @@ -1275,7 +1328,7 @@
  524.     if (ab8500->irq_base) {
  525.         ret = ab8500_irq_init(ab8500);
  526.         if (ret)
  527. -           goto out_freeoldmask;
  528. +           goto out_freelatch;
  529.  
  530.         /*  Activate this feature only in ab9540 */
  531.         /*  till tests are done on ab8500 1p2 or later*/
  532. @@ -1343,6 +1396,8 @@
  533.  out_removeirq:
  534.     if (ab8500->irq_base)
  535.         ab8500_irq_remove(ab8500);
  536. +out_freelatch:
  537. +   kfree(ab8500->latch);
  538.  out_freeoldmask:
  539.     kfree(ab8500->oldmask);
  540.  out_freemask:
  541. @@ -1364,6 +1419,7 @@
  542.     }
  543.     kfree(ab8500->oldmask);
  544.     kfree(ab8500->mask);
  545. +   kfree(ab8500->latch);
  546.  
  547.     return 0;
  548.  }
  549. diff -ruN a/drivers/misc/clonedev/clonedev.c b/drivers/misc/clonedev/clonedev.c
  550. --- a/drivers/misc/clonedev/clonedev.c  2012-10-27 17:12:22.971216991 +0900
  551. +++ b/drivers/misc/clonedev/clonedev.c  2012-10-24 23:38:12.000000000 +0900
  552. @@ -48,6 +48,7 @@
  553.     struct compdev *src_compdev;
  554.     struct compdev *dst_compdev;
  555.     bool overlay_case;
  556. +   struct compdev_size src_size;
  557.     struct compdev_size dst_size;
  558.     struct compdev_rect crop_rect;
  559.     struct compdev_scene_info s_info;
  560. @@ -140,8 +141,7 @@
  561.     return req_id;
  562.  }
  563.  
  564. -static void clonedev_best_fit(struct compdev_rect *src_rect,
  565. -       struct compdev_rect *crop_rect,
  566. +static void clonedev_best_fit(struct compdev_rect *crop_rect,
  567.         struct compdev_rect *dst_rect,
  568.         enum   compdev_transform  transform)
  569.  {
  570. @@ -201,6 +201,45 @@
  571.         dst_rect->y += (crop_rect->height - dst_h) >> 1;
  572.  }
  573.  
  574. +static void clonedev_rescale_destrect(struct compdev_rect *boundary,
  575. +       struct compdev_size *src_size,
  576. +       struct compdev_rect *dst_rect,
  577. +       enum compdev_transform transform)
  578. +{
  579. +   uint32_t q, r, src_width;
  580. +   uint32_t x, y, height, width;
  581. +
  582. +   if (transform == COMPDEV_TRANSFORM_ROT_0) {
  583. +       x = dst_rect->x;
  584. +       y = dst_rect->y;
  585. +       width = dst_rect->width;
  586. +       height = dst_rect->height;
  587. +       src_width = src_size->width;
  588. +   } else if (transform == COMPDEV_TRANSFORM_ROT_90_CW) {
  589. +       x = src_size->height - dst_rect->y - dst_rect->height;
  590. +       y = dst_rect->x;
  591. +       width = dst_rect->height;
  592. +       height = dst_rect->width;
  593. +       src_width = src_size->height;
  594. +   } else if (transform == COMPDEV_TRANSFORM_ROT_90_CCW) {
  595. +       x = dst_rect->y;
  596. +       y = src_size->width - dst_rect->x - dst_rect->width;
  597. +       width = dst_rect->height;
  598. +       height = dst_rect->width;
  599. +       src_width = src_size->height;
  600. +   }
  601. +
  602. +   q = (boundary->width << 6) / src_width;
  603. +   r = (boundary->width << 6) % src_width;
  604. +
  605. +   dst_rect->x      = (((boundary->x << 6) + ((q * x + r * x / src_width) +
  606. +               (0x1 << 5))) >> 6) & ~0x1;
  607. +   dst_rect->y      = ((q * y + r * y / src_width) >> 6) + boundary->y;
  608. +   dst_rect->width  = (((q * width + r * width / src_width) +
  609. +               (0x1 << 5)) >> 6) & ~0x1;
  610. +   dst_rect->height = (q * height + r * height / src_width) >> 6;
  611. +}
  612. +
  613.  static int clonedev_set_mode_locked(struct clonedev *cd,
  614.         enum clonedev_mode mode)
  615.  {
  616. @@ -247,9 +286,18 @@
  617.  static void set_transform_and_dest_rect(struct clonedev *cd,
  618.         struct compdev_img *img)
  619.  {
  620. -   /* Adjust destination rect */
  621. -   clonedev_best_fit(&img->src_rect,
  622. -           &cd->crop_rect,
  623. +   struct compdev_rect temp_rect = {0};
  624. +   temp_rect.width = cd->src_size.width;
  625. +   temp_rect.height = cd->src_size.height;
  626. +
  627. +   /* First adjust src rect to crop_rect */
  628. +   clonedev_best_fit(&cd->crop_rect,
  629. +           &temp_rect,
  630. +           img->transform);
  631. +
  632. +   /* Now use temp_rect as the boundary */
  633. +   clonedev_rescale_destrect(&temp_rect,
  634. +           &cd->src_size,
  635.             &img->dst_rect,
  636.             img->transform);
  637.  
  638. @@ -290,12 +338,83 @@
  639.     case COMPDEV_FMT_YVU420_SP:
  640.     case COMPDEV_FMT_YUV420_P:
  641.     case COMPDEV_FMT_YVU420_P:
  642. +   case COMPDEV_FMT_YV12:
  643.         return COMPDEV_FMT_RGB888;
  644.     default:
  645.         return COMPDEV_FMT_RGBA8888;
  646.     }
  647.  }
  648.  
  649. +static u32 get_b2r2_color_black(enum b2r2_blt_fmt fmt)
  650. +{
  651. +   switch (fmt) {
  652. +   case B2R2_BLT_FMT_CB_Y_CR_Y:
  653. +       return 0x80108010;
  654. +   case B2R2_BLT_FMT_32_BIT_ARGB8888:
  655. +       return 0xFF000000;
  656. +   case B2R2_BLT_FMT_24_BIT_RGB888:
  657. +   case B2R2_BLT_FMT_16_BIT_RGB565:
  658. +   default:
  659. +       return 0;
  660. +   }
  661. +}
  662. +
  663. +
  664. +static inline void clear_rect(struct clonedev *cd,
  665. +       struct b2r2_blt_req *bltreq, int x, int y,
  666. +       int width, int height)
  667. +{
  668. +   int req_id;
  669. +
  670. +   bltreq->dst_rect.x = x;
  671. +   bltreq->dst_rect.y = y;
  672. +   bltreq->dst_rect.width = width;
  673. +   bltreq->dst_rect.height = height;
  674. +   if (width != 0 && height != 0) {
  675. +       req_id = b2r2_blt_request(cd->blt_handle, bltreq);
  676. +       if (req_id < 0)
  677. +           dev_err(cd->dev, "%s: Err b2r2_blt_request, id %d",
  678. +                   __func__, req_id);
  679. +   }
  680. +}
  681. +
  682. +static void clonedev_clear_background(struct clonedev *cd,
  683. +           struct compdev_img *dst_img,
  684. +           struct compdev_rect *img_rect)
  685. +{
  686. +   /* Clear the dst_img outside of the rect specified by img_rect */
  687. +   struct b2r2_blt_req *bltreq;
  688. +
  689. +   bltreq = kzalloc(sizeof(*bltreq), GFP_KERNEL);
  690. +   if (bltreq == NULL)
  691. +       return;
  692. +
  693. +   bltreq->size = sizeof(struct b2r2_blt_req);
  694. +   bltreq->flags = B2R2_BLT_FLAG_ASYNCH | B2R2_BLT_FLAG_SOURCE_FILL_RAW;
  695. +   bltreq->transform = B2R2_BLT_TRANSFORM_NONE;
  696. +   bltreq->dst_img.buf.type = B2R2_BLT_PTR_HWMEM_BUF_NAME_OFFSET;
  697. +   bltreq->dst_img.buf.hwmem_buf_name = dst_img->buf.hwmem_buf_name;
  698. +   bltreq->dst_img.width = dst_img->width;
  699. +   bltreq->dst_img.height = dst_img->height;
  700. +   bltreq->dst_img.fmt = compdev_to_blt_format(dst_img->fmt);
  701. +   bltreq->dst_img.pitch = dst_img->pitch;
  702. +   bltreq->src_color = get_b2r2_color_black(bltreq->dst_img.fmt);
  703. +
  704. +   clear_rect(cd, bltreq,
  705. +           0, 0, img_rect->x, dst_img->height);
  706. +   clear_rect(cd, bltreq,  img_rect->x, 0,
  707. +           img_rect->width, img_rect->y);
  708. +   clear_rect(cd, bltreq,  img_rect->x + img_rect->width,
  709. +           0, dst_img->width - img_rect->width - img_rect->x,
  710. +           dst_img->height);
  711. +   clear_rect(cd, bltreq,  img_rect->x,
  712. +           img_rect->y + img_rect->height, img_rect->width,
  713. +           dst_img->height - img_rect->y - img_rect->height);
  714. +
  715. +   kfree(bltreq);
  716. +}
  717. +
  718. +
  719.  static void clonedev_compose_locked(struct clonedev *cd)
  720.  {
  721.     struct compdev_img *img0;
  722. @@ -367,18 +486,31 @@
  723.         dst_img->img.flags |= img0->flags;
  724.         dst_img->img.transform = COMPDEV_TRANSFORM_ROT_0;
  725.  
  726. +
  727. +       /* Clear destination buf outside of img0 */
  728. +       clonedev_clear_background(cd, &dst_img->img,
  729. +           &img0->dst_rect);
  730. +
  731.         /* Handle the blit jobs */
  732.         if (img1 == NULL) {
  733.             b2r2_req_id = clonedev_blt(cd, img0, &dst_img->img,
  734.                         false, false);
  735.         } else {
  736. -           clonedev_blt(cd, img0, &dst_img->img, false, false);
  737. -           b2r2_req_id = clonedev_blt(cd, img1, &dst_img->img,
  738. +           int ret;
  739. +           b2r2_req_id = clonedev_blt(cd, img0, &dst_img->img,
  740. +                       false, false);
  741. +           ret = clonedev_blt(cd, img1, &dst_img->img,
  742.                         true, false);
  743. +           if (ret >= 0)
  744. +               b2r2_req_id = ret;
  745.         }
  746.  
  747. -       dst_img->img.dst_rect.x += cd->crop_rect.x;
  748. -       dst_img->img.dst_rect.y += cd->crop_rect.y;
  749. +       dst_img->img.dst_rect = cd->crop_rect;
  750. +       dst_img->img.src_rect.x = 0;
  751. +       dst_img->img.src_rect.y = 0;
  752. +       dst_img->img.src_rect.width = cd->crop_rect.width;
  753. +       dst_img->img.src_rect.height = cd->crop_rect.height;
  754. +
  755.         compdev_post_single_buffer_asynch(cd->dst_compdev,
  756.                 &dst_img->img, cd->blt_handle, b2r2_req_id);
  757.  
  758. @@ -638,6 +770,10 @@
  759.     if (ret < 0)
  760.         goto fail_register_misc;
  761.  
  762. +   ret = compdev_get_size(cd->src_compdev, &cd->src_size);
  763. +   if (ret < 0)
  764. +       goto fail_register_misc;
  765. +
  766.     ret = compdev_get_size(cd->dst_compdev, &cd->dst_size);
  767.     if (ret < 0)
  768.         goto fail_register_misc;
  769. diff -ruN a/drivers/misc/compdev/compdev.c b/drivers/misc/compdev/compdev.c
  770. --- a/drivers/misc/compdev/compdev.c    2012-10-27 17:12:22.959216745 +0900
  771. +++ b/drivers/misc/compdev/compdev.c    2012-10-24 23:38:12.000000000 +0900
  772. @@ -1,5 +1,6 @@
  773.  /*
  774.   * Copyright (C) ST-Ericsson SA 2011
  775. + * Copyright (C) 2012 Sony Mobile Communications AB.
  776.   *
  777.   * Display overlay compositer device driver
  778.   *
  779. @@ -10,6 +11,9 @@
  780.   * for ST-Ericsson.
  781.   *
  782.   * License terms: GNU General Public License (GPL), version 2.
  783. + *
  784. + * NOTE: This file has been modified by Sony Mobile Communications AB.
  785. + * Modifications are licensed under the License.
  786.   */
  787.  
  788.  #include <linux/kernel.h>
  789. @@ -321,7 +325,7 @@
  790.         }
  791.  
  792.         rgn.size = rgn.end = buffer->size;
  793. -       ret = hwmem_set_domain(buffer->alloc, HWMEM_ACCESS_READ,
  794. +       ret = hwmem_set_domain(buffer->alloc, access,
  795.             HWMEM_DOMAIN_SYNC, &rgn);
  796.         if (ret)
  797.             dev_warn(dss_ctx->dev,
  798. @@ -556,6 +560,7 @@
  799.         if ((fb_img->flags & COMPDEV_PROTECTED_FLAG) &&
  800.             (mcde_dss_secure_output(dss_ctx->ddev) == false)) {
  801.             disable_overlay(dss_ctx->ovly[i]);
  802. +           update_ovly[i] = true;
  803.         } else {
  804.             ret = compdev_setup_ovly(fb_img,
  805.                     &dss_ctx->ovly_buffer[i],
  806. @@ -577,6 +582,7 @@
  807.         if ((ovly_img->flags & COMPDEV_PROTECTED_FLAG) &&
  808.             (mcde_dss_secure_output(dss_ctx->ddev) == false)) {
  809.             disable_overlay(dss_ctx->ovly[i]);
  810. +           update_ovly[i] = true;
  811.         } else {
  812.             ret = compdev_setup_ovly(ovly_img,
  813.                     &dss_ctx->ovly_buffer[i],
  814. diff -ruN a/drivers/misc/compdev/compdev_util.c b/drivers/misc/compdev/compdev_util.c
  815. --- a/drivers/misc/compdev/compdev_util.c   2012-10-27 17:12:22.963216827 +0900
  816. +++ b/drivers/misc/compdev/compdev_util.c   2012-10-24 23:38:12.000000000 +0900
  817. @@ -50,6 +50,8 @@
  818.         return B2R2_BLT_FMT_YUV420_PACKED_PLANAR;
  819.     case COMPDEV_FMT_YVU420_P:
  820.         return B2R2_BLT_FMT_YVU420_PACKED_PLANAR;
  821. +   case COMPDEV_FMT_YV12:
  822. +       return B2R2_BLT_FMT_YV12;
  823.     default:
  824.         return B2R2_BLT_FMT_UNUSED;
  825.     }
  826. @@ -104,6 +106,7 @@
  827.     case COMPDEV_FMT_YVU420_SP:
  828.     case COMPDEV_FMT_YUV420_P:
  829.     case COMPDEV_FMT_YVU420_P:
  830. +   case COMPDEV_FMT_YV12:
  831.         stride = width;
  832.         break;
  833.     }
  834. @@ -136,12 +139,59 @@
  835.     case COMPDEV_FMT_YVU420_SP:
  836.     case COMPDEV_FMT_YUV420_P:
  837.     case COMPDEV_FMT_YVU420_P:
  838. +   case COMPDEV_FMT_YV12:
  839.         bpp = 12;
  840.         break;
  841.     }
  842.     return bpp;
  843.  }
  844.  
  845. +static int get_chroma_pitch(u32 luma_pitch, enum compdev_fmt fmt)
  846. +{
  847. +   int chroma_pitch;
  848. +
  849. +   switch (fmt) {
  850. +   case COMPDEV_FMT_YV12:
  851. +       chroma_pitch = ALIGN((luma_pitch >> 1), 16);
  852. +   case COMPDEV_FMT_YUV420_SP:
  853. +   case COMPDEV_FMT_YVU420_SP:
  854. +       chroma_pitch = luma_pitch;
  855. +   case COMPDEV_FMT_YCBCR42XMBN:
  856. +   case COMPDEV_FMT_YUV420_P:
  857. +   case COMPDEV_FMT_YVU420_P:
  858. +       chroma_pitch = luma_pitch >> 1;
  859. +   default:
  860. +       chroma_pitch = 0;
  861. +   }
  862. +
  863. +   return chroma_pitch;
  864. +}
  865. +
  866. +static int get_chroma_size(u32 luma_pitch, u32 luma_height,
  867. +       enum compdev_fmt fmt)
  868. +{
  869. +   int chroma_pitch = get_chroma_pitch(luma_pitch, fmt);
  870. +
  871. +   if (chroma_pitch <= 0)
  872. +       return 0;
  873. +
  874. +   switch (fmt) {
  875. +   case COMPDEV_FMT_YUV420_P:
  876. +   case COMPDEV_FMT_YVU420_P:
  877. +   case COMPDEV_FMT_YV12:
  878. +       return chroma_pitch *
  879. +           ((luma_height + 1) >> 1) << 1;
  880. +   case COMPDEV_FMT_YUV420_SP:
  881. +   case COMPDEV_FMT_YVU420_SP:
  882. +       return chroma_pitch *
  883. +           ((luma_height + 1) >> 1);
  884. +   case COMPDEV_FMT_YCBCR42XMBN:
  885. +       return chroma_pitch * (ALIGN(luma_height, 16) >> 1);
  886. +   default:
  887. +       return 0;
  888. +   }
  889. +}
  890. +
  891.  static int alloc_comp_internal_img(enum compdev_fmt fmt,
  892.         u16 width, u16 height, bool protected,
  893.         struct compdev_img_internal **img_pp)
  894. @@ -155,6 +205,7 @@
  895.  
  896.     stride = compdev_get_stride(width, fmt);
  897.     size = stride * height;
  898. +   size += get_chroma_size(stride, height, fmt);
  899.     size = PAGE_ALIGN(size);
  900.  
  901.     if (protected)
  902. @@ -455,6 +506,7 @@
  903.         case COMPDEV_FMT_YVU420_SP:
  904.         case COMPDEV_FMT_YUV420_P:
  905.         case COMPDEV_FMT_YVU420_P:
  906. +       case COMPDEV_FMT_YV12:
  907.             return COMPDEV_FMT_YUV422;
  908.         default:
  909.             return COMPDEV_FMT_RGBA8888;
  910. @@ -472,6 +524,7 @@
  911.         case COMPDEV_FMT_YVU420_SP:
  912.         case COMPDEV_FMT_YUV420_P:
  913.         case COMPDEV_FMT_YVU420_P:
  914. +       case COMPDEV_FMT_YV12:
  915.             return COMPDEV_FMT_RGB888;
  916.         default:
  917.             return COMPDEV_FMT_RGBA8888;
  918. diff -ruN a/drivers/misc/hwmem/Makefile b/drivers/misc/hwmem/Makefile
  919. --- a/drivers/misc/hwmem/Makefile   2012-10-27 17:12:22.923216008 +0900
  920. +++ b/drivers/misc/hwmem/Makefile   2012-10-24 23:38:12.000000000 +0900
  921. @@ -1,3 +1,3 @@
  922. -hwmem-objs := hwmem-main.o hwmem-ioctl.o cache_handler.o contig_alloc.o
  923. +hwmem-objs := hwmem-main.o hwmem-ioctl.o cache_handler.o contig_alloc.o scatt_alloc.o
  924.  
  925.  obj-$(CONFIG_HWMEM) += hwmem.o
  926. diff -ruN a/drivers/misc/hwmem/cache_handler.c b/drivers/misc/hwmem/cache_handler.c
  927. --- a/drivers/misc/hwmem/cache_handler.c    2012-10-27 17:12:22.923216008 +0900
  928. +++ b/drivers/misc/hwmem/cache_handler.c    2012-10-24 23:38:12.000000000 +0900
  929. @@ -68,13 +68,15 @@
  930.  /*
  931.   * Exported functions
  932.   */
  933. -
  934. -void cach_init_buf(struct cach_buf *buf, enum hwmem_alloc_flags cache_settings,
  935. -                               u32 size)
  936. +void cach_init_buf(struct cach_buf *buf,
  937. +          enum hwmem_mem_type mem_type,
  938. +          enum hwmem_alloc_flags cache_settings,
  939. +          u32 size)
  940.  {
  941.     buf->vstart = NULL;
  942.     buf->pstart = 0;
  943.     buf->size = size;
  944. +   buf->mem_type = mem_type;
  945.  
  946.     buf->cache_settings = cachi_get_cache_settings(cache_settings);
  947.  }
  948. @@ -339,6 +341,9 @@
  949.         else
  950.             shrink_range(&buf->range_dirty_in_cpu_cache,
  951.                                 &intersection);
  952. +
  953. +       if (buf->mem_type == HWMEM_MEM_SCATTERED_SYS)
  954. +           outer_flush_all();
  955.     }
  956.  }
  957.  
  958. diff -ruN a/drivers/misc/hwmem/cache_handler.h b/drivers/misc/hwmem/cache_handler.h
  959. --- a/drivers/misc/hwmem/cache_handler.h    2012-10-27 17:12:22.923216008 +0900
  960. +++ b/drivers/misc/hwmem/cache_handler.h    2012-10-24 23:38:12.000000000 +0900
  961. @@ -42,13 +42,14 @@
  962.     /* Remaining hints are active */
  963.     enum hwmem_alloc_flags cache_settings;
  964.  
  965. +   enum hwmem_mem_type mem_type;
  966.     bool in_cpu_write_buf;
  967.     struct cach_range range_in_cpu_cache;
  968.     struct cach_range range_dirty_in_cpu_cache;
  969.     struct cach_range range_invalid_in_cpu_cache;
  970.  };
  971.  
  972. -void cach_init_buf(struct cach_buf *buf,
  973. +void cach_init_buf(struct cach_buf *buf, enum hwmem_mem_type,
  974.             enum hwmem_alloc_flags cache_settings, u32 size);
  975.  
  976.  void cach_set_buf_addrs(struct cach_buf *buf, void* vaddr, u32 paddr);
  977. diff -ruN a/drivers/misc/hwmem/contig_alloc.c b/drivers/misc/hwmem/contig_alloc.c
  978. --- a/drivers/misc/hwmem/contig_alloc.c 2012-10-27 17:12:22.919215926 +0900
  979. +++ b/drivers/misc/hwmem/contig_alloc.c 2012-10-24 23:38:12.000000000 +0900
  980. @@ -79,7 +79,10 @@
  981.  {
  982.     int ret;
  983.     struct instance *instance;
  984. -   struct vm_struct *vm_area;
  985. +   struct vm_struct *vm_area = NULL;
  986. +#ifdef CONFIG_FLATMEM
  987. +   phys_addr_t region_end = region_paddr + region_size;
  988. +#endif
  989.  
  990.     if (region_size == 0)
  991.         return ERR_PTR(-EINVAL);
  992. @@ -94,14 +97,36 @@
  993.     instance->region_paddr = region_paddr;
  994.     instance->region_size = region_size;
  995.  
  996. -   vm_area = get_vm_area(region_size, VM_IOREMAP);
  997. -   if (vm_area == NULL) {
  998. -       printk(KERN_WARNING "CONA: Failed to allocate %u bytes"
  999. -                   " kernel virtual memory", region_size);
  1000. -       ret = -ENOMSG;
  1001. -       goto vmem_alloc_failed;
  1002. +#ifdef CONFIG_FLATMEM
  1003. +   /*
  1004. +    * Map hwmem physical memory to the holes in the kernel LOMEM virtual
  1005. +    * address if LOMEM region is enough to contain the whole HWMEM.
  1006. +    * otherwise map hwmem to VMALLOC region.
  1007. +    */
  1008. +   if (__phys_to_virt(region_end) > __phys_to_virt(region_paddr)
  1009. +       && __phys_to_virt(region_end) < (unsigned long)high_memory) {
  1010. +       instance->region_kaddr = phys_to_virt(region_paddr);
  1011. +       pr_info("hwmem: %s map to LOMEM, start: 0x%p, end: 0x%p\n",
  1012. +           name,
  1013. +           phys_to_virt(region_paddr),
  1014. +           phys_to_virt(region_paddr+region_size));
  1015. +   }
  1016. +#endif
  1017. +
  1018. +   if (!instance->region_kaddr) {
  1019. +       vm_area = get_vm_area(region_size, VM_IOREMAP);
  1020. +       if (vm_area == NULL) {
  1021. +           pr_err("CONA: Failed to allocate %u bytes kernel virtual memory",
  1022. +                  region_size);
  1023. +           ret = -ENOMSG;
  1024. +           goto vmem_alloc_failed;
  1025. +       }
  1026. +
  1027. +       instance->region_kaddr = vm_area->addr;
  1028. +       pr_info("hwmem: %s map to VMALLOC, address: 0x%p\n",
  1029. +           name,
  1030. +           instance->region_kaddr);
  1031.     }
  1032. -   instance->region_kaddr = vm_area->addr;
  1033.  
  1034.     /*
  1035.      * This newly created memory area is unsused.
  1036. @@ -121,10 +146,11 @@
  1037.     return instance;
  1038.  
  1039.  init_alloc_list_failed:
  1040. -   vm_area = remove_vm_area(instance->region_kaddr);
  1041. -   if (vm_area == NULL)
  1042. -       printk(KERN_ERR "CONA: Failed to free kernel virtual memory,"
  1043. -                           " resource leak!\n");
  1044. +   if (vm_area) {
  1045. +       vm_area = remove_vm_area(instance->region_kaddr);
  1046. +       if (vm_area == NULL)
  1047. +           pr_err("CONA: Failed to free kernel virtual memory, resource leak!\n");
  1048. +   }
  1049.  
  1050.     kfree(vm_area);
  1051.  vmem_alloc_failed:
  1052. diff -ruN a/drivers/misc/hwmem/hwmem-main.c b/drivers/misc/hwmem/hwmem-main.c
  1053. --- a/drivers/misc/hwmem/hwmem-main.c   2012-10-27 17:12:22.919215926 +0900
  1054. +++ b/drivers/misc/hwmem/hwmem-main.c   2012-10-24 23:38:12.000000000 +0900
  1055. @@ -61,6 +61,10 @@
  1056.     /* Cache handling */
  1057.     struct cach_buf cach_buf;
  1058.  
  1059. +   /* Scattered allocation parameters */
  1060. +   struct page **sglist;
  1061. +   size_t nr_of_pages;
  1062. +
  1063.  #ifdef CONFIG_DEBUG_FS
  1064.     /* Debug */
  1065.     void *creator;
  1066. @@ -165,24 +169,37 @@
  1067.     int ret;
  1068.     pgprot_t pgprot;
  1069.     void *alloc_kaddr;
  1070. +   void *vmap_addr;
  1071.  
  1072. -   alloc_kaddr = alloc->mem_type->allocator_api.get_alloc_kaddr(
  1073. -       alloc->mem_type->allocator_instance, alloc->allocator_hndl);
  1074. -   if (IS_ERR(alloc_kaddr))
  1075. -       return PTR_ERR(alloc_kaddr);
  1076. +   if (alloc->mem_type->id != HWMEM_MEM_SCATTERED_SYS) {
  1077. +       alloc_kaddr = alloc->mem_type->allocator_api.get_alloc_kaddr(
  1078. +           alloc->mem_type->allocator_instance, alloc->allocator_hndl);
  1079. +       if (IS_ERR(alloc_kaddr))
  1080. +           return PTR_ERR(alloc_kaddr);
  1081. +   }
  1082.  
  1083.     pgprot = PAGE_KERNEL;
  1084.     cach_set_pgprot_cache_options(&alloc->cach_buf, &pgprot);
  1085.  
  1086. -   ret = ioremap_page_range((unsigned long)alloc_kaddr,
  1087. -       (unsigned long)alloc_kaddr + alloc->size, alloc->paddr, pgprot);
  1088. -   if (ret < 0) {
  1089. -       dev_warn(&hwdev->dev, "Failed to map %#x - %#x", alloc->paddr,
  1090. -                       alloc->paddr + alloc->size);
  1091. -       return ret;
  1092. -   }
  1093. +   if (alloc->mem_type->id == HWMEM_MEM_SCATTERED_SYS) {
  1094. +       /* map an array of pages into virtually contiguous space */
  1095. +       vmap_addr = vmap(alloc->sglist, alloc->nr_of_pages, VM_MAP, PAGE_KERNEL);
  1096. +       if (IS_ERR_OR_NULL(vmap_addr)) {
  1097. +           dev_warn(&hwdev->dev, "Failed to vmap size %d", alloc->size);
  1098. +           return -ENOMEM;
  1099. +       }
  1100. +       alloc->kaddr = vmap_addr;
  1101. +   } else { /* contiguous or protected */
  1102. +       ret = ioremap_page_range((unsigned long)alloc_kaddr,
  1103. +           (unsigned long)alloc_kaddr + alloc->size, alloc->paddr, pgprot);
  1104. +       if (ret < 0) {
  1105. +           dev_warn(&hwdev->dev, "Failed to map %#x - %#x", alloc->paddr,
  1106. +                           alloc->paddr + alloc->size);
  1107. +           return ret;
  1108. +       }
  1109.  
  1110. -   alloc->kaddr = alloc_kaddr;
  1111. +       alloc->kaddr = alloc_kaddr;
  1112. +   }
  1113.  
  1114.     return 0;
  1115.  }
  1116. @@ -192,7 +209,10 @@
  1117.     if (alloc->kaddr == NULL)
  1118.         return;
  1119.  
  1120. -   unmap_kernel_range((unsigned long)alloc->kaddr, alloc->size);
  1121. +   if (alloc->mem_type->id == HWMEM_MEM_SCATTERED_SYS)
  1122. +       vunmap(alloc->kaddr); /* release virtual mapping obtained by vmap() */
  1123. +   else /* contiguous or protected */
  1124. +       unmap_kernel_range((unsigned long)alloc->kaddr, alloc->size);
  1125.  
  1126.     alloc->kaddr = NULL;
  1127.  }
  1128. @@ -245,6 +265,7 @@
  1129.     alloc->creator_tgid = task_tgid_nr(current);
  1130.  #endif
  1131.     alloc->mem_type = resolve_mem_type(mem_type);
  1132. +
  1133.     if (IS_ERR(alloc->mem_type)) {
  1134.         ret = PTR_ERR(alloc->mem_type);
  1135.         goto resolve_mem_type_failed;
  1136. @@ -257,15 +278,29 @@
  1137.         goto allocator_failed;
  1138.     }
  1139.  
  1140. -   alloc->paddr = alloc->mem_type->allocator_api.get_alloc_paddr(
  1141. -                           alloc->allocator_hndl);
  1142. -   alloc->size = alloc->mem_type->allocator_api.get_alloc_size(
  1143. -                           alloc->allocator_hndl);
  1144. +   if (alloc->mem_type->id == HWMEM_MEM_SCATTERED_SYS) {
  1145. +       alloc->size = alloc->mem_type->allocator_api.get_alloc_size(
  1146. +                               alloc->allocator_hndl);
  1147. +       alloc->nr_of_pages = alloc->size >> PAGE_SHIFT;
  1148. +       alloc->sglist = alloc->mem_type->allocator_api.get_alloc_sglist(
  1149. +                               alloc->allocator_hndl);
  1150. +       alloc->paddr = 0;
  1151. +   } else {  /* contiguous or protected */
  1152. +       alloc->paddr = alloc->mem_type->allocator_api.get_alloc_paddr(
  1153. +                               alloc->allocator_hndl);
  1154. +       alloc->size = alloc->mem_type->allocator_api.get_alloc_size(
  1155. +                               alloc->allocator_hndl);
  1156. +   }
  1157. +
  1158. +   cach_init_buf(&alloc->cach_buf,
  1159. +             alloc->mem_type->id,
  1160. +             alloc->flags,
  1161. +             alloc->size);
  1162.  
  1163. -   cach_init_buf(&alloc->cach_buf, alloc->flags, alloc->size);
  1164.     ret = kmap_alloc(alloc);
  1165.     if (ret < 0)
  1166.         goto kmap_alloc_failed;
  1167. +
  1168.     cach_set_buf_addrs(&alloc->cach_buf, alloc->kaddr, alloc->paddr);
  1169.  
  1170.     list_add_tail(&alloc->list, &alloc_list);
  1171. @@ -315,16 +350,36 @@
  1172.  int hwmem_pin(struct hwmem_alloc *alloc, struct hwmem_mem_chunk *mem_chunks,
  1173.                             u32 *mem_chunks_length)
  1174.  {
  1175. +   /* Calculate hwmem_mem_chunk_length */
  1176. +   if (mem_chunks == NULL) {
  1177. +       if (alloc->mem_type->id == HWMEM_MEM_SCATTERED_SYS)
  1178. +           *mem_chunks_length = alloc->nr_of_pages;
  1179. +       else
  1180. +           *mem_chunks_length = 1;
  1181. +
  1182. +       return 0;
  1183. +   }
  1184. +
  1185.     if (*mem_chunks_length < 1) {
  1186.         *mem_chunks_length = 1;
  1187. +       printk(KERN_ERR "HWMEM: hwmem_pin mem_chunks_length < 1\n");
  1188.         return -ENOSPC;
  1189.     }
  1190.  
  1191.     mutex_lock(&lock);
  1192.  
  1193. -   mem_chunks[0].paddr = alloc->paddr;
  1194. -   mem_chunks[0].size = alloc->size;
  1195. -   *mem_chunks_length = 1;
  1196. +   if (alloc->mem_type->id == HWMEM_MEM_SCATTERED_SYS) {
  1197. +       int i;
  1198. +       for (i = 0; i < alloc->nr_of_pages; i++) {
  1199. +           mem_chunks[i].paddr = page_to_phys(alloc->sglist[i]);
  1200. +           mem_chunks[i].size = PAGE_SIZE;
  1201. +       }
  1202. +       *mem_chunks_length = alloc->nr_of_pages;
  1203. +   } else { /* contiguous or protected */
  1204. +       mem_chunks[0].paddr = alloc->paddr;
  1205. +       mem_chunks[0].size = alloc->size;
  1206. +       *mem_chunks_length = 1;
  1207. +   }
  1208.  
  1209.     mutex_unlock(&lock);
  1210.  
  1211. @@ -349,7 +404,9 @@
  1212.  
  1213.  int hwmem_mmap(struct hwmem_alloc *alloc, struct vm_area_struct *vma)
  1214.  {
  1215. +   unsigned long temp_addr;
  1216.     int ret = 0;
  1217. +   int i = 0;
  1218.     unsigned long vma_size = vma->vm_end - vma->vm_start;
  1219.     enum hwmem_access access;
  1220.     mutex_lock(&lock);
  1221. @@ -380,11 +437,21 @@
  1222.     atomic_inc(&alloc->ref_cnt);
  1223.     vma->vm_ops = &vm_ops;
  1224.  
  1225. -   ret = remap_pfn_range(vma, vma->vm_start, alloc->paddr >> PAGE_SHIFT,
  1226. -       min(vma_size, (unsigned long)alloc->size), vma->vm_page_prot);
  1227. -   if (ret < 0)
  1228. -       goto map_failed;
  1229. -
  1230. +   if (alloc->mem_type->id == HWMEM_MEM_SCATTERED_SYS) {
  1231. +       /* VM_MIXEDMAP can contain "struct page" and pure PFN pages */
  1232. +       vma->vm_flags |= VM_MIXEDMAP;
  1233. +       temp_addr = vma->vm_start;
  1234. +
  1235. +       for (i = 0; i < alloc->nr_of_pages; i++) {
  1236. +           vm_insert_page(vma, temp_addr, alloc->sglist[i]);
  1237. +           temp_addr += PAGE_SIZE;
  1238. +       }
  1239. +   } else { /* contiguous or protected */
  1240. +       ret = remap_pfn_range(vma, vma->vm_start, alloc->paddr >> PAGE_SHIFT,
  1241. +           min(vma_size, (unsigned long)alloc->size), vma->vm_page_prot);
  1242. +       if (ret < 0)
  1243. +           goto map_failed;
  1244. +   }
  1245.     goto out;
  1246.  
  1247.  map_failed:
  1248. diff -ruN a/drivers/misc/hwmem/scatt_alloc.c b/drivers/misc/hwmem/scatt_alloc.c
  1249. --- a/drivers/misc/hwmem/scatt_alloc.c  1970-01-01 09:00:00.000000000 +0900
  1250. +++ b/drivers/misc/hwmem/scatt_alloc.c  2012-10-24 23:38:12.000000000 +0900
  1251. @@ -0,0 +1,120 @@
  1252. +/*
  1253. + * Copyright (C) ST-Ericsson SA 2012
  1254. + *
  1255. + * Scattered memory allocator
  1256. + *
  1257. + * Author: Andreas Karlsson <andreas.z.karlsson@stericsson.com> for ST-Ericsson.
  1258. + *
  1259. + * License terms: GNU General Public License (GPL), version 2.
  1260. + */
  1261. +
  1262. +#include <linux/err.h>
  1263. +#include <linux/slab.h>
  1264. +
  1265. +#define MAX_INSTANCE_NAME_LENGTH 31
  1266. +
  1267. +struct alloc {
  1268. +   size_t size;
  1269. +   struct page **pages;
  1270. +   size_t nr_of_pages;
  1271. +};
  1272. +
  1273. +struct instance {
  1274. +   char name[MAX_INSTANCE_NAME_LENGTH + 1];
  1275. +};
  1276. +
  1277. +static DEFINE_MUTEX(lock);
  1278. +
  1279. +void *scatt_create(const char *name)
  1280. +{
  1281. +   struct instance *instance;
  1282. +
  1283. +   instance = kmalloc(sizeof(*instance), GFP_KERNEL);
  1284. +   if (instance == NULL)
  1285. +       return ERR_PTR(-ENOMEM);
  1286. +
  1287. +   memcpy(instance->name, name, MAX_INSTANCE_NAME_LENGTH + 1);
  1288. +   /* Truncate name if necessary */
  1289. +   instance->name[MAX_INSTANCE_NAME_LENGTH] = '\0';
  1290. +
  1291. +   return instance;
  1292. +}
  1293. +
  1294. +void *scatt_alloc(void *instance, size_t size)
  1295. +{
  1296. +   struct alloc *new_alloc;
  1297. +   unsigned int array_size, i;
  1298. +
  1299. +   new_alloc = kmalloc(sizeof(struct alloc), GFP_KERNEL);
  1300. +   if (new_alloc == NULL)
  1301. +       return ERR_PTR(-ENOMEM);
  1302. +
  1303. +   mutex_lock(&lock);
  1304. +
  1305. +   new_alloc->size = size;
  1306. +   new_alloc->nr_of_pages = new_alloc->size >> PAGE_SHIFT;
  1307. +
  1308. +   array_size = (new_alloc->nr_of_pages * sizeof(struct page *));
  1309. +   new_alloc->pages = kmalloc(array_size, GFP_KERNEL);
  1310. +
  1311. +   if (!new_alloc->pages) {
  1312. +       printk(KERN_ERR "HWMEM: Scattered alloc pages array failed\n");
  1313. +       goto alloc_failed;
  1314. +   }
  1315. +
  1316. +   /* Alloc page and place in the sglist */
  1317. +   for (i = 0; i < new_alloc->nr_of_pages; i++) {
  1318. +       new_alloc->pages[i] = alloc_page(GFP_KERNEL);
  1319. +       if (!new_alloc->pages[i]) {
  1320. +           printk(KERN_ERR "HWMEM: Scattered alloc page failed\n");
  1321. +           goto alloc_failed;
  1322. +       }
  1323. +   }
  1324. +
  1325. +   mutex_unlock(&lock);
  1326. +
  1327. +   return new_alloc;
  1328. +
  1329. +alloc_failed:
  1330. +   kfree(new_alloc);
  1331. +   mutex_unlock(&lock);
  1332. +   return ERR_PTR(-ENOMEM);
  1333. +}
  1334. +
  1335. +void scatt_free(void *instance, void *alloc)
  1336. +{
  1337. +   int i;
  1338. +
  1339. +   struct alloc *alloc_l = (struct alloc *)alloc;
  1340. +
  1341. +   if (alloc == NULL)
  1342. +       return;
  1343. +
  1344. +   mutex_lock(&lock);
  1345. +
  1346. +   /* Free all pages in the sglist */
  1347. +   for (i = 0; i < alloc_l->nr_of_pages; i++)
  1348. +       __free_page(alloc_l->pages[i]);
  1349. +
  1350. +   kfree(alloc_l->pages);
  1351. +   kfree(alloc_l);
  1352. +
  1353. +   mutex_unlock(&lock);
  1354. +}
  1355. +
  1356. +size_t scatt_get_alloc_size(void *alloc)
  1357. +{
  1358. +   if (alloc == NULL)
  1359. +       return -EINVAL;
  1360. +
  1361. +   return ((struct alloc *)alloc)->size;
  1362. +}
  1363. +
  1364. +struct page **scatt_get_alloc_sglist(void *alloc)
  1365. +{
  1366. +   if (alloc == NULL)
  1367. +       return ERR_PTR(-EINVAL);
  1368. +
  1369. +   return ((struct alloc *)alloc)->pages;
  1370. +}
  1371. +
  1372. diff -ruN a/drivers/power/ab8500_chargalg.c b/drivers/power/ab8500_chargalg.c
  1373. --- a/drivers/power/ab8500_chargalg.c   2012-10-27 17:12:08.034941212 +0900
  1374. +++ b/drivers/power/ab8500_chargalg.c   2012-10-24 23:38:19.000000000 +0900
  1375. @@ -8,6 +8,9 @@
  1376.   * Author: Johan Palsson <johan.palsson@stericsson.com>
  1377.   * Author: Karl Komierowski <karl.komierowski@stericsson.com>
  1378.   * Author: Imre Sunyi <imre.sunyi@sonymobile.com>
  1379. + *
  1380. + * NOTE: This file has been modified by Sony Mobile Communication AB.
  1381. + * Modification are licenced under the Licence.
  1382.   */
  1383.  
  1384.  #include <linux/init.h>
  1385. @@ -1964,11 +1967,11 @@
  1386.         ab8500_chargalg_external_power_changed;
  1387.  
  1388.     /* Initilialize safety timer */
  1389. -   hrtimer_init(&di->safety_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
  1390. +   hrtimer_init(&di->safety_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
  1391.     di->safety_timer.function = ab8500_chargalg_safety_timer_expired;
  1392.  
  1393.     /* Initilialize maintenance timer */
  1394. -   hrtimer_init(&di->maintenance_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
  1395. +   hrtimer_init(&di->maintenance_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
  1396.     di->maintenance_timer.function =
  1397.         ab8500_chargalg_maintenance_timer_expired;
  1398.  
  1399. diff -ruN a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
  1400. --- a/drivers/power/ab8500_fg.c 2012-10-27 17:12:08.030941166 +0900
  1401. +++ b/drivers/power/ab8500_fg.c 2012-10-24 23:38:19.000000000 +0900
  1402. @@ -36,7 +36,6 @@
  1403.  #define MILLI_TO_MICRO         1000
  1404.  #define FG_LSB_IN_MA           1627
  1405.  #define QLSB_NANO_AMP_HOURS_X10        1129
  1406. -#define CCEOC_IRQ_SKIP_CNT 1
  1407.  
  1408.  #define SEC_TO_SAMPLE(S)       (S * 4)
  1409.  
  1410. @@ -167,13 +166,13 @@
  1411.   * struct ab8500_fg - ab8500 FG device information
  1412.   * @dev:       Pointer to the structure device
  1413.   * @node:      a list of AB8500 FGs, hence prepared for reentrance
  1414. - * @irq            holds the CCEOC interrupt number
  1415. + * @irq:       holds the CCEOC interrupt number
  1416.   * @cc_irq:        average current irq number
  1417.   * @vbat:      Battery voltage in mV
  1418.   * @vbat_nom:      Nominal battery voltage in mV
  1419. - * @inst_curr:     Instantenous battery current in mA
  1420. + * @inst_curr:     Instantaneous battery current in mA
  1421.   * @avg_curr:      Average battery current in mA
  1422. - * @bat_temp       battery temperature
  1423. + * @bat_temp:      battery temperature
  1424.   * @fg_samples:        Number of samples used in the FG accumulation
  1425.   * @accu_charge:   Accumulated charge from the last conversion
  1426.   * @missed_accu_charge:    Accumulated charge that may be missed between
  1427. @@ -181,9 +180,8 @@
  1428.   * @recovery_cnt_ms:   Counter for recovery mode
  1429.   * @high_curr_cnt_ms:  Counter for high current mode
  1430.   * @init_cnt:      Counter for init mode
  1431. - * @low_bat_cnt        Counter for number of consecutive low battery measures
  1432. - * @nbr_cceoc_irq_cnt  Counter for number of CCEOC irqs to skip
  1433. - * @high_curr_thr_pc   Percent counter of exceeded high current threshold
  1434. + * @low_bat_cnt:   Counter for number of consecutive low battery measures
  1435. + * @high_curr_thr_pc:  Percent counter of exceeded high current threshold
  1436.   * @calculate_missed_accu:
  1437.   *         Indicate if missing accu logic should be activated
  1438.   * @recovery_needed:   Indicate if recovery is needed
  1439. @@ -192,10 +190,10 @@
  1440.   * @prohibit_uncomp_voltage_replace:
  1441.             True when capacity is not allowed to be replaced with
  1442.             uncompensated voltage
  1443. - * @calib_state        State during offset calibration
  1444. + * @calib_state:       State during offset calibration
  1445.   * @discharge_state:   Current discharge state
  1446.   * @charge_state:  Current charge state
  1447. - * @ab8500_fg_complete Completion struct used for the instant current reading
  1448. + * @ab8500_fg_complete:    Completion struct used for the instant current reading
  1449.   * @flags:     Structure for information about events triggered
  1450.   * @bat_cap:       Structure for battery capacity specific parameters
  1451.   * @avg_cap:       Average capacity filter
  1452. @@ -205,11 +203,12 @@
  1453.   * @bat:       Pointer to the ab8500_bm platform data
  1454.   * @fg_psy:        Structure that holds the FG specific battery properties
  1455.   * @fg_wq:     Work queue for running the FG algorithm
  1456. + * @inst_curr_wq: Work queue for running the instantaneous current calculation
  1457.   * @avg_curr_wq:   Work queue for running the avg current calculation
  1458.   * @shutdown_wq:   Work queue for running shutdown determination
  1459.   * @fg_periodic_work:  Work to run the FG algorithm periodically
  1460.   * @fg_low_bat_work:   Work to check low bat condition
  1461. - * @fg_reinit_work Work used to reset and reinitialise the FG algorithm
  1462. + * @fg_reinit_work:    Work used to reset and reinitialise the FG algorithm
  1463.   * @fg_work:       Work to run the FG algorithm instantly
  1464.   * @fg_acc_cur_work:   Work to read the FG accumulator
  1465.   * @fg_check_hw_failure_work:  Work for checking HW state
  1466. @@ -237,7 +236,6 @@
  1467.     int high_curr_cnt_ms;
  1468.     int init_cnt;
  1469.     int low_bat_cnt;
  1470. -   int nbr_cceoc_irq_cnt;
  1471.     int high_curr_thr_pc;
  1472.     bool calculate_missed_accu;
  1473.     bool recovery_needed;
  1474. @@ -258,6 +256,7 @@
  1475.     struct ab8500_bm_data *bat;
  1476.     struct power_supply fg_psy;
  1477.     struct workqueue_struct *fg_wq;
  1478. +   struct workqueue_struct *inst_curr_wq;
  1479.     struct workqueue_struct *avg_curr_wq;
  1480.     struct workqueue_struct *shutdown_wq;
  1481.     struct delayed_work fg_periodic_work;
  1482. @@ -265,6 +264,7 @@
  1483.     struct delayed_work fg_reinit_work;
  1484.     struct work_struct fg_work;
  1485.     struct work_struct fg_acc_cur_work;
  1486. +   struct work_struct fg_cur_now_work;
  1487.     struct delayed_work fg_check_hw_failure_work;
  1488.     struct mutex cc_lock;
  1489.     struct mutex shutdown_lock;
  1490. @@ -567,10 +567,6 @@
  1491.  
  1492.         di->fg_samples = samples;
  1493.  
  1494. -       /*
  1495. -        * how many CCEOC to skip after enabling CC
  1496. -        */
  1497. -       di->nbr_cceoc_irq_cnt = CCEOC_IRQ_SKIP_CNT;
  1498.     } else {
  1499.         if (di->flags.fg_enabled) {
  1500.             di->flags.fg_enabled = false;
  1501. @@ -718,8 +714,9 @@
  1502.     disable_irq(di->irq);
  1503.  
  1504.     if (timeout == 0) {
  1505. -       dev_dbg(di->dev, "%s:%d: waiting for 'CCEOC' irq timeout, "
  1506. -               "use previous value\n", __func__, __LINE__);
  1507. +       dev_dbg(di->dev, "%s:%d: waiting for 'CCEOC' irq timeout(%d ms), "
  1508. +               "use previous value\n", __func__, __LINE__,
  1509. +               INS_CURR_TIMEOUT);
  1510.         val = di->inst_curr;
  1511.         goto leave;
  1512.     }
  1513. @@ -2395,10 +2392,7 @@
  1514.  {
  1515.     struct ab8500_fg *di = _di;
  1516.  
  1517. -   if (di->nbr_cceoc_irq_cnt > 0)
  1518. -       di->nbr_cceoc_irq_cnt--;
  1519. -   else
  1520. -       complete(&di->ab8500_fg_complete);
  1521. +   complete(&di->ab8500_fg_complete);
  1522.  
  1523.     return IRQ_HANDLED;
  1524.  }
  1525. @@ -2484,6 +2478,23 @@
  1526.     return IRQ_HANDLED;
  1527.  }
  1528.  
  1529. + /**
  1530. + * ab8500_fg_current_now_work() - instantaneous battery current reader work
  1531. + * @work:       pointer to the work_struct structure
  1532. + *
  1533. + * Reads the instantaneous battery current.
  1534. + */
  1535. +static void ab8500_fg_current_now_work(struct work_struct *work)
  1536. +{
  1537. +   struct ab8500_fg *di = container_of(work, struct ab8500_fg,
  1538. +       fg_cur_now_work);
  1539. +
  1540. +   dev_dbg(di->dev, "Start reading instantaneous battery current\n");
  1541. +   di->inst_curr = ab8500_fg_inst_curr_blocking(di);
  1542. +   dev_dbg(di->dev, "Finish reading instantaneous battery current: %d\n",
  1543. +       di->inst_curr);
  1544. +}
  1545. +
  1546.  /**
  1547.   * ab8500_fg_get_property() - get the fg properties
  1548.   * @psy:   pointer to the power_supply structure
  1549. @@ -2525,6 +2536,11 @@
  1550.             val->intval = di->vbat * 1000;
  1551.         break;
  1552.     case POWER_SUPPLY_PROP_CURRENT_NOW:
  1553. +       if (!di->flags.calibrate)
  1554. +           queue_work(di->inst_curr_wq, &di->fg_cur_now_work);
  1555. +       else
  1556. +           dev_dbg(di->dev, "CC not calibrated yet,"
  1557. +               "return inst_curr(%dmA)!\n", di->inst_curr);
  1558.         val->intval = di->inst_curr * 1000;
  1559.         break;
  1560.     case POWER_SUPPLY_PROP_CURRENT_AVG:
  1561. @@ -3124,6 +3140,9 @@
  1562.  
  1563.     destroy_workqueue(di->fg_wq);
  1564.     destroy_workqueue(di->shutdown_wq);
  1565. +   destroy_workqueue(di->avg_curr_wq);
  1566. +   destroy_workqueue(di->inst_curr_wq);
  1567. +
  1568.     ab8500_fg_sysfs_exit(di);
  1569.  
  1570.     flush_scheduled_work();
  1571. @@ -3158,6 +3177,13 @@
  1572.     mutex_init(&di->cc_lock);
  1573.     mutex_init(&di->shutdown_lock);
  1574.  
  1575. +   /*
  1576. +    * Initialize completion used to notify completion and start
  1577. +    * of inst current
  1578. +    */
  1579. +   init_completion(&di->ab8500_fg_complete);
  1580. +   init_completion(&di->accu_done);
  1581. +
  1582.     /* get parent data */
  1583.     di->dev = &pdev->dev;
  1584.     di->parent = dev_get_drvdata(pdev->dev.parent);
  1585. @@ -3227,12 +3253,23 @@
  1586.         goto free_shutdown_wq;
  1587.     }
  1588.  
  1589. +   /* work for instantaneous current */
  1590. +   di->inst_curr_wq =
  1591. +       create_singlethread_workqueue("ab8500_fg_inst_curr_wq");
  1592. +   if (di->inst_curr_wq == NULL) {
  1593. +       dev_err(di->dev, "failed to create work queue\n");
  1594. +       goto free_avg_curr_wq;
  1595. +   }
  1596. +
  1597.     /* Init work for running the fg algorithm instantly */
  1598.     INIT_WORK(&di->fg_work, ab8500_fg_instant_work);
  1599.  
  1600.     /* Init work for getting the battery accumulated current */
  1601.     INIT_WORK(&di->fg_acc_cur_work, ab8500_fg_acc_cur_work);
  1602.  
  1603. +   /* Init work for getting the battery instantaneous current */
  1604. +   INIT_WORK(&di->fg_cur_now_work, ab8500_fg_current_now_work);
  1605. +
  1606.     /* Init work for reinitialising the fg algorithm */
  1607.     INIT_DELAYED_WORK_DEFERRABLE(&di->fg_reinit_work,
  1608.         ab8500_fg_reinit_work);
  1609. @@ -3253,27 +3290,13 @@
  1610.     ret = ab8500_fg_init_hw_registers(di);
  1611.     if (ret) {
  1612.         dev_err(di->dev, "failed to initialize registers\n");
  1613. -       goto free_shutdown_wq;
  1614. +       goto free_inst_curr_wq;
  1615.     }
  1616.  
  1617.     /* Consider battery unknown until we're informed otherwise */
  1618.     di->flags.batt_unknown = true;
  1619.     di->flags.batt_id_received = false;
  1620.  
  1621. -   /* Register FG power supply class */
  1622. -   ret = power_supply_register(di->dev, &di->fg_psy);
  1623. -   if (ret) {
  1624. -       dev_err(di->dev, "failed to register FG psy\n");
  1625. -       goto free_shutdown_wq;
  1626. -   }
  1627. -
  1628. -   /*
  1629. -    * Initialize completion used to notify completion and start
  1630. -    * of inst current
  1631. -    */
  1632. -   init_completion(&di->ab8500_fg_complete);
  1633. -   init_completion(&di->accu_done);
  1634. -
  1635.     /* Register interrupts */
  1636.     for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) {
  1637.         irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name);
  1638. @@ -3300,42 +3323,52 @@
  1639.  
  1640.     platform_set_drvdata(pdev, di);
  1641.  
  1642. +   /* Calibrate the fg first time */
  1643. +   di->flags.calibrate = true;
  1644. +   di->calib_state = AB8500_FG_CALIB_INIT;
  1645. +
  1646. +   /* Use room temp as default value until we get an update from driver. */
  1647. +   di->bat_temp = 210;
  1648. +
  1649. +   list_add_tail(&di->node, &ab8500_fg_list);
  1650. +
  1651. +   /* Register FG power supply class */
  1652. +   ret = power_supply_register(di->dev, &di->fg_psy);
  1653. +   if (ret) {
  1654. +       dev_err(di->dev, "failed to register FG psy\n");
  1655. +       goto free_irq;
  1656. +   }
  1657. +
  1658.     ret = ab8500_fg_sysfs_init(di);
  1659.     if (ret) {
  1660.         dev_err(di->dev, "failed to create sysfs entry\n");
  1661. -       goto free_irq;
  1662. +       goto free_power_supply_register;
  1663.     }
  1664.  
  1665.     ret = ab8500_fg_sysfs_psy_create_attrs(di->fg_psy.dev);
  1666.     if (ret) {
  1667.         dev_err(di->dev, "failed to create FG psy\n");
  1668.         ab8500_fg_sysfs_exit(di);
  1669. -       goto free_irq;
  1670. +       goto free_power_supply_register;
  1671.     }
  1672.  
  1673. -   /* Calibrate the fg first time */
  1674. -   di->flags.calibrate = true;
  1675. -   di->calib_state = AB8500_FG_CALIB_INIT;
  1676. -
  1677. -   /* Use room temp as default value until we get an update from driver. */
  1678. -   di->bat_temp = 210;
  1679. -
  1680.     /* Run the FG algorithm */
  1681.     queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0);
  1682.  
  1683. -   list_add_tail(&di->node, &ab8500_fg_list);
  1684. -
  1685.     return ret;
  1686.  
  1687. -free_irq:
  1688. +free_power_supply_register:
  1689.     power_supply_unregister(&di->fg_psy);
  1690. -
  1691. +free_irq:
  1692.     /* We also have to free all successfully registered irqs */
  1693.     for (i = i - 1; i >= 0; i--) {
  1694.         irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name);
  1695.         free_irq(irq, di);
  1696.     }
  1697.  
  1698. +free_inst_curr_wq:
  1699. +   destroy_workqueue(di->inst_curr_wq);
  1700. +free_avg_curr_wq:
  1701.     destroy_workqueue(di->avg_curr_wq);
  1702.  free_shutdown_wq:
  1703.     destroy_workqueue(di->shutdown_wq);
  1704. diff -ruN a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
  1705. --- a/drivers/rtc/rtc-ab8500.c  2012-10-27 17:12:09.854962258 +0900
  1706. +++ b/drivers/rtc/rtc-ab8500.c  2012-10-24 23:38:19.000000000 +0900
  1707. @@ -48,6 +48,7 @@
  1708.  
  1709.  static struct rtc_device *ab8500_rtc;
  1710.  static struct delayed_work sync_work;
  1711. +static u32 resumed;
  1712.  
  1713.  static const u8 ab8500_rtc_time_regs[] = {
  1714.     AB8500_RTC_WATCH_TMIN_HI_REG, AB8500_RTC_WATCH_TMIN_MID_REG,
  1715. @@ -396,13 +397,31 @@
  1716.  {
  1717.     struct rtc_time r;
  1718.     unsigned long t;
  1719. -   struct timespec ts;
  1720. +   struct timespec ts, sys_ts;
  1721. +   struct timex adjust;
  1722.  
  1723.     ab8500_rtc_read_time(ab8500_rtc->dev.parent, &r);
  1724.     rtc_tm_to_time(&r, &t);
  1725.     set_normalized_timespec(&ts, (time_t) t, 0);
  1726. -   do_settimeofday(&ts);
  1727. -   rtc_hctohc(r);
  1728. +   getnstimeofday(&sys_ts);
  1729. +   /*
  1730. +    * AB8500 RTC is more accurate then u8500 system clock.
  1731. +    * Compensate for drift here but not if time differs more then 60s nor
  1732. +    * when the drift is less than a second.
  1733. +    * If diff is more then 60s then system time is considered changed
  1734. +    * but not the rtc time and they should be kept different.
  1735. +    * */
  1736. +   if ((abs(ts.tv_sec - sys_ts.tv_sec) < 60) &&
  1737. +       (ts.tv_sec != sys_ts.tv_sec) && !resumed) {
  1738. +       adjust.offset = (ts.tv_sec - sys_ts.tv_sec) * 1000000;
  1739. +       adjust.modes = ADJ_OFFSET_SINGLESHOT;
  1740. +       do_adjtimex(&adjust);
  1741. +       rtc_hctohc(r);
  1742. +   } else if (resumed) {
  1743. +       do_settimeofday(&ts);
  1744. +       resumed = 0;
  1745. +       rtc_hctohc(r);
  1746. +   }
  1747.     /* Once every minute to match calibration */
  1748.     schedule_delayed_work(&sync_work, 60 * HZ);
  1749.  }
  1750. @@ -495,6 +514,7 @@
  1751.  static int ab8500_rtc_resume(struct platform_device *pdev)
  1752.  {
  1753.     /* Delay by 300ms to let resume finnish */
  1754. +   resumed = 1;
  1755.     schedule_delayed_work(&sync_work, 3 * HZ / 10);
  1756.     return 0;
  1757.  }
  1758. diff -ruN a/drivers/usb/gadget/f_mtp.c b/drivers/usb/gadget/f_mtp.c
  1759. --- a/drivers/usb/gadget/f_mtp.c    2012-10-27 17:12:25.563269691 +0900
  1760. +++ b/drivers/usb/gadget/f_mtp.c    2012-10-24 23:38:23.000000000 +0900
  1761. @@ -4,6 +4,7 @@
  1762.   * Copyright (C) 2010 Google, Inc.
  1763.   * Author: Mike Lockwood <lockwood@android.com>
  1764.   * Copyright (C) 2011 Sony Ericsson Mobile Communications AB.
  1765. + * Copyright (C) 2012 Sony Mobile Communications AB.
  1766.   *
  1767.   * This software is licensed under the terms of the GNU General Public
  1768.   * License version 2, as published by the Free Software Foundation, and
  1769. @@ -350,7 +351,7 @@
  1770.     struct mtp_dev *dev = _mtp_dev;
  1771.  
  1772.     dev->rx_done = 1;
  1773. -   if (req->status != 0)
  1774. +   if (req->status != 0 && dev->state == STATE_BUSY)
  1775.         dev->state = STATE_ERROR;
  1776.  
  1777.     wake_up(&dev->read_wq);
  1778. @@ -489,8 +490,9 @@
  1779.     }
  1780.  
  1781.     /* wait for a request to complete */
  1782. -   ret = wait_event_interruptible(dev->read_wq, dev->rx_done);
  1783. -   if (ret < 0) {
  1784. +   ret = wait_event_interruptible(dev->read_wq,
  1785. +       dev->rx_done || dev->state != STATE_BUSY);
  1786. +   if (ret < 0 || !dev->rx_done) {
  1787.         r = ret;
  1788.         usb_ep_dequeue(dev->ep_out, req);
  1789.         goto done;
  1790. @@ -1124,9 +1126,9 @@
  1791.             spin_lock_irqsave(&dev->lock, flags);
  1792.             /* Flushing the buffers as mentioned in MTP spec */
  1793.             usb_ep_fifo_flush(dev->ep_out);
  1794. +           dev->state = STATE_RESET;
  1795.             wake_up(&dev->read_wq);
  1796.             wake_up(&dev->write_wq);
  1797. -           dev->state = STATE_RESET;
  1798.             spin_unlock_irqrestore(&dev->lock, flags);
  1799.  
  1800.             /* We need to queue a request to read the remaining
  1801. diff -ruN a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
  1802. --- a/drivers/usb/gadget/storage_common.c   2012-10-27 17:12:25.555269529 +0900
  1803. +++ b/drivers/usb/gadget/storage_common.c   2012-10-24 23:38:23.000000000 +0900
  1804. @@ -227,7 +227,7 @@
  1805.  #define ASC(x)     ((u8) ((x) >> 8))
  1806.  #define ASCQ(x)        ((u8) (x))
  1807.  
  1808. -#define RANDOM_WRITE_COUNT_TO_BE_FLUSHED (10)
  1809. +#define RANDOM_WRITE_COUNT_TO_BE_FLUSHED (5)
  1810.  
  1811.  /* VPD(Vital product data) Page Name */
  1812.  #define VPD_SUPPORTED_VPD_PAGES        0x00
  1813. diff -ruN a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
  1814. --- a/drivers/usb/musb/musb_gadget.c    2012-10-27 17:12:25.335265075 +0900
  1815. +++ b/drivers/usb/musb/musb_gadget.c    2012-10-24 23:38:23.000000000 +0900
  1816. @@ -5,6 +5,7 @@
  1817.   * Copyright (C) 2005-2006 by Texas Instruments
  1818.   * Copyright (C) 2006-2007 Nokia Corporation
  1819.   * Copyright (C) 2009 MontaVista Software, Inc. <source@mvista.com>
  1820. + * Copyright (C) 2012 Sony Mobile Communications AB
  1821.   *
  1822.   * This program is free software; you can redistribute it and/or
  1823.   * modify it under the terms of the GNU General Public License
  1824. @@ -1361,7 +1362,7 @@
  1825.     spin_lock_irqsave(&musb->lock, lockflags);
  1826.  
  1827.     /* don't queue if the ep is down */
  1828. -   if (!musb_ep->desc) {
  1829. +   if (!musb_ep || !musb_ep->desc) {
  1830.         dev_dbg(musb->controller, "req %p queued to %s while ep %s\n",
  1831.                 req, ep->name, "disabled");
  1832.         status = -ESHUTDOWN;
  1833. diff -ruN a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
  1834. --- a/drivers/usb/musb/ux500.c  2012-10-27 17:12:25.307264511 +0900
  1835. +++ b/drivers/usb/musb/ux500.c  2012-10-24 23:38:23.000000000 +0900
  1836. @@ -449,18 +449,10 @@
  1837.     u8      devctl;
  1838.     unsigned long timeout = jiffies + msecs_to_jiffies(1000);
  1839.     int ret = 1;
  1840. -#ifdef CONFIG_USB_OTG_20
  1841. -   int val = 0;
  1842. -#endif
  1843.     /* HDRC controls CPEN, but beware current surges during device
  1844.      * connect.  They can trigger transient overcurrent conditions
  1845.      * that must be ignored.
  1846.      */
  1847. -#ifdef CONFIG_USB_OTG_20
  1848. -   val = musb_readb(musb->mregs, MUSB_MISC);
  1849. -   val |= 0x1C;
  1850. -   musb_writeb(musb->mregs, MUSB_MISC, val);
  1851. -#endif
  1852.     devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
  1853.  
  1854.     if (is_on) {
  1855. diff -ruN a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
  1856. --- a/drivers/usb/musb/ux500_dma.c  2012-10-27 17:12:25.295264268 +0900
  1857. +++ b/drivers/usb/musb/ux500_dma.c  2012-10-24 23:38:23.000000000 +0900
  1858. @@ -9,6 +9,7 @@
  1859.   * Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
  1860.   * Praveena Nadahally <praveen.nadahally@stericsson.com>
  1861.   * Rajaram Regupathy <ragupathy.rajaram@stericsson.com>
  1862. + * Copyright (C) 2012 Sony Mobile Communications AB
  1863.   *
  1864.   * This program is free software: you can redistribute it and/or modify
  1865.   * it under the terms of the GNU General Public License as published by
  1866. @@ -274,6 +275,12 @@
  1867.     if (length <= Ux500_USB_DMA_MIN_TRANSFER_SIZE)
  1868.         return 0;
  1869.  
  1870. +   /* In case when device has no config data
  1871. +    * (i.e. usb ep is disconnected)
  1872. +    */
  1873. +   if (!cdev || !cdev->config)
  1874. +       return 0;
  1875. +
  1876.     list_for_each_entry(f, &cdev->config->functions, list) {
  1877.         if (!strcmp(f->name, "cdc_ethernet") ||
  1878.             !strcmp(f->name, "rndis") ||
  1879. diff -ruN a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c
  1880. --- a/drivers/usb/otg/ab8500-usb.c  2012-10-27 17:12:25.423266858 +0900
  1881. +++ b/drivers/usb/otg/ab8500-usb.c  2012-10-24 23:38:23.000000000 +0900
  1882. @@ -252,8 +252,6 @@
  1883.  
  1884.     clk_enable(ab->sysclk);
  1885.  
  1886. -   ab8500_usb_regulator_ctrl(ab, sel_host, true);
  1887. -
  1888.     prcmu_qos_update_requirement(PRCMU_QOS_APE_OPP,
  1889.                      (char *)dev_name(ab->dev),
  1890.                      PRCMU_QOS_APE_OPP_MAX);
  1891. @@ -361,6 +359,7 @@
  1892.         }
  1893.         if (ab->mode == USB_IDLE) {
  1894.             ab->mode = USB_PERIPHERAL;
  1895. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1896.             atomic_notifier_call_chain(&ab->otg.notifier,
  1897.                            USB_EVENT_PREPARE,
  1898.                            &ab->vbus_draw);
  1899. @@ -375,6 +374,7 @@
  1900.         if (ab->mode == USB_PERIPHERAL) {
  1901.             ab->mode = USB_HOST;
  1902.             ab8500_usb_peri_phy_dis(ab);
  1903. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1904.             atomic_notifier_call_chain(&ab->otg.notifier,
  1905.                            USB_EVENT_PREPARE,
  1906.                            &ab->vbus_draw);
  1907. @@ -382,6 +382,7 @@
  1908.         }
  1909.         if (ab->mode == USB_IDLE) {
  1910.             ab->mode = USB_HOST;
  1911. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1912.             atomic_notifier_call_chain(&ab->otg.notifier,
  1913.                            USB_EVENT_PREPARE,
  1914.                            &ab->vbus_draw);
  1915. @@ -455,6 +456,7 @@
  1916.         if (ab->mode == USB_HOST) {
  1917.             ab->mode = USB_PERIPHERAL;
  1918.             ab8500_usb_host_phy_dis(ab);
  1919. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1920.             atomic_notifier_call_chain(&ab->otg.notifier,
  1921.                            USB_EVENT_PREPARE,
  1922.                            &ab->vbus_draw);
  1923. @@ -462,6 +464,7 @@
  1924.         }
  1925.         if (ab->mode == USB_IDLE) {
  1926.             ab->mode = USB_PERIPHERAL;
  1927. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1928.             atomic_notifier_call_chain(&ab->otg.notifier,
  1929.                            USB_EVENT_PREPARE,
  1930.                            &ab->vbus_draw);
  1931. @@ -477,6 +480,7 @@
  1932.         if (ab->mode == USB_PERIPHERAL) {
  1933.             ab->mode = USB_HOST;
  1934.             ab8500_usb_peri_phy_dis(ab);
  1935. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1936.             atomic_notifier_call_chain(&ab->otg.notifier,
  1937.                            USB_EVENT_PREPARE,
  1938.                            &ab->vbus_draw);
  1939. @@ -484,6 +488,7 @@
  1940.         }
  1941.         if (ab->mode == USB_IDLE) {
  1942.             ab->mode = USB_HOST;
  1943. +           ab8500_usb_regulator_ctrl(ab, true, true);
  1944.             atomic_notifier_call_chain(&ab->otg.notifier,
  1945.                            USB_EVENT_PREPARE,
  1946.                            &ab->vbus_draw);
  1947. diff -ruN a/drivers/video/av8100/av8100.c b/drivers/video/av8100/av8100.c
  1948. --- a/drivers/video/av8100/av8100.c 2012-10-27 17:12:06.838927480 +0900
  1949. +++ b/drivers/video/av8100/av8100.c 2012-10-24 23:38:23.000000000 +0900
  1950. @@ -151,9 +151,6 @@
  1951.  static DEFINE_MUTEX(av8100_usrcnt_mutex);
  1952.  #define LOCK_AV8100_USRCNT mutex_lock(&av8100_usrcnt_mutex)
  1953.  #define UNLOCK_AV8100_USRCNT mutex_unlock(&av8100_usrcnt_mutex)
  1954. -static DEFINE_MUTEX(av8100_conf_mutex);
  1955. -#define LOCK_AV8100_CONF mutex_lock(&av8100_conf_mutex)
  1956. -#define UNLOCK_AV8100_CONF mutex_unlock(&av8100_conf_mutex)
  1957.  
  1958.  enum av8100_timer_flag {
  1959.     TIMER_UNSET,
  1960. @@ -240,7 +237,6 @@
  1961.     bool disp_on;
  1962.     bool busy;
  1963.     u8 hdcp_state;
  1964. -   bool pwr_recover;
  1965.  };
  1966.  
  1967.  /**
  1968. @@ -306,8 +302,6 @@
  1969.     u8          chip_version;
  1970.     struct early_suspend    early_suspend;
  1971.     u32                     usr_cnt;
  1972. -   bool            usr_audio;
  1973. -   bool            usr_video;
  1974.  };
  1975.  
  1976.  static const unsigned int waittime_retry[10] = {
  1977. @@ -646,13 +640,9 @@
  1978.         (av8100_status_get().av8100_state > AV8100_OPMODE_SHUTDOWN);
  1979.  
  1980.     if (adev->params.pre_suspend_power) {
  1981. -       if (adev->usr_audio) {
  1982. -           ret = -EBUSY;
  1983. -       } else {
  1984. -           ret = av8100_powerdown();
  1985. -           if (ret)
  1986. -               dev_err(dev, "av8100_powerdown failed\n");
  1987. -       }
  1988. +       ret = av8100_powerdown();
  1989. +       if (ret)
  1990. +           dev_err(dev, "av8100_powerdown failed\n");
  1991.     }
  1992.  
  1993.     return ret;
  1994. @@ -695,15 +685,9 @@
  1995.  {
  1996.     if (av8100_status_get().av8100_state <= AV8100_OPMODE_SHUTDOWN)
  1997.         return 0;
  1998. -   dev_dbg(adev->dev, "%s %d\n", __func__, adev->usr_audio);
  1999. -   if (!adev->usr_audio) {
  2000. -       av8100_powerdown();
  2001. -       set_hrtimer(adev, TIMER_POWERUP);
  2002. -   } else {
  2003. -       /* Simulate unplug in order to recover */
  2004. -       clr_plug_status(adev, AV8100_HDMI_PLUGIN);
  2005. -       adev->params.pwr_recover = true;
  2006. -   }
  2007. +   dev_dbg(adev->dev, "%s\n", __func__);
  2008. +   av8100_powerdown();
  2009. +   set_hrtimer(adev, TIMER_POWERUP);
  2010.     return 0;
  2011.  }
  2012.  
  2013. @@ -778,8 +762,7 @@
  2014.     if (adev->params.pulsing_5V == false)
  2015.         set_hrtimer(adev, TIMER_1S);
  2016.  
  2017. -   if (av8100_status_get().av8100_state > AV8100_OPMODE_SCAN)
  2018. -       av8100_set_state(adev, AV8100_OPMODE_SCAN);
  2019. +   av8100_set_state(adev, AV8100_OPMODE_SCAN);
  2020.  }
  2021.  
  2022.  static int fix_cec(struct av8100_device *adev)
  2023. @@ -964,8 +947,6 @@
  2024.  
  2025.     dev_dbg(adev->dev, "Thpd\n");
  2026.  
  2027. -   hrtimer_cancel(&adev->hrtimer);
  2028. -
  2029.     /* Clear hpdi and cci interrupts */
  2030.     if (av8100_reg_stby_pend_int_w(
  2031.             AV8100_STANDBY_PENDING_INTERRUPT_HPDI_HIGH,
  2032. @@ -1025,12 +1006,9 @@
  2033.         set_plug_status(adev, AV8100_HDMI_PLUGIN);
  2034.  
  2035.     } else {
  2036. -       if (!adev->usr_audio) {
  2037. -           av8100_powerdown();
  2038. -           usleep_range(AV8100_WAITTIME_1MS,
  2039. -                       AV8100_WAITTIME_1MS_MAX);
  2040. -           av8100_powerup();
  2041. -       }
  2042. +       av8100_powerdown();
  2043. +       msleep(AV8100_WAITTIME_1MS);
  2044. +       av8100_powerup();
  2045.         if (adev->params.pulsing_5V == false)
  2046.             set_hrtimer(adev, TIMER_1S);
  2047.         av8100_set_state(adev, AV8100_OPMODE_SCAN);
  2048. @@ -1063,8 +1041,8 @@
  2049.  {
  2050.     dev_dbg(adev->dev, "Tpwrdown\n");
  2051.  
  2052. -   if (!adev->usr_audio)
  2053. -       (void)av8100_powerdown();
  2054. +   (void)av8100_powerdown();
  2055. +   adev->params.busy = false;
  2056.  }
  2057.  
  2058.  static int cci_handle(struct av8100_device *adev, u8 hpdi)
  2059. @@ -1292,9 +1270,6 @@
  2060.     u8 cecrx = 0;
  2061.     u8 cectx = 0;
  2062.  
  2063. -   if (av8100_status_get().av8100_state <= AV8100_OPMODE_SHUTDOWN)
  2064. -       return 0;
  2065. -
  2066.     /* Get hpdi and cci */
  2067.     if (av8100_reg_stby_pend_int_r(&hpdi, NULL, NULL, &cci, NULL))
  2068.         goto av8100_int_event_handle_err;
  2069. @@ -2785,7 +2760,7 @@
  2070.     return 0;
  2071.  }
  2072.  
  2073. -int av8100_hdmi_get(enum av8100_hdmi_user user)
  2074. +int av8100_hdmi_get(void)
  2075.  {
  2076.     struct av8100_device *adev;
  2077.     int usr_cnt;
  2078. @@ -2793,42 +2768,18 @@
  2079.     adev = devnr_to_adev(AV8100_DEVNR_DEFAULT);
  2080.     if (!adev)
  2081.         return  -EFAULT;
  2082. -   if (adev->timer_flag == TIMER_POWERDOWN) {
  2083. -       dev_dbg(adev->dev, "%s busy %d\n", __func__, user);
  2084. -       return  -EBUSY;
  2085. -   }
  2086. -   if (adev->params.suspended && (user == AV8100_HDMI_USER_AUDIO)) {
  2087. -       dev_dbg(adev->dev, "%s suspended %d\n", __func__, user);
  2088. -       return -EPERM;
  2089. -   }
  2090.  
  2091.     LOCK_AV8100_USRCNT;
  2092. -   switch (user) {
  2093. -   case AV8100_HDMI_USER_AUDIO:
  2094. -       if (!adev->usr_audio) {
  2095. -           adev->usr_cnt++;
  2096. -           adev->usr_audio = true;
  2097. -       }
  2098. -       break;
  2099. -   case AV8100_HDMI_USER_VIDEO:
  2100. -       if (!adev->usr_video) {
  2101. -           adev->usr_cnt++;
  2102. -           adev->usr_video = true;
  2103. -       }
  2104. -       break;
  2105. -   default:
  2106. -       break;
  2107. -   }
  2108. +   adev->usr_cnt++;
  2109.     usr_cnt = adev->usr_cnt;
  2110.     UNLOCK_AV8100_USRCNT;
  2111. -
  2112. -   dev_dbg(adev->dev, "%s %d %d\n", __func__, usr_cnt, user);
  2113. +   dev_dbg(adev->dev, "%s %d\n", __func__, usr_cnt);
  2114.  
  2115.     return usr_cnt;
  2116.  }
  2117.  EXPORT_SYMBOL(av8100_hdmi_get);
  2118.  
  2119. -int av8100_hdmi_put(enum av8100_hdmi_user user)
  2120. +int av8100_hdmi_put(void)
  2121.  {
  2122.     struct av8100_device *adev;
  2123.     int usr_cnt;
  2124. @@ -2838,41 +2789,16 @@
  2125.         return -EFAULT;
  2126.  
  2127.     LOCK_AV8100_USRCNT;
  2128. -   switch (user) {
  2129. -   case AV8100_HDMI_USER_AUDIO:
  2130. -       if (adev->usr_audio) {
  2131. -           adev->usr_cnt--;
  2132. -           adev->usr_audio = false;
  2133. -       }
  2134. -       break;
  2135. -   case AV8100_HDMI_USER_VIDEO:
  2136. -       if (adev->usr_video) {
  2137. -           adev->usr_cnt--;
  2138. -           adev->usr_video = false;
  2139. -       }
  2140. -       break;
  2141. -   default:
  2142. -       break;
  2143. -   }
  2144. +   if (adev->usr_cnt)
  2145. +       adev->usr_cnt--;
  2146.     usr_cnt = adev->usr_cnt;
  2147. +   UNLOCK_AV8100_USRCNT;
  2148.  
  2149. -   dev_dbg(adev->dev, "%s %d %d\n", __func__, usr_cnt, user);
  2150. +   dev_dbg(adev->dev, "%s %d\n", __func__, usr_cnt);
  2151.  
  2152. -   if (usr_cnt == 0) {
  2153. -       if (adev->params.suspended) {
  2154. -           adev->params.disp_on = false;
  2155. -           av8100_powerdown();
  2156. -       } else if (adev->params.plug_state == AV8100_UNPLUGGED) {
  2157. -           if (adev->params.pwr_recover) {
  2158. -               adev->params.pwr_recover = false;
  2159. -               av8100_powerdown();
  2160. -               av8100_powerup();
  2161. -           }
  2162. -           if (av8100_powerscan(true))
  2163. -               dev_err(adev->dev, "av8100_powerscan failed\n");
  2164. -       }
  2165. -   }
  2166. -   UNLOCK_AV8100_USRCNT;
  2167. +   if (usr_cnt == 0)
  2168. +       if (av8100_powerscan(true))
  2169. +           dev_err(adev->dev, "av8100_powerscan failed\n");
  2170.  
  2171.     return usr_cnt;
  2172.  }
  2173. @@ -2880,7 +2806,9 @@
  2174.  
  2175.  int av8100_hdmi_video_off(void)
  2176.  {
  2177. +   int ret;
  2178.     struct av8100_device *adev;
  2179. +   union av8100_configuration config;
  2180.  
  2181.     adev = devnr_to_adev(AV8100_DEVNR_DEFAULT);
  2182.     if (!adev)
  2183. @@ -2891,64 +2819,42 @@
  2184.     if (av8100_status_get().av8100_state < AV8100_OPMODE_VIDEO)
  2185.         return 0;
  2186.  
  2187. -   /* Video is off: mask uovbi interrupts */
  2188. -   if (av8100_reg_gen_int_mask_w(
  2189. -           AV8100_GENERAL_INTERRUPT_MASK_EOCM_LOW,
  2190. -           AV8100_GENERAL_INTERRUPT_MASK_VSIM_LOW,
  2191. -           AV8100_GENERAL_INTERRUPT_MASK_VSOM_LOW,
  2192. -           adev->params.cecm,
  2193. -           adev->params.hdcpm,
  2194. -           AV8100_GENERAL_INTERRUPT_MASK_UOVBM_LOW,
  2195. -           AV8100_GENERAL_INTERRUPT_MASK_TEM_LOW))
  2196. -       dev_dbg(adev->dev, "av8100_reg_gen_int_mask_w err\n");
  2197. -
  2198. -   av8100_set_state(adev, AV8100_OPMODE_IDLE);
  2199. -
  2200. -   return 0;
  2201. -}
  2202. -EXPORT_SYMBOL(av8100_hdmi_video_off);
  2203. -
  2204. -int av8100_hdmi_video_on(void)
  2205. -{
  2206. -   struct av8100_device *adev;
  2207. -
  2208. -   adev = devnr_to_adev(AV8100_DEVNR_DEFAULT);
  2209. -   if (!adev)
  2210. +   /* Get current av8100 video input format */
  2211. +   ret = av8100_conf_get(AV8100_COMMAND_VIDEO_INPUT_FORMAT,
  2212. +       &config);
  2213. +   if (ret) {
  2214. +       dev_err(adev->dev, "%s:av8100_conf_get "
  2215. +           "AV8100_COMMAND_VIDEO_INPUT_FORMAT failed\n",
  2216. +           __func__);
  2217.         return -EFAULT;
  2218. +   }
  2219.  
  2220. -   dev_dbg(adev->dev, "%s\n", __func__);
  2221. +   config.video_input_format.dsi_input_mode = AV8100_HDMI_DSI_OFF;
  2222.  
  2223. -   if (av8100_status_get().av8100_state < AV8100_OPMODE_IDLE)
  2224. -       return 0;
  2225. +   ret = av8100_conf_prep(AV8100_COMMAND_VIDEO_INPUT_FORMAT,
  2226. +       &config);
  2227. +   if (ret) {
  2228. +       dev_err(adev->dev, "%s:av8100_conf_prep "
  2229. +               "AV8100_COMMAND_VIDEO_INPUT_FORMAT failed\n",
  2230. +               __func__);
  2231. +       return -EFAULT;
  2232. +   }
  2233.  
  2234. -   /* Video is off: unmask uovbi interrupts */
  2235. -   if (av8100_reg_gen_int_mask_w(
  2236. -           AV8100_GENERAL_INTERRUPT_MASK_EOCM_LOW,
  2237. -           AV8100_GENERAL_INTERRUPT_MASK_VSIM_LOW,
  2238. -           AV8100_GENERAL_INTERRUPT_MASK_VSOM_LOW,
  2239. -           adev->params.cecm,
  2240. -           adev->params.hdcpm,
  2241. -           adev->params.uovbm,
  2242. -           AV8100_GENERAL_INTERRUPT_MASK_TEM_LOW))
  2243. -       dev_dbg(adev->dev, "av8100_reg_gen_int_mask_w err\n");
  2244. +   /* Video input */
  2245. +   ret = av8100_conf_w(AV8100_COMMAND_VIDEO_INPUT_FORMAT,
  2246. +       NULL, NULL, I2C_INTERFACE);
  2247. +   if (ret) {
  2248. +       dev_err(adev->dev, "%s:av8100_conf_w "
  2249. +               "AV8100_COMMAND_VIDEO_INPUT_FORMAT failed\n",
  2250. +               __func__);
  2251. +       return -EFAULT;
  2252. +   }
  2253.  
  2254. -   av8100_set_state(adev, AV8100_OPMODE_VIDEO);
  2255. +   av8100_set_state(adev, AV8100_OPMODE_IDLE);
  2256.  
  2257.     return 0;
  2258.  }
  2259. -EXPORT_SYMBOL(av8100_hdmi_video_on);
  2260. -
  2261. -void av8100_conf_lock(void)
  2262. -{
  2263. -   LOCK_AV8100_CONF;
  2264. -}
  2265. -EXPORT_SYMBOL(av8100_conf_lock);
  2266. -
  2267. -void av8100_conf_unlock(void)
  2268. -{
  2269. -   UNLOCK_AV8100_CONF;
  2270. -}
  2271. -EXPORT_SYMBOL(av8100_conf_unlock);
  2272. +EXPORT_SYMBOL(av8100_hdmi_video_off);
  2273.  
  2274.  int av8100_powerwakeup(bool disp_user)
  2275.  {
  2276. @@ -2966,12 +2872,16 @@
  2277.         goto av8100_powerwakeup_end;
  2278.     }
  2279.  
  2280. -   if (disp_user)
  2281. +   if (disp_user) {
  2282.         adev->params.disp_on = true;
  2283. +       if (av8100_status_get().av8100_state < AV8100_OPMODE_STANDBY)
  2284. +           ret = av8100_powerup();
  2285. +   } else {
  2286. +       if (av8100_status_get().av8100_state > AV8100_OPMODE_SHUTDOWN)
  2287. +           av8100_powerdown();
  2288.  
  2289. -   if (av8100_status_get().av8100_state < AV8100_OPMODE_STANDBY)
  2290. -       ret = av8100_powerup();
  2291. -
  2292. +       set_hrtimer(adev, TIMER_POWERUP);
  2293. +   }
  2294.  av8100_powerwakeup_end:
  2295.     return ret;
  2296.  }
  2297. @@ -3016,8 +2926,7 @@
  2298.         set_hrtimer(adev, TIMER_POWERDOWN);
  2299.         adev->params.busy = true;
  2300.     } else {
  2301. -       if (!adev->usr_audio)
  2302. -           ret = av8100_powerdown();
  2303. +       ret = av8100_powerdown();
  2304.     }
  2305.  av8100_powerscan_end:
  2306.     return ret;
  2307. @@ -3071,7 +2980,7 @@
  2308.         return -EFAULT;
  2309.  
  2310.     adev->params.busy = false;
  2311. -   adev->flag = 0;
  2312. +   adev->flag &= ~AV8100_EVENTS;
  2313.     adev->timer_flag = TIMER_UNSET;
  2314.     hrtimer_cancel(&adev->hrtimer);
  2315.     pdata = adev->dev->platform_data;
  2316. @@ -3434,10 +3343,8 @@
  2317.  av8100_download_firmware_err2:
  2318.     UNLOCK_AV8100_FWDL;
  2319.  
  2320. -   if (!adev->params.suspended) {
  2321. -       adev->flag |= AV8100_SCAN_TIMER_EVENT;
  2322. -       wake_up_interruptible(&adev->event);
  2323. -   }
  2324. +   adev->flag |= AV8100_SCAN_TIMER_EVENT;
  2325. +   wake_up_interruptible(&adev->event);
  2326.  
  2327.     return retval;
  2328.  }
  2329. @@ -4851,11 +4758,7 @@
  2330.         container_of(data, struct av8100_device, early_suspend);
  2331.  
  2332.     adev->params.suspended = false;
  2333. -   if (!adev->params.disp_on) {
  2334. -       adev->flag &= ~AV8100_EVENTS;
  2335. -       hrtimer_cancel(&adev->hrtimer);
  2336. -       (void)av8100_powerwakeup(false);
  2337. -   }
  2338. +   (void)av8100_powerwakeup(false);
  2339.  }
  2340.  
  2341.  static int av8100_open(struct inode *inode, struct file *filp)
  2342. diff -ruN a/drivers/video/av8100/hdmi.c b/drivers/video/av8100/hdmi.c
  2343. --- a/drivers/video/av8100/hdmi.c   2012-10-27 17:12:06.842927527 +0900
  2344. +++ b/drivers/video/av8100/hdmi.c   2012-10-24 23:38:23.000000000 +0900
  2345. @@ -409,7 +409,6 @@
  2346.  {
  2347.     union av8100_configuration config;
  2348.     struct av8100_status status;
  2349. -   int ret = 0;
  2350.  
  2351.     status = av8100_status_get();
  2352.     if (status.av8100_state < AV8100_OPMODE_STANDBY)
  2353. @@ -430,24 +429,19 @@
  2354.     config.infoframes_format.crc = crc;
  2355.     config.infoframes_format.length = data_len;
  2356.     memcpy(&config.infoframes_format.data, data, data_len);
  2357. -   av8100_conf_lock();
  2358.     if (av8100_conf_prep(AV8100_COMMAND_INFOFRAMES,
  2359.         &config) != 0) {
  2360.         dev_err(hdev->dev, "av8100_conf_prep FAIL\n");
  2361. -       ret = -EINVAL;
  2362. -       goto infofrsend_end;
  2363. +       return -EINVAL;
  2364.     }
  2365.  
  2366.     if (av8100_conf_w(AV8100_COMMAND_INFOFRAMES,
  2367.         NULL, NULL, I2C_INTERFACE) != 0) {
  2368.         dev_err(hdev->dev, "av8100_conf_w FAIL\n");
  2369. -       ret = -EINVAL;
  2370. -       goto infofrsend_end;
  2371. +       return -EINVAL;
  2372.     }
  2373.  
  2374. -infofrsend_end:
  2375. -   av8100_conf_unlock();
  2376. -   return ret;
  2377. +   return 0;
  2378.  }
  2379.  
  2380.  static int hdcpchkaesotp(struct hdmi_device *hdev, u8 *crc, u8 *progged)
  2381. @@ -702,7 +696,6 @@
  2382.  {
  2383.     union av8100_configuration config;
  2384.     struct av8100_status status;
  2385. -   int ret = 0;
  2386.  
  2387.     status = av8100_status_get();
  2388.     if (status.av8100_state < AV8100_OPMODE_STANDBY) {
  2389. @@ -727,24 +720,19 @@
  2390.     config.audio_input_format.audio_if_mode     = cfg->if_mode;
  2391.     config.audio_input_format.audio_mute        = cfg->mute;
  2392.  
  2393. -   av8100_conf_lock();
  2394.     if (av8100_conf_prep(AV8100_COMMAND_AUDIO_INPUT_FORMAT,
  2395.         &config) != 0) {
  2396.         dev_err(hdev->dev, "av8100_conf_prep FAIL\n");
  2397. -       ret = -EINVAL;
  2398. -       goto audiocfg_end;
  2399. +       return -EINVAL;
  2400.     }
  2401.  
  2402.     if (av8100_conf_w(AV8100_COMMAND_AUDIO_INPUT_FORMAT,
  2403.         NULL, NULL, I2C_INTERFACE) != 0) {
  2404.         dev_err(hdev->dev, "av8100_conf_w FAIL\n");
  2405. -       ret = -EINVAL;
  2406. -       goto audiocfg_end;
  2407. +       return -EINVAL;
  2408.     }
  2409.  
  2410. -audiocfg_end:
  2411. -   av8100_conf_unlock();
  2412. -   return ret;
  2413. +   return 0;
  2414.  }
  2415.  
  2416.  /* sysfs */
  2417. @@ -2174,19 +2162,15 @@
  2418.         else
  2419.             config.hdmi_format.hdmi_mode = AV8100_HDMI_ON;
  2420.  
  2421. -       av8100_conf_lock();
  2422.         if (av8100_conf_prep(AV8100_COMMAND_HDMI, &config) != 0) {
  2423.             dev_err(hdev->dev, "av8100_conf_prep FAIL\n");
  2424. -           av8100_conf_unlock();
  2425.             return -EINVAL;
  2426.         }
  2427.         if (av8100_conf_w(AV8100_COMMAND_HDMI, NULL, NULL,
  2428.             I2C_INTERFACE) != 0) {
  2429.             dev_err(hdev->dev, "av8100_conf_w FAIL\n");
  2430. -           av8100_conf_unlock();
  2431.             return -EINVAL;
  2432.         }
  2433. -       av8100_conf_unlock();
  2434.         }
  2435.         break;
  2436.  
  2437. diff -ruN a/drivers/video/b2r2/b2r2_api.c b/drivers/video/b2r2/b2r2_api.c
  2438. --- a/drivers/video/b2r2/b2r2_api.c 2012-10-27 17:12:06.314921488 +0900
  2439. +++ b/drivers/video/b2r2/b2r2_api.c 2012-10-24 23:38:23.000000000 +0900
  2440. @@ -308,6 +308,7 @@
  2441.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  2442.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2443.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  2444. +   case B2R2_BLT_FMT_YV12:
  2445.         return true;
  2446.     default:
  2447.         return false;
  2448. diff -ruN a/drivers/video/b2r2/b2r2_generic.c b/drivers/video/b2r2/b2r2_generic.c
  2449. --- a/drivers/video/b2r2/b2r2_generic.c 2012-10-27 17:12:06.314921488 +0900
  2450. +++ b/drivers/video/b2r2/b2r2_generic.c 2012-10-24 23:38:23.000000000 +0900
  2451. @@ -211,6 +211,7 @@
  2452.     case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  2453.     case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  2454.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  2455. +   case B2R2_BLT_FMT_YV12:
  2456.         return B2R2_NATIVE_YUV;
  2457.     default:
  2458.         /* Should never ever happen */
  2459. @@ -240,103 +241,13 @@
  2460.     return B2R2_TY_ALPHA_RANGE_128; /* 0 - 128 */
  2461.  }
  2462.  
  2463. -static unsigned int get_pitch(struct b2r2_control *cont,
  2464. -       enum b2r2_blt_fmt format, u32 width)
  2465. -{
  2466. -   switch (format) {
  2467. -   case B2R2_BLT_FMT_1_BIT_A1: {
  2468. -       int pitch = width >> 3;
  2469. -       /* Check for remainder */
  2470. -       if (width & 7)
  2471. -           pitch++;
  2472. -       return pitch;
  2473. -       break;
  2474. -   }
  2475. -   case B2R2_BLT_FMT_8_BIT_A8:
  2476. -       return width;
  2477. -       break;
  2478. -   case B2R2_BLT_FMT_16_BIT_RGB565: /* all 16 bits/pixel RGB formats */
  2479. -   case B2R2_BLT_FMT_16_BIT_ARGB1555:
  2480. -   case B2R2_BLT_FMT_16_BIT_ARGB4444:
  2481. -   case B2R2_BLT_FMT_16_BIT_ABGR4444:
  2482. -       return width * 2;
  2483. -       break;
  2484. -   case B2R2_BLT_FMT_24_BIT_RGB888: /* all 24 bits/pixel raster formats */
  2485. -   case B2R2_BLT_FMT_24_BIT_ARGB8565:
  2486. -   case B2R2_BLT_FMT_24_BIT_YUV888:
  2487. -   case B2R2_BLT_FMT_24_BIT_VUY888:
  2488. -       return width * 3;
  2489. -       break;
  2490. -   case B2R2_BLT_FMT_32_BIT_ARGB8888: /* all 32 bits/pixel formats */
  2491. -   case B2R2_BLT_FMT_32_BIT_ABGR8888:
  2492. -   case B2R2_BLT_FMT_32_BIT_VUYA8888:
  2493. -   case B2R2_BLT_FMT_32_BIT_AYUV8888:
  2494. -       return width * 4;
  2495. -       break;
  2496. -   case B2R2_BLT_FMT_CB_Y_CR_Y:
  2497. -       /* width of the buffer must be a multiple of 4 */
  2498. -       if (width & 3) {
  2499. -           b2r2_log_warn(cont->dev, "%s: Illegal width "
  2500. -               "for fmt=%#010x width=%d\n", __func__,
  2501. -               format, width);
  2502. -           return 0;
  2503. -       }
  2504. -       return width * 2;
  2505. -       break;
  2506. -   case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  2507. -       return width;
  2508. -       break;
  2509. -   /* fall through, same pitch and pointers */
  2510. -   case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  2511. -   case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  2512. -   case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  2513. -   case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  2514. -   case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  2515. -   case B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR:
  2516. -   case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  2517. -   case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  2518. -       /* width of the buffer must be a multiple of 2 */
  2519. -       if (width & 1) {
  2520. -           b2r2_log_warn(cont->dev, "%s: Illegal width "
  2521. -               "for fmt=%#010x width=%d\n", __func__,
  2522. -               format, width);
  2523. -           return 0;
  2524. -       }
  2525. -       /*
  2526. -        * return pitch of the Y-buffer.
  2527. -        * U and V pitch can be derived from it.
  2528. -        */
  2529. -       return width;
  2530. -       break;
  2531. -   case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2532. -   case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  2533. -       /* width of the buffer must be a multiple of 16. */
  2534. -       if (width & 15) {
  2535. -           b2r2_log_warn(cont->dev, "%s: Illegal width "
  2536. -               "for fmt=%#010x width=%d\n", __func__,
  2537. -               format, width);
  2538. -           return 0;
  2539. -       }
  2540. -       /*
  2541. -        * return pitch of the Y-buffer.
  2542. -        * U and V pitch can be derived from it.
  2543. -        */
  2544. -       return width;
  2545. -       break;
  2546. -   default:
  2547. -       b2r2_log_warn(cont->dev, "%s: Unable to determine pitch "
  2548. -           "for fmt=%#010x width=%d\n", __func__,
  2549. -           format, width);
  2550. -       return 0;
  2551. -   }
  2552. -}
  2553. -
  2554.  static s32 validate_buf(struct b2r2_control *cont,
  2555.         const struct b2r2_blt_img *image,
  2556.         const struct b2r2_resolved_buf *buf)
  2557.  {
  2558.     u32 expect_buf_size;
  2559.     u32 pitch;
  2560. +   u32 chroma_pitch;
  2561.  
  2562.     if (image->width <= 0 || image->height <= 0) {
  2563.         b2r2_log_warn(cont->dev, "%s: width=%d or height=%d negative"
  2564. @@ -346,7 +257,8 @@
  2565.  
  2566.     if (image->pitch == 0) {
  2567.         /* autodetect pitch based on format and width */
  2568. -       pitch = get_pitch(cont, image->fmt, image->width);
  2569. +       pitch = b2r2_calc_pitch_from_width(cont->dev,
  2570. +           image->width, image->fmt);
  2571.     } else
  2572.         pitch = image->pitch;
  2573.  
  2574. @@ -361,22 +273,22 @@
  2575.     }
  2576.  
  2577.     /* format specific adjustments */
  2578. +   chroma_pitch = b2r2_get_chroma_pitch(pitch, image->fmt);
  2579.     switch (image->fmt) {
  2580.     case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  2581.     case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  2582. +   case B2R2_BLT_FMT_YV12:
  2583.         /*
  2584.          * Use ceil(height/2) in case buffer height
  2585.          * is not divisible by 2.
  2586.          */
  2587. -       expect_buf_size +=
  2588. -           (pitch >> 1) * ((image->height + 1) >> 1) * 2;
  2589. +       expect_buf_size += chroma_pitch *
  2590. +           ((image->height + 1) >> 1) * 2;
  2591.         break;
  2592.     case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  2593.     case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  2594. -       expect_buf_size += (pitch >> 1) * image->height * 2;
  2595. -       break;
  2596.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  2597. -       expect_buf_size += pitch * image->height * 2;
  2598. +       expect_buf_size += chroma_pitch * image->height * 2;
  2599.         break;
  2600.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  2601.     case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  2602. @@ -558,6 +470,7 @@
  2603.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  2604.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2605.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  2606. +   case B2R2_BLT_FMT_YV12:
  2607.         if ((req->user_req.flags & B2R2_BLT_FLAG_SOURCE_FILL) != 0) {
  2608.             fill_fmt = B2R2_NATIVE_AYCBCR8888;
  2609.             /*
  2610. @@ -575,33 +488,9 @@
  2611.                 b2r2_setup_ivmx(node, B2R2_CC_BLT_YUV888_TO_RGB);
  2612.         } else {
  2613.             /* SOURCE_FILL_RAW */
  2614. -           bool dst_yuv_planar =
  2615. -               B2R2_BLT_FMT_YUV420_PACKED_PLANAR ==
  2616. -                   dst_img->fmt ||
  2617. -               B2R2_BLT_FMT_YUV422_PACKED_PLANAR ==
  2618. -                   dst_img->fmt ||
  2619. -               B2R2_BLT_FMT_YVU420_PACKED_PLANAR ==
  2620. -                   dst_img->fmt ||
  2621. -               B2R2_BLT_FMT_YVU422_PACKED_PLANAR ==
  2622. -                   dst_img->fmt ||
  2623. -               B2R2_BLT_FMT_YUV444_PACKED_PLANAR ==
  2624. -                   dst_img->fmt;
  2625. -
  2626. -           bool dst_yuv_semi_planar =
  2627. -               B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ==
  2628. -                   dst_img->fmt ||
  2629. -               B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ==
  2630. -                   dst_img->fmt ||
  2631. -               B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ==
  2632. -                   dst_img->fmt ||
  2633. -               B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ==
  2634. -                   dst_img->fmt ||
  2635. -               B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ==
  2636. -                   dst_img->fmt ||
  2637. -               B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE ==
  2638. -                   dst_img->fmt;
  2639. -
  2640. -           if (dst_yuv_planar || dst_yuv_semi_planar) {
  2641. +           if (b2r2_is_ycbcrp_fmt(dst_img->fmt) ||
  2642. +                   b2r2_is_ycbcrsp_fmt(dst_img->fmt) ||
  2643. +                   b2r2_is_mb_fmt(dst_img->fmt))
  2644.                 /*
  2645.                  * SOURCE_FILL_RAW cannot be supported
  2646.                  * with multi-buffer formats.
  2647. @@ -609,9 +498,8 @@
  2648.                  * from misbehaving.
  2649.                  */
  2650.                 fill_fmt = B2R2_NATIVE_AYCBCR8888;
  2651. -           } else {
  2652. +           else
  2653.                 fill_fmt = to_native_fmt(cont, dst_img->fmt);
  2654. -           }
  2655.  
  2656.             switch (dst_img->fmt) {
  2657.             case B2R2_BLT_FMT_24_BIT_YUV888:
  2658. @@ -712,27 +600,13 @@
  2659.     u32 fctl = 0;
  2660.     u32 rsf = 0;
  2661.     u32 rzi = 0;
  2662. -   bool yuv_semi_planar =
  2663. -       src_img->fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  2664. -       src_img->fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  2665. -       src_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  2666. -       src_img->fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  2667. -       src_img->fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ||
  2668. -       src_img->fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  2669. -
  2670. -   bool yuv_planar =
  2671. -       src_img->fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  2672. -       src_img->fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  2673. -       src_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2674. -       src_img->fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  2675. -       src_img->fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR;
  2676. -
  2677.     struct b2r2_filter_spec *hf;
  2678.     struct b2r2_filter_spec *vf;
  2679. -
  2680.     bool use_h_filter = false;
  2681.     bool use_v_filter = false;
  2682. -
  2683. +   const bool yuv_planar = b2r2_is_ycbcrp_fmt(src_img->fmt);
  2684. +   const bool yuv_semi_planar = b2r2_is_ycbcrsp_fmt(src_img->fmt) ||
  2685. +       b2r2_is_mb_fmt(src_img->fmt);
  2686.     struct b2r2_control *cont = req->instance->control;
  2687.     bool fullrange = (req->user_req.flags &
  2688.         B2R2_BLT_FLAG_FULL_RANGE_YUV) != 0;
  2689. @@ -748,7 +622,8 @@
  2690.  
  2691.     if (src_img->pitch == 0) {
  2692.         /* Determine pitch based on format and width of the image. */
  2693. -       src_pitch = get_pitch(cont, src_img->fmt, src_img->width);
  2694. +       src_pitch = b2r2_calc_pitch_from_width(cont->dev,
  2695. +           src_img->width, src_img->fmt);
  2696.     } else {
  2697.         src_pitch = src_img->pitch;
  2698.     }
  2699. @@ -852,7 +727,8 @@
  2700.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  2701.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  2702.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2703. -   case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE: {
  2704. +   case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  2705. +   case B2R2_BLT_FMT_YV12: {
  2706.         /*
  2707.          * Luma handled in the same way
  2708.          * for all YUV multi-buffer formats.
  2709. @@ -906,6 +782,7 @@
  2710.         case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  2711.         case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  2712.         case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2713. +       case B2R2_BLT_FMT_YV12:
  2714.             /*
  2715.              * Chrominance is always half the luminance size
  2716.              * so chrominance resizer is always active.
  2717. @@ -1025,50 +902,14 @@
  2718.          */
  2719.         u32 cb_addr = 0;
  2720.         u32 cr_addr = 0;
  2721. -       u32 chroma_pitch = 0;
  2722. -       bool swapped_chroma =
  2723. -           src_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2724. -           src_img->fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR;
  2725.         enum b2r2_native_fmt src_fmt =
  2726.             to_native_fmt(cont, src_img->fmt);
  2727. +       u32 chroma_pitch =
  2728. +           b2r2_get_chroma_pitch(src_pitch, src_img->fmt);
  2729.  
  2730. -       if (swapped_chroma)
  2731. -           cr_addr = req->src_resolved.physical_address +
  2732. -               src_pitch * src_img->height;
  2733. -       else
  2734. -           cb_addr = req->src_resolved.physical_address +
  2735. -               src_pitch * src_img->height;
  2736. -
  2737. -       switch (src_img->fmt) {
  2738. -       case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  2739. -       case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  2740. -           chroma_pitch = src_pitch >> 1;
  2741. -           if (swapped_chroma)
  2742. -               cb_addr = cr_addr + chroma_pitch *
  2743. -                   (src_img->height >> 1);
  2744. -           else
  2745. -               cr_addr = cb_addr + chroma_pitch *
  2746. -                   (src_img->height >> 1);
  2747. -           break;
  2748. -       case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  2749. -       case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  2750. -           chroma_pitch = src_pitch >> 1;
  2751. -           if (swapped_chroma)
  2752. -               cb_addr = cr_addr + chroma_pitch *
  2753. -                   src_img->height;
  2754. -           else
  2755. -               cr_addr = cb_addr + chroma_pitch *
  2756. -                   src_img->height;
  2757. -           break;
  2758. -       case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  2759. -           /* Chrominance has full resolution, same as luminance.*/
  2760. -           chroma_pitch = src_pitch;
  2761. -           cr_addr =
  2762. -               cb_addr + chroma_pitch * src_img->height;
  2763. -           break;
  2764. -       default:
  2765. -           break;
  2766. -       }
  2767. +       b2r2_get_cb_cr_addr(req->src_resolved.physical_address,
  2768. +           src_pitch, src_img->height, src_img->fmt,
  2769. +           &cr_addr, &cb_addr);
  2770.  
  2771.         node->node.GROUP3.B2R2_SBA = cr_addr;
  2772.         node->node.GROUP3.B2R2_STY =
  2773. @@ -1222,20 +1063,9 @@
  2774.     u32 fctl = 0;
  2775.     u32 rsf = 0;
  2776.     u32 endianness = 0;
  2777. -   bool yuv_semi_planar =
  2778. -       dst_img->fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  2779. -       dst_img->fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  2780. -       dst_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  2781. -       dst_img->fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  2782. -       dst_img->fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ||
  2783. -       dst_img->fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  2784. -
  2785. -   bool yuv_planar =
  2786. -       dst_img->fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  2787. -       dst_img->fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  2788. -       dst_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2789. -       dst_img->fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  2790. -       dst_img->fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR;
  2791. +   const bool yuv_planar = b2r2_is_ycbcrp_fmt(dst_img->fmt);
  2792. +   const bool yuv_semi_planar = b2r2_is_ycbcrsp_fmt(dst_img->fmt) ||
  2793. +       b2r2_is_mb_fmt(dst_img->fmt);
  2794.  
  2795.     u32 dst_pitch = 0;
  2796.     struct b2r2_control *cont = req->instance->control;
  2797. @@ -1244,7 +1074,8 @@
  2798.  
  2799.     if (dst_img->pitch == 0) {
  2800.         /* Determine pitch based on format and width of the image. */
  2801. -       dst_pitch = get_pitch(cont, dst_img->fmt, dst_img->width);
  2802. +       dst_pitch = b2r2_calc_pitch_from_width(cont->dev,
  2803. +           dst_img->width, dst_img->fmt);
  2804.     } else {
  2805.         dst_pitch = dst_img->pitch;
  2806.     }
  2807. @@ -1299,7 +1130,8 @@
  2808.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  2809.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  2810.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2811. -   case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE: {
  2812. +   case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  2813. +   case B2R2_BLT_FMT_YV12: {
  2814.         if (dst_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  2815.             dst_img->fmt ==
  2816.                 B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR) {
  2817. @@ -1320,6 +1152,7 @@
  2818.         case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  2819.         case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  2820.         case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  2821. +       case B2R2_BLT_FMT_YV12:
  2822.             /*
  2823.              * Chrominance is always half the luminance size
  2824.              * so chrominance resizer is always active.
  2825. @@ -1394,47 +1227,14 @@
  2826.          */
  2827.         u32 cb_addr = 0;
  2828.         u32 cr_addr = 0;
  2829. -       u32 chroma_pitch = 0;
  2830. -       bool swapped_chroma =
  2831. -           dst_img->fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2832. -           dst_img->fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR;
  2833. +       u32 chroma_pitch =
  2834. +           b2r2_get_chroma_pitch(dst_pitch, dst_img->fmt);
  2835.         enum b2r2_native_fmt dst_native_fmt =
  2836.                 to_native_fmt(cont, dst_img->fmt);
  2837.  
  2838. -       if (swapped_chroma)
  2839. -           cr_addr = req->dst_resolved.physical_address +
  2840. -               dst_pitch * dst_img->height;
  2841. -       else
  2842. -           cb_addr = req->dst_resolved.physical_address +
  2843. -               dst_pitch * dst_img->height;
  2844. -
  2845. -       switch (dst_img->fmt) {
  2846. -       case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  2847. -           chroma_pitch = dst_pitch >> 1;
  2848. -           if (swapped_chroma)
  2849. -               cb_addr = cr_addr + chroma_pitch *
  2850. -                   (dst_img->height >> 1);
  2851. -           else
  2852. -               cr_addr = cb_addr + chroma_pitch *
  2853. -                   (dst_img->height >> 1);
  2854. -           break;
  2855. -       case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  2856. -           chroma_pitch = dst_pitch >> 1;
  2857. -           if (swapped_chroma)
  2858. -               cb_addr = cr_addr + chroma_pitch *
  2859. -                   dst_img->height;
  2860. -           else
  2861. -               cr_addr = cb_addr + chroma_pitch *
  2862. -                   dst_img->height;
  2863. -           break;
  2864. -       case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  2865. -           chroma_pitch = dst_pitch;
  2866. -           cr_addr =
  2867. -               cb_addr + chroma_pitch * dst_img->height;
  2868. -           break;
  2869. -       default:
  2870. -           break;
  2871. -       }
  2872. +       b2r2_get_cb_cr_addr(req->dst_resolved.physical_address,
  2873. +           dst_pitch, dst_img->height, dst_img->fmt,
  2874. +           &cb_addr, &cr_addr);
  2875.  
  2876.         node->node.GROUP3.B2R2_SBA = cr_addr;
  2877.         node->node.GROUP3.B2R2_STY =
  2878. @@ -1638,21 +1438,9 @@
  2879.  {
  2880.     const struct b2r2_blt_img *dst_img = &(req->user_req.dst_img);
  2881.     const enum b2r2_blt_fmt dst_fmt = dst_img->fmt;
  2882. -   const bool yuv_planar_dst =
  2883. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  2884. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  2885. -       dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2886. -       dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  2887. -       dst_fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR;
  2888. -
  2889. -   const bool yuv_semi_planar_dst =
  2890. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  2891. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  2892. -       dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  2893. -       dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  2894. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ||
  2895. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  2896. -
  2897. +   const bool yuv_planar_dst = b2r2_is_ycbcrp_fmt(dst_fmt);
  2898. +   const bool yuv_semi_planar_dst = b2r2_is_ycbcrsp_fmt(dst_fmt) ||
  2899. +       b2r2_is_mb_fmt(dst_fmt);
  2900.     const u32 group4_b2r2_sty =
  2901.         (B2R2_GENERIC_WORK_BUF_PITCH << B2R2_TY_BITMAP_PITCH_SHIFT) |
  2902.         B2R2_GENERIC_WORK_BUF_FMT |
  2903. @@ -1671,8 +1459,8 @@
  2904.     b2r2_log_info(cont->dev, "%s ENTRY\n", __func__);
  2905.  
  2906.     if (dst_img->pitch == 0) {
  2907. -       /* Determine pitch based on format and width of the image. */
  2908. -       dst_pitch = get_pitch(cont, dst_img->fmt, dst_img->width);
  2909. +       dst_pitch = b2r2_calc_pitch_from_width(cont->dev,
  2910. +           dst_img->width, dst_img->fmt);
  2911.     } else
  2912.         dst_pitch = dst_img->pitch;
  2913.  
  2914. @@ -1696,31 +1484,19 @@
  2915.  
  2916.         u32 cb_addr = 0;
  2917.         u32 cr_addr = 0;
  2918. -       u32 chroma_pitch = 0;
  2919. -       bool swapped_chroma =
  2920. -           dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2921. -           dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR;
  2922. +       u32 chroma_pitch = b2r2_get_chroma_pitch(dst_pitch, dst_fmt);
  2923. +
  2924.         enum b2r2_native_fmt dst_native_fmt =
  2925.                 to_native_fmt(cont, dst_img->fmt);
  2926.         enum b2r2_ty alpha_range = get_alpha_range(cont, dst_img->fmt);
  2927.  
  2928. -       if (swapped_chroma)
  2929. -           cr_addr = req->dst_resolved.physical_address +
  2930. -               dst_pitch * dst_img->height;
  2931. -       else
  2932. -           cb_addr = req->dst_resolved.physical_address +
  2933. -               dst_pitch * dst_img->height;
  2934. +       b2r2_get_cb_cr_addr(req->dst_resolved.physical_address,
  2935. +           dst_pitch, dst_img->height, dst_fmt,
  2936. +           &cr_addr, &cb_addr);
  2937.  
  2938.         switch (dst_fmt) {
  2939.         case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  2940.         case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  2941. -           chroma_pitch = dst_pitch >> 1;
  2942. -           if (swapped_chroma)
  2943. -               cb_addr = cr_addr + chroma_pitch *
  2944. -                   (dst_img->height >> 1);
  2945. -           else
  2946. -               cr_addr = cb_addr + chroma_pitch *
  2947. -                   (dst_img->height >> 1);
  2948.             /*
  2949.              * Chrominance is always half the luminance size
  2950.              * so chrominance resizer is always active.
  2951. @@ -1735,13 +1511,6 @@
  2952.             break;
  2953.         case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  2954.         case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  2955. -           chroma_pitch = dst_pitch >> 1;
  2956. -           if (swapped_chroma)
  2957. -               cb_addr = cr_addr + chroma_pitch *
  2958. -                   dst_img->height;
  2959. -           else
  2960. -               cr_addr = cb_addr + chroma_pitch *
  2961. -                   dst_img->height;
  2962.             /*
  2963.              * YUV422 or YVU422
  2964.              * Chrominance is always half the luminance size
  2965. @@ -1755,9 +1524,6 @@
  2966.             rsf |= (1 << 10) << B2R2_RSF_VSRC_INC_SHIFT;
  2967.             break;
  2968.         case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  2969. -           chroma_pitch = dst_pitch;
  2970. -           cr_addr =
  2971. -               cb_addr + chroma_pitch * dst_img->height;
  2972.             /*
  2973.              * No scaling required since
  2974.              * chrominance is not subsampled.
  2975. @@ -1825,7 +1591,6 @@
  2976.         node->node.GROUP4.B2R2_SBA = in_buf->phys_addr;
  2977.         node->node.GROUP4.B2R2_STY = group4_b2r2_sty;
  2978.  
  2979. -
  2980.         /*
  2981.          * Red chroma (V-component)
  2982.          * The flag B2R2_TTY_CB_NOT_CR actually works
  2983. @@ -2121,19 +1886,9 @@
  2984.                 (B2R2_BLT_FLAG_SOURCE_FILL |
  2985.                 B2R2_BLT_FLAG_SOURCE_FILL_RAW)) != 0;
  2986.  
  2987. -   yuv_planar_dst =
  2988. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  2989. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  2990. -       dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  2991. -       dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  2992. -       dst_fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR;
  2993. -   yuv_semi_planar_dst =
  2994. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  2995. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  2996. -       dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  2997. -       dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  2998. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ||
  2999. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  3000. +   yuv_planar_dst = b2r2_is_ycbcrp_fmt(dst_fmt);
  3001. +   yuv_semi_planar_dst = b2r2_is_ycbcrsp_fmt(dst_fmt) ||
  3002. +       b2r2_is_mb_fmt(dst_fmt);
  3003.  
  3004.     *node_count = 0;
  3005.     *work_buf_width = 0;
  3006. @@ -2428,31 +2183,12 @@
  3007.     const struct b2r2_blt_rect *dst_rect = &(req->user_req.dst_rect);
  3008.     const struct b2r2_blt_rect *src_rect = &(req->user_req.src_rect);
  3009.     const enum b2r2_blt_fmt src_fmt = req->user_req.src_img.fmt;
  3010. -   bool yuv_multi_buffer_src =
  3011. -       src_fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  3012. -       src_fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  3013. -       src_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  3014. -       src_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  3015. -       src_fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR ||
  3016. -       src_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  3017. -       src_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  3018. -       src_fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  3019. -       src_fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  3020. -       src_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ||
  3021. -       src_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  3022. +   const bool yuv_multi_buffer_src = b2r2_is_ycbcrsp_fmt(src_fmt) ||
  3023. +       b2r2_is_ycbcrp_fmt(src_fmt) || b2r2_is_mb_fmt(src_fmt);
  3024.     const enum b2r2_blt_fmt dst_fmt = req->user_req.dst_img.fmt;
  3025. -   const bool yuv_multi_buffer_dst =
  3026. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  3027. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  3028. -       dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  3029. -       dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  3030. -       dst_fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR ||
  3031. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  3032. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  3033. -       dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  3034. -       dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  3035. -       dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE ||
  3036. -       dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  3037. +   const bool yuv_multi_buffer_dst = b2r2_is_ycbcrsp_fmt(dst_fmt) ||
  3038. +       b2r2_is_ycbcrp_fmt(dst_fmt) || b2r2_is_mb_fmt(dst_fmt);
  3039. +
  3040.     s32 h_scf = 1 << 10;
  3041.     s32 v_scf = 1 << 10;
  3042.     s32 src_x = 0;
  3043. @@ -2830,19 +2566,6 @@
  3044.     if (yuv_multi_buffer_dst) {
  3045.         s32 dst_w = dst_rect_area->width;
  3046.         s32 dst_h = dst_rect_area->height;
  3047. -       bool yuv420_dst =
  3048. -           dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  3049. -           dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  3050. -           dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR ||
  3051. -           dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR ||
  3052. -           dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE;
  3053. -
  3054. -       bool yuv422_dst =
  3055. -           dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  3056. -           dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  3057. -           dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR ||
  3058. -           dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR ||
  3059. -           dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE;
  3060.         node = node->next;
  3061.         /* Luma on SRC3 */
  3062.         node->node.GROUP5.B2R2_SXY =
  3063. @@ -2852,7 +2575,7 @@
  3064.             ((dst_w & 0xfff) << B2R2_SZ_WIDTH_SHIFT) |
  3065.             ((dst_h & 0xfff) << B2R2_SZ_HEIGHT_SHIFT);
  3066.  
  3067. -       if (yuv420_dst) {
  3068. +       if (b2r2_is_ycbcr420_fmt(dst_fmt)) {
  3069.             /*
  3070.              * Chroma goes on SRC2 and potentially on SRC1.
  3071.              * Chroma is half the size of luma. Must round up
  3072. @@ -2879,7 +2602,7 @@
  3073.                 node->node.GROUP3.B2R2_SSZ =
  3074.                     node->node.GROUP4.B2R2_SSZ;
  3075.             }
  3076. -       } else if (yuv422_dst) {
  3077. +       } else if (b2r2_is_ycbcr422_fmt(dst_fmt)) {
  3078.             /*
  3079.              * Chroma goes on SRC2 and potentially on SRC1.
  3080.              * Now chroma is half the size of luma
  3081. @@ -3007,11 +2730,7 @@
  3082.         int i = 0;
  3083.         /* Number of nodes required to write chroma output */
  3084.         int n_nodes = 1;
  3085. -       if (dst_fmt == B2R2_BLT_FMT_YUV420_PACKED_PLANAR ||
  3086. -               dst_fmt == B2R2_BLT_FMT_YUV422_PACKED_PLANAR ||
  3087. -               dst_fmt == B2R2_BLT_FMT_YVU420_PACKED_PLANAR ||
  3088. -               dst_fmt == B2R2_BLT_FMT_YVU422_PACKED_PLANAR ||
  3089. -               dst_fmt == B2R2_BLT_FMT_YUV444_PACKED_PLANAR)
  3090. +       if (b2r2_is_ycbcrp_fmt(dst_fmt))
  3091.             n_nodes = 2;
  3092.  
  3093.         node->node.GROUP4.B2R2_SXY = 0;
  3094. diff -ruN a/drivers/video/b2r2/b2r2_input_validation.c b/drivers/video/b2r2/b2r2_input_validation.c
  3095. --- a/drivers/video/b2r2/b2r2_input_validation.c    2012-10-27 17:12:06.326921627 +0900
  3096. +++ b/drivers/video/b2r2/b2r2_input_validation.c    2012-10-24 23:38:23.000000000 +0900
  3097. @@ -75,6 +75,7 @@
  3098.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3099.     case B2R2_BLT_FMT_24_BIT_VUY888:
  3100.     case B2R2_BLT_FMT_32_BIT_VUYA8888:
  3101. +   case B2R2_BLT_FMT_YV12:
  3102.         return true;
  3103.  
  3104.     default:
  3105. @@ -96,6 +97,7 @@
  3106.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  3107.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3108.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  3109. +   case B2R2_BLT_FMT_YV12:
  3110.         return false;
  3111.     default:
  3112.         return true;
  3113. @@ -194,6 +196,7 @@
  3114.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  3115.         return b2r2_align_up(width, 2);
  3116.  
  3117. +   case B2R2_BLT_FMT_YV12:
  3118.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3119.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  3120.         return b2r2_align_up(width, 16);
  3121. @@ -220,6 +223,7 @@
  3122.  
  3123.         break;
  3124.  
  3125. +   case B2R2_BLT_FMT_YV12:
  3126.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3127.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  3128.         if (!b2r2_is_aligned(width, 16))
  3129. @@ -241,6 +245,7 @@
  3130.     case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  3131.     case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  3132.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3133. +   case B2R2_BLT_FMT_YV12:
  3134.         if (!b2r2_is_aligned(height, 2))
  3135.             return false;
  3136.  
  3137. diff -ruN a/drivers/video/b2r2/b2r2_node_split.c b/drivers/video/b2r2/b2r2_node_split.c
  3138. --- a/drivers/video/b2r2/b2r2_node_split.c  2012-10-27 17:12:06.322921580 +0900
  3139. +++ b/drivers/video/b2r2/b2r2_node_split.c  2012-10-24 23:38:23.000000000 +0900
  3140. @@ -2178,7 +2178,8 @@
  3141.     if (upsample) {
  3142.         h_rsf /= 2;
  3143.  
  3144. -       if (b2r2_is_yuv420_fmt(src->fmt))
  3145. +       if (b2r2_is_yuv420_fmt(src->fmt) ||
  3146. +               b2r2_is_yvu420_fmt(src->fmt))
  3147.             v_rsf /= 2;
  3148.     }
  3149.  
  3150. @@ -2187,7 +2188,8 @@
  3151.     if (downsample) {
  3152.         h_rsf *= 2;
  3153.  
  3154. -       if (b2r2_is_yuv420_fmt(dst->fmt))
  3155. +       if (b2r2_is_yuv420_fmt(dst->fmt) ||
  3156. +               b2r2_is_yvu420_fmt(dst->fmt))
  3157.             v_rsf *= 2;
  3158.     }
  3159.  
  3160. @@ -2407,7 +2409,8 @@
  3161.             tmp_buf.win.x >>= 1;
  3162.             tmp_buf.win.width = (tmp_buf.win.width + 1) / 2;
  3163.  
  3164. -           if (b2r2_is_yuv420_fmt(src->fmt)) {
  3165. +           if (b2r2_is_yuv420_fmt(src->fmt) ||
  3166. +                   b2r2_is_yvu420_fmt(src->fmt)) {
  3167.                 tmp_buf.win.height =
  3168.                         (tmp_buf.win.height + 1) / 2;
  3169.                 tmp_buf.win.y >>= 1;
  3170. @@ -2425,7 +2428,8 @@
  3171.              * Each chroma buffer will have half as many values
  3172.              * per line as the luma buffer
  3173.              */
  3174. -           tmp_buf.pitch = (tmp_buf.pitch + 1) / 2;
  3175. +           tmp_buf.pitch = b2r2_get_chroma_pitch(src->pitch,
  3176. +               src->fmt);
  3177.  
  3178.             /* Horizontal resolution is half */
  3179.             tmp_buf.win.x >>= 1;
  3180. @@ -2435,16 +2439,22 @@
  3181.              * If the buffer is in YUV420 format, the vertical
  3182.              * resolution is half as well
  3183.              */
  3184. -           if (b2r2_is_yuv420_fmt(src->fmt)) {
  3185. +           if (b2r2_is_yuv420_fmt(src->fmt) ||
  3186. +                   b2r2_is_yvu420_fmt(src->fmt)) {
  3187.                 tmp_buf.win.height =
  3188.                         (tmp_buf.win.height + 1) / 2;
  3189.                 tmp_buf.win.y >>= 1;
  3190.             }
  3191.         }
  3192.  
  3193. -       set_src_3(node, src->addr, src);                   /* Y */
  3194. -       set_src_2(node, tmp_buf.chroma_addr, &tmp_buf);    /* U */
  3195. -       set_src_1(node, tmp_buf.chroma_cr_addr, &tmp_buf); /* V */
  3196. +       set_src_3(node, src->addr, src);
  3197. +       if (b2r2_is_yvu_fmt(src->fmt)) {
  3198. +           set_src_1(node, tmp_buf.chroma_addr, &tmp_buf);
  3199. +           set_src_2(node, tmp_buf.chroma_cr_addr, &tmp_buf);
  3200. +       } else {
  3201. +           set_src_2(node, tmp_buf.chroma_addr, &tmp_buf);
  3202. +           set_src_1(node, tmp_buf.chroma_cr_addr, &tmp_buf);
  3203. +       }
  3204.  
  3205.         break;
  3206.     default:
  3207. @@ -2564,7 +2574,8 @@
  3208.              * resolution is half as well. Height must be rounded in
  3209.              * the same way as is done for width.
  3210.              */
  3211. -           if (b2r2_is_yuv420_fmt(dst->fmt)) {
  3212. +           if (b2r2_is_yuv420_fmt(dst->fmt) ||
  3213. +                   b2r2_is_yvu420_fmt(dst->fmt)) {
  3214.                 dst_planes[1].win.y /= 2;
  3215.                 dst_planes[1].win.height =
  3216.                     (dst_planes[1].win.height + 1) / 2;
  3217. @@ -2575,10 +2586,8 @@
  3218.             /* There will be a third plane as well */
  3219.             nbr_planes = 3;
  3220.  
  3221. -           if (!b2r2_is_yuv444_fmt(dst->fmt)) {
  3222. -               /* The chroma planes have half the luma pitch */
  3223. -               dst_planes[1].pitch /= 2;
  3224. -           }
  3225. +           dst_planes[1].pitch = b2r2_get_chroma_pitch(
  3226. +               dst->pitch, dst->fmt);
  3227.  
  3228.             memcpy(&dst_planes[2], &dst_planes[1],
  3229.                 sizeof(dst_planes[2]));
  3230. @@ -2764,41 +2773,14 @@
  3231.  
  3232.         switch (buf->type) {
  3233.         case B2R2_FMT_TYPE_SEMI_PLANAR:
  3234. -           buf->chroma_addr = (u32)(((u8 *)addr) +
  3235. -                   buf->pitch * buf->height);
  3236. +           b2r2_get_cb_cr_addr(buf->addr, buf->pitch, buf->height,
  3237. +               buf->fmt, &buf->chroma_addr,
  3238. +               &buf->chroma_addr);
  3239.             break;
  3240.         case B2R2_FMT_TYPE_PLANAR:
  3241. -           if (b2r2_is_yuv422_fmt(buf->fmt) ||
  3242. -                   b2r2_is_yuv420_fmt(buf->fmt)) {
  3243. -               buf->chroma_addr = (u32)(((u8 *)addr) +
  3244. -                   buf->pitch * buf->height);
  3245. -           } else {
  3246. -               buf->chroma_cr_addr = (u32)(((u8 *)addr) +
  3247. -                   buf->pitch * buf->height);
  3248. -           }
  3249. -           if (b2r2_is_yuv420_fmt(buf->fmt)) {
  3250. -               /*
  3251. -                * Use ceil(height/2) in case
  3252. -                * buffer height is not divisible by 2.
  3253. -                */
  3254. -               buf->chroma_cr_addr =
  3255. -                   (u32)(((u8 *)buf->chroma_addr) +
  3256. -                   (buf->pitch >> 1) *
  3257. -                   ((buf->height + 1) >> 1));
  3258. -           } else if (b2r2_is_yuv422_fmt(buf->fmt)) {
  3259. -               buf->chroma_cr_addr =
  3260. -                   (u32)(((u8 *)buf->chroma_addr) +
  3261. -                   (buf->pitch >> 1) * buf->height);
  3262. -           } else if (b2r2_is_yvu420_fmt(buf->fmt)) {
  3263. -               buf->chroma_addr =
  3264. -                   (u32)(((u8 *)buf->chroma_cr_addr) +
  3265. -                   (buf->pitch >> 1) *
  3266. -                   ((buf->height + 1) >> 1));
  3267. -           } else if (b2r2_is_yvu422_fmt(buf->fmt)) {
  3268. -               buf->chroma_addr =
  3269. -                   (u32)(((u8 *)buf->chroma_cr_addr) +
  3270. -                   (buf->pitch >> 1) * buf->height);
  3271. -           }
  3272. +           b2r2_get_cb_cr_addr(buf->addr, buf->pitch, buf->height,
  3273. +               buf->fmt, &buf->chroma_addr,
  3274. +               &buf->chroma_cr_addr);
  3275.             break;
  3276.         default:
  3277.             break;
  3278. diff -ruN a/drivers/video/b2r2/b2r2_utils.c b/drivers/video/b2r2/b2r2_utils.c
  3279. --- a/drivers/video/b2r2/b2r2_utils.c   2012-10-27 17:12:06.302921352 +0900
  3280. +++ b/drivers/video/b2r2/b2r2_utils.c   2012-10-24 23:38:23.000000000 +0900
  3281. @@ -324,6 +324,7 @@
  3282.     case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  3283.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3284.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3285. +   case B2R2_BLT_FMT_YV12:
  3286.         return 12;
  3287.  
  3288.     case B2R2_BLT_FMT_16_BIT_ARGB4444:
  3289. @@ -378,6 +379,7 @@
  3290.     case B2R2_BLT_FMT_32_BIT_AYUV8888:
  3291.     case B2R2_BLT_FMT_24_BIT_VUY888:
  3292.     case B2R2_BLT_FMT_32_BIT_VUYA8888:
  3293. +   case B2R2_BLT_FMT_YV12:
  3294.         return 8;
  3295.  
  3296.     default:
  3297. @@ -476,6 +478,7 @@
  3298.     case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  3299.     case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  3300.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3301. +   case B2R2_BLT_FMT_YV12:
  3302.         return true;
  3303.  
  3304.     default:
  3305. @@ -491,6 +494,7 @@
  3306.     case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  3307.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3308.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3309. +   case B2R2_BLT_FMT_YV12:
  3310.         return true;
  3311.  
  3312.     default:
  3313. @@ -541,6 +545,20 @@
  3314.     }
  3315.  }
  3316.  
  3317. +u32 b2r2_get_chroma_pitch(u32 luma_pitch, enum b2r2_blt_fmt fmt)
  3318. +{
  3319. +   switch (fmt) {
  3320. +   case B2R2_BLT_FMT_YV12:
  3321. +       return b2r2_align_up(luma_pitch >> 1, 16);
  3322. +   case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3323. +   case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3324. +   case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  3325. +       return luma_pitch;
  3326. +   default:
  3327. +       return luma_pitch >> 1;
  3328. +   }
  3329. +}
  3330. +
  3331.  u32 b2r2_calc_pitch_from_width(struct device *dev,
  3332.         s32 width, enum b2r2_blt_fmt fmt)
  3333.  {
  3334. @@ -550,6 +568,9 @@
  3335.     } else if (b2r2_is_ycbcrsp_fmt(fmt) || b2r2_is_ycbcrp_fmt(fmt)) {
  3336.         return (u32)b2r2_div_round_up(width *
  3337.             b2r2_get_fmt_y_bpp(dev, fmt), 8);
  3338. +   } else if (b2r2_is_mb_fmt(fmt)) {
  3339. +       return b2r2_align_up((u32)b2r2_div_round_up(width *
  3340. +           b2r2_get_fmt_y_bpp(dev, fmt), 8), 16);
  3341.     } else {
  3342.         b2r2_log_err(dev, "%s: Internal error! "
  3343.             "Pitchless format supplied.\n",
  3344. @@ -802,6 +823,7 @@
  3345.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3346.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  3347.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3348. +   case B2R2_BLT_FMT_YV12:
  3349.         return true;
  3350.     default:
  3351.         return false;
  3352. @@ -818,6 +840,7 @@
  3353.     case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  3354.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3355.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  3356. +   case B2R2_BLT_FMT_YV12:
  3357.         return true;
  3358.     default:
  3359.         return false;
  3360. @@ -832,9 +855,7 @@
  3361.  
  3362.     switch (fmt) {
  3363.     case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  3364. -   case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  3365.     case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  3366. -   case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3367.     case B2R2_BLT_FMT_YUV420_PACKED_SEMIPLANAR_MB_STE:
  3368.         return true;
  3369.     default:
  3370. @@ -845,11 +866,8 @@
  3371.  bool b2r2_is_yuv422_fmt(enum b2r2_blt_fmt fmt)
  3372.  {
  3373.     switch (fmt) {
  3374. -   case B2R2_BLT_FMT_CB_Y_CR_Y:
  3375.     case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  3376. -   case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  3377.     case B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR:
  3378. -   case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:
  3379.     case B2R2_BLT_FMT_YUV422_PACKED_SEMIPLANAR_MB_STE:
  3380.         return true;
  3381.     default:
  3382. @@ -865,6 +883,7 @@
  3383.     switch (fmt) {
  3384.     case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  3385.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3386. +   case B2R2_BLT_FMT_YV12:
  3387.         return true;
  3388.     default:
  3389.         return false;
  3390. @@ -928,6 +947,7 @@
  3391.     case B2R2_BLT_FMT_YUV422_PACKED_SEMI_PLANAR:       /* Fall through */
  3392.     case B2R2_BLT_FMT_YVU422_PACKED_SEMI_PLANAR:       /* Fall through */
  3393.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3394. +   case B2R2_BLT_FMT_YV12:
  3395.         return width;
  3396.  
  3397.     case B2R2_BLT_FMT_16_BIT_ARGB4444: /* Fall through */
  3398. @@ -1004,6 +1024,7 @@
  3399.     case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  3400.     case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  3401.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3402. +   case B2R2_BLT_FMT_YV12:
  3403.         return B2R2_NATIVE_YUV;
  3404.     default:
  3405.         /* Should never ever happen */
  3406. @@ -1096,6 +1117,7 @@
  3407.     case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  3408.     case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  3409.     case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3410. +   case B2R2_BLT_FMT_YV12:
  3411.         return B2R2_FMT_TYPE_PLANAR;
  3412.     case B2R2_BLT_FMT_YUV420_PACKED_SEMI_PLANAR:
  3413.     case B2R2_BLT_FMT_YVU420_PACKED_SEMI_PLANAR:
  3414. @@ -1405,7 +1427,44 @@
  3415.         return "VUY888";
  3416.     case B2R2_BLT_FMT_32_BIT_VUYA8888:
  3417.         return "VUYA8888";
  3418. +   case B2R2_BLT_FMT_YV12:
  3419. +       return "YV12";
  3420.     default:
  3421.         return "UNKNOWN";
  3422.     }
  3423.  }
  3424. +
  3425. +void b2r2_get_cb_cr_addr(u32 phy_base_addr, u32 luma_pitch, u32 height,
  3426. +       enum b2r2_blt_fmt fmt, u32 *cb_addr, u32 *cr_addr)
  3427. +{
  3428. +   u32 chroma_pitch = b2r2_get_chroma_pitch(luma_pitch, fmt);
  3429. +
  3430. +   if (cr_addr == NULL || cb_addr == NULL)
  3431. +       return;
  3432. +
  3433. +   if (b2r2_is_yvu_fmt(fmt))
  3434. +       *cr_addr = phy_base_addr + luma_pitch * height;
  3435. +   else
  3436. +       *cb_addr = phy_base_addr + luma_pitch * height;
  3437. +
  3438. +   switch (fmt) {
  3439. +   case B2R2_BLT_FMT_YUV420_PACKED_PLANAR:
  3440. +       *cr_addr = *cb_addr + chroma_pitch * (height >> 1);
  3441. +       break;
  3442. +   case B2R2_BLT_FMT_YVU420_PACKED_PLANAR:
  3443. +   case B2R2_BLT_FMT_YV12:
  3444. +       *cb_addr = *cr_addr + chroma_pitch * (height >> 1);
  3445. +       break;
  3446. +   case B2R2_BLT_FMT_YUV422_PACKED_PLANAR:
  3447. +       *cr_addr = *cb_addr + chroma_pitch * height;
  3448. +       break;
  3449. +   case B2R2_BLT_FMT_YVU422_PACKED_PLANAR:
  3450. +       *cb_addr = *cr_addr + chroma_pitch * height;
  3451. +       break;
  3452. +   case B2R2_BLT_FMT_YUV444_PACKED_PLANAR:
  3453. +       *cr_addr = *cb_addr + chroma_pitch * height;
  3454. +       break;
  3455. +   default:
  3456. +       break;
  3457. +   }
  3458. +}
  3459. diff -ruN a/drivers/video/b2r2/b2r2_utils.h b/drivers/video/b2r2/b2r2_utils.h
  3460. --- a/drivers/video/b2r2/b2r2_utils.h   2012-10-27 17:12:06.294921262 +0900
  3461. +++ b/drivers/video/b2r2/b2r2_utils.h   2012-10-24 23:38:23.000000000 +0900
  3462. @@ -77,6 +77,9 @@
  3463.  bool b2r2_is_yvu422_fmt(enum b2r2_blt_fmt fmt);
  3464.  bool b2r2_is_yuv444_fmt(enum b2r2_blt_fmt fmt);
  3465.  int b2r2_fmt_byte_pitch(enum b2r2_blt_fmt fmt, u32 width);
  3466. +u32 b2r2_get_chroma_pitch(u32 luma_pitch, enum b2r2_blt_fmt fmt);
  3467. +void b2r2_get_cb_cr_addr(u32 phy_base_addr, u32 luma_pitch, u32 height,
  3468. +       enum b2r2_blt_fmt fmt, u32 *cb_addr, u32 *cr_addr);
  3469.  enum b2r2_native_fmt b2r2_to_native_fmt(enum b2r2_blt_fmt fmt);
  3470.  u32 b2r2_to_RGB888(u32 color, const enum b2r2_blt_fmt fmt);
  3471.  enum b2r2_fmt_type b2r2_get_fmt_type(enum b2r2_blt_fmt fmt);
  3472. diff -ruN a/drivers/video/mcde/display-av8100.c b/drivers/video/mcde/display-av8100.c
  3473. --- a/drivers/video/mcde/display-av8100.c   2012-10-27 17:12:05.858916283 +0900
  3474. +++ b/drivers/video/mcde/display-av8100.c   2012-10-24 23:38:23.000000000 +0900
  3475. @@ -972,48 +972,34 @@
  3476.         }
  3477.     }
  3478.  
  3479. -   av8100_conf_lock();
  3480. -
  3481.     /*
  3482.      * Don't look at dev->port->hdmi_sdtv_switch; it states only which
  3483.      * one should be started, not which one is currently working
  3484.      */
  3485. -   if (av8100_conf_get(AV8100_COMMAND_HDMI, &av8100_config)) {
  3486. -       ret = -EFAULT;
  3487. -       goto hdmi_set_video_mode_end;
  3488. -   }
  3489. +   if (av8100_conf_get(AV8100_COMMAND_HDMI, &av8100_config))
  3490. +       return -EFAULT;
  3491.     if (av8100_config.hdmi_format.hdmi_mode == AV8100_HDMI_ON) {
  3492.         /* Set HDMI mode to OFF */
  3493.         av8100_config.hdmi_format.hdmi_mode = AV8100_HDMI_OFF;
  3494.         av8100_config.hdmi_format.dvi_format = AV8100_DVI_CTRL_CTL0;
  3495.         av8100_config.hdmi_format.hdmi_format = AV8100_HDMI;
  3496. -       if (av8100_conf_prep(AV8100_COMMAND_HDMI, &av8100_config)) {
  3497. -           ret = -EFAULT;
  3498. -           goto hdmi_set_video_mode_end;
  3499. -       }
  3500. +       if (av8100_conf_prep(AV8100_COMMAND_HDMI, &av8100_config))
  3501. +           return -EFAULT;
  3502.  
  3503.         if (av8100_conf_w(AV8100_COMMAND_HDMI, NULL, NULL,
  3504. -                           I2C_INTERFACE)) {
  3505. -           ret = -EFAULT;
  3506. -           goto hdmi_set_video_mode_end;
  3507. -       }
  3508. -   }
  3509. -   if (av8100_conf_get(AV8100_COMMAND_DENC, &av8100_config)) {
  3510. -       ret = -EFAULT;
  3511. -       goto hdmi_set_video_mode_end;
  3512. +                               I2C_INTERFACE))
  3513. +           return -EFAULT;
  3514.     }
  3515. +   if (av8100_conf_get(AV8100_COMMAND_DENC, &av8100_config))
  3516. +       return -EFAULT;
  3517.     if (av8100_config.denc_format.enable) {
  3518.         /* Turn off DENC */
  3519.         av8100_config.denc_format.enable = 0;
  3520. -       if (av8100_conf_prep(AV8100_COMMAND_DENC, &av8100_config)) {
  3521. -           ret = -EFAULT;
  3522. -           goto hdmi_set_video_mode_end;
  3523. -       }
  3524. +       if (av8100_conf_prep(AV8100_COMMAND_DENC, &av8100_config))
  3525. +           return -EFAULT;
  3526.         if (av8100_conf_w(AV8100_COMMAND_DENC, NULL, NULL,
  3527. -                           I2C_INTERFACE)) {
  3528. -           ret = -EFAULT;
  3529. -           goto hdmi_set_video_mode_end;
  3530. -       }
  3531. +                               I2C_INTERFACE))
  3532. +           return -EFAULT;
  3533.     }
  3534.  
  3535.     /* Get current av8100 video output format */
  3536. @@ -1023,7 +1009,7 @@
  3537.         dev_err(&dev->dev, "%s:av8100_conf_get "
  3538.             "AV8100_COMMAND_VIDEO_OUTPUT_FORMAT failed\n",
  3539.             __func__);
  3540. -       goto hdmi_set_video_mode_end;
  3541. +       return ret;
  3542.     }
  3543.  
  3544.     if (dev->port->hdmi_sdtv_switch == SDTV_SWITCH)
  3545. @@ -1047,7 +1033,7 @@
  3546.         av8100_config.video_output_format.video_output_cea_vesa) {
  3547.         dev_err(&dev->dev, "%s:video output format not found "
  3548.             "\n", __func__);
  3549. -       goto hdmi_set_video_mode_end;
  3550. +       return ret;
  3551.     }
  3552.  
  3553.     ret = av8100_conf_prep(AV8100_COMMAND_VIDEO_OUTPUT_FORMAT,
  3554. @@ -1056,7 +1042,7 @@
  3555.         dev_err(&dev->dev, "%s:av8100_conf_prep "
  3556.             "AV8100_COMMAND_VIDEO_OUTPUT_FORMAT failed\n",
  3557.             __func__);
  3558. -       goto hdmi_set_video_mode_end;
  3559. +       return ret;
  3560.     }
  3561.  
  3562.     /* Get current av8100 video input format */
  3563. @@ -1066,7 +1052,7 @@
  3564.         dev_err(&dev->dev, "%s:av8100_conf_get "
  3565.             "AV8100_COMMAND_VIDEO_INPUT_FORMAT failed\n",
  3566.             __func__);
  3567. -       goto hdmi_set_video_mode_end;
  3568. +       return ret;
  3569.     }
  3570.  
  3571.     /* Set correct av8100 video input pixel format */
  3572. @@ -1121,7 +1107,7 @@
  3573.         dev_err(&dev->dev, "%s:av8100_conf_prep "
  3574.                 "AV8100_COMMAND_VIDEO_INPUT_FORMAT failed\n",
  3575.                 __func__);
  3576. -       goto hdmi_set_video_mode_end;
  3577. +       return ret;
  3578.     }
  3579.  
  3580.     ret = av8100_conf_w(AV8100_COMMAND_VIDEO_INPUT_FORMAT,
  3581. @@ -1130,7 +1116,7 @@
  3582.         dev_err(&dev->dev, "%s:av8100_conf_w "
  3583.                 "AV8100_COMMAND_VIDEO_INPUT_FORMAT failed\n",
  3584.                 __func__);
  3585. -       goto hdmi_set_video_mode_end;
  3586. +       return ret;
  3587.     }
  3588.  
  3589.     if (dev->port->hdmi_sdtv_switch == SDTV_SWITCH) {
  3590. @@ -1155,7 +1141,7 @@
  3591.         dev_err(&dev->dev, "%s:av8100_configuration_prepare "
  3592.             "AV8100_COMMAND_COLORSPACECONVERSION failed\n",
  3593.             __func__);
  3594. -       goto hdmi_set_video_mode_end;
  3595. +       return ret;
  3596.     }
  3597.  
  3598.     ret = av8100_conf_w(
  3599. @@ -1165,7 +1151,7 @@
  3600.         dev_err(&dev->dev, "%s:av8100_conf_w "
  3601.             "AV8100_COMMAND_COLORSPACECONVERSION failed\n",
  3602.             __func__);
  3603. -       goto hdmi_set_video_mode_end;
  3604. +       return ret;
  3605.     }
  3606.  
  3607.     /* Set video output format */
  3608. @@ -1173,7 +1159,7 @@
  3609.         NULL, NULL, I2C_INTERFACE);
  3610.     if (ret) {
  3611.         dev_err(&dev->dev, "av8100_conf_w failed\n");
  3612. -       goto hdmi_set_video_mode_end;
  3613. +       return ret;
  3614.     }
  3615.  
  3616.     /* Set audio input format */
  3617. @@ -1183,16 +1169,13 @@
  3618.         dev_err(&dev->dev, "%s:av8100_conf_w "
  3619.                 "AV8100_COMMAND_AUDIO_INPUT_FORMAT failed\n",
  3620.             __func__);
  3621. -       goto hdmi_set_video_mode_end;
  3622. +       return ret;
  3623.     }
  3624.  
  3625.     dev->update_flags |= UPDATE_FLAG_VIDEO_MODE;
  3626.     dev->first_update = true;
  3627.  
  3628. -hdmi_set_video_mode_end:
  3629. -   av8100_conf_unlock();
  3630. -
  3631. -   return ret;
  3632. +   return 0;
  3633.  }
  3634.  
  3635.  static u16 rotate_byte_left(u8 c, int nr)
  3636. @@ -1281,13 +1264,10 @@
  3637.      * Only one of them should be enabled.
  3638.      * Note HDMI/DVI and DENC are always turned off in set_video_mode.
  3639.      */
  3640. -   av8100_conf_lock();
  3641.     switch (dev->port->hdmi_sdtv_switch) {
  3642.     case SDTV_SWITCH:
  3643. -       if (av8100_conf_get(AV8100_COMMAND_DENC, &av8100_config)) {
  3644. -           ret = -EFAULT;
  3645. -           goto hdmi_on_first_update_end;
  3646. -       }
  3647. +       if (av8100_conf_get(AV8100_COMMAND_DENC, &av8100_config))
  3648. +           return -EFAULT;
  3649.         av8100_config.denc_format.enable = 1;
  3650.         if (dev->video_mode.yres == NATIVE_YRES_SDTV) {
  3651.             av8100_config.denc_format.standard_selection =
  3652. @@ -1320,7 +1300,7 @@
  3653.     if (ret) {
  3654.         dev_err(&dev->dev, "%s:av8100_conf_prep "
  3655.             "AV8100_COMMAND_HDMI/DENC failed\n", __func__);
  3656. -       goto hdmi_on_first_update_end;
  3657. +       return ret;
  3658.     }
  3659.  
  3660.     if (dev->port->hdmi_sdtv_switch == SDTV_SWITCH)
  3661. @@ -1332,16 +1312,12 @@
  3662.     if (ret) {
  3663.         dev_err(&dev->dev, "%s:av8100_conf_w "
  3664.             "AV8100_COMMAND_HDMI/DENC failed\n", __func__);
  3665. -       goto hdmi_on_first_update_end;
  3666. +       return ret;
  3667.     }
  3668. -hdmi_on_first_update_end:
  3669. -   av8100_conf_unlock();
  3670. +
  3671.     return ret;
  3672.  }
  3673.  
  3674. -#define HDMI_GET_RETRY_TIME    500000
  3675. -#define HDMI_GET_RETRY_CNT_MAX 4
  3676. -
  3677.  static int hdmi_set_power_mode(struct mcde_display_device *ddev,
  3678.     enum mcde_display_power_mode power_mode)
  3679.  {
  3680. @@ -1351,9 +1327,6 @@
  3681.     /* OFF -> STANDBY */
  3682.     if (ddev->power_mode == MCDE_DISPLAY_PM_OFF &&
  3683.                     power_mode != MCDE_DISPLAY_PM_OFF) {
  3684. -       int cnt;
  3685. -       int get_res;
  3686. -
  3687.         /*
  3688.          * the regulator for analog TV out is only enabled here,
  3689.          * this means that one needs to switch to the OFF state
  3690. @@ -1368,21 +1341,9 @@
  3691.         ddev->power_mode = MCDE_DISPLAY_PM_STANDBY;
  3692.  
  3693.         /* Get HDMI resource */
  3694. -       for (cnt = 0; cnt < HDMI_GET_RETRY_CNT_MAX; cnt++) {
  3695. -           get_res = av8100_hdmi_get(AV8100_HDMI_USER_VIDEO);
  3696. -           if (get_res >= 0)
  3697. -               break;
  3698. -           else
  3699. -               usleep_range(HDMI_GET_RETRY_TIME,
  3700. -                       HDMI_GET_RETRY_TIME * 12 / 10);
  3701. -       }
  3702. +       av8100_hdmi_get();
  3703.  
  3704. -       if (get_res < 0)
  3705. -           return -EFAULT;
  3706. -       else if (get_res > 1)
  3707. -           av8100_hdmi_video_on();
  3708. -       else
  3709. -           hdmi_set_port_pixel_format(ddev);
  3710. +       hdmi_set_port_pixel_format(ddev);
  3711.     }
  3712.     /* STANDBY -> ON */
  3713.     if (ddev->power_mode == MCDE_DISPLAY_PM_STANDBY &&
  3714. @@ -1403,8 +1364,8 @@
  3715.         memset(&(ddev->video_mode), 0, sizeof(struct mcde_video_mode));
  3716.  
  3717.         /* Put HDMI resource */
  3718. -       if (av8100_hdmi_put(AV8100_HDMI_USER_VIDEO)) {
  3719. -           /* Audio is still used */
  3720. +       if (av8100_hdmi_put()) {
  3721. +           /* Audio is still used; disable video */
  3722.             av8100_hdmi_video_off();
  3723.         }
  3724.  
  3725. diff -ruN a/drivers/video/mcde/logo.c b/drivers/video/mcde/logo.c
  3726. --- a/drivers/video/mcde/logo.c 2012-10-27 17:12:05.890916646 +0900
  3727. +++ b/drivers/video/mcde/logo.c 2012-10-24 23:38:23.000000000 +0900
  3728. @@ -3,6 +3,7 @@
  3729.   * Show Logo in RLE 565 format
  3730.   *
  3731.   * Copyright (C) 2008 Google Incorporated
  3732. + * Copyright (C) 2012 Sony Mobile Communications AB.
  3733.   *
  3734.   * This software is licensed under the terms of the GNU General Public
  3735.   * License version 2, as published by the Free Software Foundation, and
  3736. @@ -113,7 +114,8 @@
  3737.                 unsigned int widepixel = ptr[1];
  3738.                 widepixel = (widepixel & 0xf800) << (19-11) |
  3739.                     (widepixel & 0x07e0) << (10-5) |
  3740. -                   (widepixel & 0x001f) << (3-0);
  3741. +                   (widepixel & 0x001f) << (3-0) |
  3742. +                   0xff000000; /* Set alpha channel*/
  3743.                 memset32(bits, widepixel, j << 2);
  3744.             }
  3745.             bits += j * fb_depth(info);
  3746. diff -ruN a/include/linux/compdev.h b/include/linux/compdev.h
  3747. --- a/include/linux/compdev.h   2012-10-27 17:11:56.614813356 +0900
  3748. +++ b/include/linux/compdev.h   2012-10-24 23:38:23.000000000 +0900
  3749. @@ -43,6 +43,7 @@
  3750.     COMPDEV_FMT_YVU420_SP,
  3751.     COMPDEV_FMT_YUV420_P,
  3752.     COMPDEV_FMT_YVU420_P,
  3753. +   COMPDEV_FMT_YV12,
  3754.  };
  3755.  
  3756.  struct compdev_size {
  3757. diff -ruN a/include/linux/hwmem.h b/include/linux/hwmem.h
  3758. --- a/include/linux/hwmem.h 2012-10-27 17:11:59.354843335 +0900
  3759. +++ b/include/linux/hwmem.h 2012-10-24 23:38:23.000000000 +0900
  3760. @@ -581,6 +581,7 @@
  3761.     phys_addr_t (*get_alloc_paddr)(void *alloc);
  3762.     void *(*get_alloc_kaddr)(void *instance, void *alloc);
  3763.     size_t (*get_alloc_size)(void *alloc);
  3764. +   struct page **(*get_alloc_sglist)(void *alloc);
  3765.  };
  3766.  
  3767.  struct hwmem_mem_type_struct {
  3768. diff -ruN a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h
  3769. --- a/include/linux/mfd/ab8500.h    2012-10-27 17:11:57.662824769 +0900
  3770. +++ b/include/linux/mfd/ab8500.h    2012-10-24 23:38:23.000000000 +0900
  3771. @@ -1,5 +1,6 @@
  3772.  /*
  3773.   * Copyright (C) ST-Ericsson SA 2010
  3774. + * Copyright (C) 2012 Sony Mobile Communications AB.
  3775.   *
  3776.   * License Terms: GNU General Public License v2
  3777.   * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
  3778. @@ -222,6 +223,7 @@
  3779.   * struct ab8500 - ab8500 internal structure
  3780.   * @dev: parent device
  3781.   * @lock: read/write operations lock
  3782. + * @latch_lock: latch array access lock
  3783.   * @irq_lock: genirq bus lock
  3784.   * @transfer_ongoing: 0 if no transfer ongoing
  3785.   * @irq: irq line
  3786. @@ -234,6 +236,7 @@
  3787.   * @tx_buf: tx buf for SPI
  3788.   * @mask: cache of IRQ regs for bus lock
  3789.   * @oldmask: cache of previous IRQ regs for bus lock
  3790. + * @latch: outstanding content of LatchX register
  3791.   * @mask_size: Actual number of valid entries in mask[], oldmask[] and
  3792.   * irq_reg_offset
  3793.   * @irq_reg_offset: Array of offsets into IRQ registers
  3794. @@ -241,6 +244,7 @@
  3795.  struct ab8500 {
  3796.     struct device   *dev;
  3797.     struct mutex    lock;
  3798. +   struct mutex    latch_lock;
  3799.     struct mutex    irq_lock;
  3800.     atomic_t    transfer_ongoing;
  3801.     int     irq_base;
  3802. @@ -257,6 +261,7 @@
  3803.  
  3804.     u8 *mask;
  3805.     u8 *oldmask;
  3806. +   u8 *latch;
  3807.     int mask_size;
  3808.     const int *irq_reg_offset;
  3809.  };
  3810. diff -ruN a/include/video/av8100.h b/include/video/av8100.h
  3811. --- a/include/video/av8100.h    2012-10-27 17:11:55.546801796 +0900
  3812. +++ b/include/video/av8100.h    2012-10-24 23:38:23.000000000 +0900
  3813. @@ -201,11 +201,6 @@
  3814.     AV8100_PATTERN_AUDIO_I2S_MEM
  3815.  };
  3816.  
  3817. -enum av8100_hdmi_user {
  3818. -   AV8100_HDMI_USER_AUDIO,
  3819. -   AV8100_HDMI_USER_VIDEO
  3820. -};
  3821. -
  3822.  struct av8100_video_input_format_cmd {
  3823.     enum av8100_dsi_mode        dsi_input_mode;
  3824.     enum av8100_pixel_format    input_pixel_format;
  3825. @@ -414,12 +409,9 @@
  3826.  
  3827.  int av8100_init(void);
  3828.  void av8100_exit(void);
  3829. -int av8100_hdmi_get(enum av8100_hdmi_user user);
  3830. -int av8100_hdmi_put(enum av8100_hdmi_user user);
  3831. +int av8100_hdmi_get(void);
  3832. +int av8100_hdmi_put(void);
  3833.  int av8100_hdmi_video_off(void);
  3834. -int av8100_hdmi_video_on(void);
  3835. -void av8100_conf_lock(void);
  3836. -void av8100_conf_unlock(void);
  3837.  int av8100_powerwakeup(bool from_scan_mode);
  3838.  int av8100_powerscan(bool to_scan_mode);
  3839.  int av8100_powerup(void);
  3840. diff -ruN a/include/video/b2r2_blt.h b/include/video/b2r2_blt.h
  3841. --- a/include/video/b2r2_blt.h  2012-10-27 17:11:55.554801882 +0900
  3842. +++ b/include/video/b2r2_blt.h  2012-10-24 23:38:23.000000000 +0900
  3843. @@ -161,6 +161,11 @@
  3844.     B2R2_BLT_FMT_24_BIT_VUY888 = 0x7F00000D,
  3845.     B2R2_BLT_FMT_32_BIT_VUYA8888 = 0x7F00000E,
  3846.     B2R2_BLT_FMT_16_BIT_ABGR4444 = 0x7F00000F,
  3847. +   /*
  3848. +    * YV12 is a YVU420P format with alignment requirements
  3849. +    * on luma and chroma stride
  3850. +    */
  3851. +   B2R2_BLT_FMT_YV12 = 0x7F000010,
  3852.  };
  3853.  
  3854.  /**
  3855. diff -ruN a/kernel-build-sin.sh b/kernel-build-sin.sh
  3856. --- a/kernel-build-sin.sh   2012-10-27 17:11:45.306694863 +0900
  3857. +++ b/kernel-build-sin.sh   1970-01-01 09:00:00.000000000 +0900
  3858. @@ -1,102 +0,0 @@
  3859. -#!/bin/bash
  3860. -
  3861. -die () {
  3862. -    echo >&2 "$@"
  3863. -    exit 1
  3864. -}
  3865. -
  3866. -PRODUCT_DEFCNFG=$1
  3867. -FSCONFIG=$2
  3868. -
  3869. -[ "$1" = "" ] && die "product{cdb/hayabusa/..} has to be specified as first argument"
  3870. -[ "$2" = "" ] && die "fsconfig.xml has to be specified as second argument"
  3871. -
  3872. -if [ ! -f "arch/arm/configs/${PRODUCT_DEFCNFG}" ]; then
  3873. -    # instead of specifying blue_cdb_defconfig, it could be 'cdb'
  3874. -    PRODUCT_DEFCNFG=riogrande_${PRODUCT_DEFCNFG}_defconfig
  3875. -fi
  3876. -
  3877. -if [ ! -f "arch/arm/configs/${PRODUCT_DEFCNFG}" ]; then
  3878. -    echo "Please use any of the following products:"
  3879. -    for line in $(ls arch/arm/configs/riogrande_*_defconfig);
  3880. -    do
  3881. -        NAME=$(basename $line)
  3882. -        echo " - $NAME"
  3883. -    done
  3884. -    exit 1
  3885. -fi
  3886. -
  3887. -if [ ! -f "$OUT/ramdisk.img" ]; then
  3888. -    echo "Missing ramdisk.img in $OUT"
  3889. -    exit 1
  3890. -fi
  3891. -
  3892. -echo "Using defconfig ${PRODUCT_DEFCNFG}"
  3893. -
  3894. -#---------------------------------------------------------------------
  3895. -# Check the actual number of CPUs on the machine and adjust the number
  3896. -#---------------------------------------------------------------------
  3897. -CPU_COUNT=`grep "^processor" /proc/cpuinfo | wc -l`
  3898. -if [ $? -eq 0 -a -n "$CPU_COUNT" ] ; then
  3899. -    JOBS=`expr $CPU_COUNT + 1`
  3900. -    echo Found $CPU_COUNT CPUs, building with $JOBS parallel jobs.
  3901. -else
  3902. -    JOBS=5
  3903. -    echo Unable to determine number of CPUs, defaulting to $JOBS parallel jobs.
  3904. -fi
  3905. -
  3906. -#------------------------------------------------------------
  3907. -# Need this to be able to build. Taken from kernel/Android.mk
  3908. -#------------------------------------------------------------
  3909. -export STERICSSON_WLAN_BUILT_IN=y
  3910. -
  3911. -if [ "$3" == "clean" ] ; then
  3912. -    echo 'Cleaning build...'
  3913. -    #-------------------
  3914. -    # Clean up the build
  3915. -    #-------------------
  3916. -    ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- make mrproper
  3917. -fi
  3918. -
  3919. -if [ ! -e ".config" ] ; then
  3920. -    echo 'No .config file, generating...'
  3921. -    #---------------------------
  3922. -    # kernel configuration setup
  3923. -    #---------------------------
  3924. -    ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- make $PRODUCT_DEFCNFG
  3925. -fi
  3926. -
  3927. -#------
  3928. -# Build
  3929. -#------
  3930. -ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- make -j$JOBS
  3931. -
  3932. -if [ $? -ne 0 ] ; then
  3933. -    echo "Build error - skip signing"
  3934. -    exit 1
  3935. -fi
  3936. -
  3937. -#------
  3938. -# Sign
  3939. -#------
  3940. -
  3941. -SIN_PATH=../vendor/semc/build/sin
  3942. -
  3943. -MKELFPY=$SIN_PATH/mkelf.py
  3944. -SEMCSC=$SIN_PATH/semcsc.py
  3945. -CSH=$SIN_PATH/create_sin_header
  3946. -
  3947. -# kernel.elf
  3948. -$MKELFPY -o kernel-unsigned.elf arch/arm/boot/zImage@0x00008000 \
  3949. -    $OUT/ramdisk.img@0x1000000,ramdisk $OUT/cmdline.txt@cmdline
  3950. -
  3951. -$SEMCSC -c $FSCONFIG -p Kernel -t internal -i kernel-unsigned.elf -o kernel.elf
  3952. -
  3953. -# kernel.si_
  3954. -$CSH Kernel $FSCONFIG kernel.si_
  3955. -cat kernel.elf >> kernel.si_
  3956. -
  3957. -# kernel.sin
  3958. -$SEMCSC -c $FSCONFIG -p Kernel -t external -i kernel.si_ -o kernel.sin
  3959. -
  3960. -echo "All done."
  3961. diff -ruN a/net/compat-wireless/drivers/staging/cw1200/ap.c b/net/compat-wireless/drivers/staging/cw1200/ap.c
  3962. --- a/net/compat-wireless/drivers/staging/cw1200/ap.c   2012-10-27 17:11:51.054753987 +0900
  3963. +++ b/net/compat-wireless/drivers/staging/cw1200/ap.c   2012-10-24 23:38:24.000000000 +0900
  3964. @@ -497,6 +497,7 @@
  3965.             priv->delayed_link_loss = 0;
  3966.             spin_lock(&priv->bss_loss_lock);
  3967.             priv->bss_loss_status = CW1200_BSS_LOSS_NONE;
  3968. +           priv->bss_loss_checking = 0;
  3969.             spin_unlock(&priv->bss_loss_lock);
  3970.             cancel_delayed_work_sync(&priv->bss_loss_work);
  3971.             cancel_delayed_work_sync(&priv->connection_loss_work);
  3972. diff -ruN a/net/compat-wireless/drivers/staging/cw1200/cw1200.h b/net/compat-wireless/drivers/staging/cw1200/cw1200.h
  3973. --- a/net/compat-wireless/drivers/staging/cw1200/cw1200.h   2012-10-27 17:11:51.058754029 +0900
  3974. +++ b/net/compat-wireless/drivers/staging/cw1200/cw1200.h   2012-10-24 23:38:24.000000000 +0900
  3975. @@ -61,6 +61,8 @@
  3976.  #define CW1200_JOIN_TIMEOUT        (1 * HZ)
  3977.  #define CW1200_AUTH_TIMEOUT        (5 * HZ)
  3978.  
  3979. +#define BSS_LOSS_CHECKING_MAX_TRY  10
  3980. +
  3981.  /* Please keep order */
  3982.  enum cw1200_join_status {
  3983.     CW1200_JOIN_STATUS_PASSIVE = 0,
  3984. @@ -278,6 +280,7 @@
  3985.     int         delayed_link_loss;
  3986.     spinlock_t      bss_loss_lock;
  3987.     int         bss_loss_status;
  3988. +   int         bss_loss_checking;
  3989.     int         bss_loss_confirm_id;
  3990.  
  3991.     /* TX rate policy cache */
  3992. diff -ruN a/net/compat-wireless/drivers/staging/cw1200/scan.c b/net/compat-wireless/drivers/staging/cw1200/scan.c
  3993. --- a/net/compat-wireless/drivers/staging/cw1200/scan.c 2012-10-27 17:11:51.054753987 +0900
  3994. +++ b/net/compat-wireless/drivers/staging/cw1200/scan.c 2012-10-24 23:38:24.000000000 +0900
  3995. @@ -269,6 +269,7 @@
  3996.                 "beacons.\n", tmo);
  3997.         spin_lock(&priv->bss_loss_lock);
  3998.         priv->bss_loss_status = CW1200_BSS_LOSS_NONE;
  3999. +       priv->bss_loss_checking = 0;
  4000.         spin_unlock(&priv->bss_loss_lock);
  4001.         cancel_delayed_work_sync(&priv->bss_loss_work);
  4002.         queue_delayed_work(priv->workqueue,
  4003. diff -ruN a/net/compat-wireless/drivers/staging/cw1200/sta.c b/net/compat-wireless/drivers/staging/cw1200/sta.c
  4004. --- a/net/compat-wireless/drivers/staging/cw1200/sta.c  2012-10-27 17:11:51.054753987 +0900
  4005. +++ b/net/compat-wireless/drivers/staging/cw1200/sta.c  2012-10-24 23:38:24.000000000 +0900
  4006. @@ -158,6 +158,7 @@
  4007.     priv->delayed_link_loss = 0;
  4008.     spin_lock(&priv->bss_loss_lock);
  4009.     priv->bss_loss_status = CW1200_BSS_LOSS_NONE;
  4010. +   priv->bss_loss_checking = 0;
  4011.     spin_unlock(&priv->bss_loss_lock);
  4012.  
  4013.     priv->join_status = CW1200_JOIN_STATUS_PASSIVE;
  4014. @@ -1102,6 +1103,7 @@
  4015.             priv->delayed_link_loss = 0;
  4016.             spin_lock(&priv->bss_loss_lock);
  4017.             priv->bss_loss_status = CW1200_BSS_LOSS_NONE;
  4018. +           priv->bss_loss_checking = 0;
  4019.             spin_unlock(&priv->bss_loss_lock);
  4020.             cancel_delayed_work_sync(&priv->bss_loss_work);
  4021.             cancel_delayed_work_sync(&priv->connection_loss_work);
  4022. @@ -1168,6 +1170,7 @@
  4023.         return;
  4024.     } else if (priv->bss_loss_status == CW1200_BSS_LOSS_CONFIRMING) {
  4025.         priv->bss_loss_status = CW1200_BSS_LOSS_NONE;
  4026. +       priv->bss_loss_checking = 0;
  4027.         spin_unlock(&priv->bss_loss_lock);
  4028.         return;
  4029.     }
  4030. @@ -1192,6 +1195,7 @@
  4031.  
  4032.     spin_lock(&priv->bss_loss_lock);
  4033.     priv->bss_loss_status = CW1200_BSS_LOSS_NONE;
  4034. +   priv->bss_loss_checking = 0;
  4035.     spin_unlock(&priv->bss_loss_lock);
  4036.  }
  4037.  
  4038. diff -ruN a/net/compat-wireless/drivers/staging/cw1200/txrx.c b/net/compat-wireless/drivers/staging/cw1200/txrx.c
  4039. --- a/net/compat-wireless/drivers/staging/cw1200/txrx.c 2012-10-27 17:11:51.046753902 +0900
  4040. +++ b/net/compat-wireless/drivers/staging/cw1200/txrx.c 2012-10-24 23:38:24.000000000 +0900
  4041. @@ -1041,6 +1041,17 @@
  4042.             ht_flags |= IEEE80211_TX_RC_GREEN_FIELD;
  4043.  
  4044.         if (likely(!arg->status)) {
  4045. +           spin_lock(&priv->bss_loss_lock);
  4046. +           if ((priv->bss_loss_status == CW1200_BSS_LOSS_CONFIRMING) &&
  4047. +               (priv->bss_loss_checking < BSS_LOSS_CHECKING_MAX_TRY)) {
  4048. +               priv->bss_loss_status = CW1200_BSS_LOSS_CHECKING;
  4049. +               priv->bss_loss_checking++;
  4050. +               spin_unlock(&priv->bss_loss_lock);
  4051. +               cancel_delayed_work(&priv->bss_loss_work);
  4052. +               queue_delayed_work(priv->workqueue,
  4053. +                                          &priv->bss_loss_work, 0);
  4054. +           } else
  4055. +               spin_unlock(&priv->bss_loss_lock);
  4056.             tx->flags |= IEEE80211_TX_STAT_ACK;
  4057.             priv->cqm_tx_failure_count = 0;
  4058.             ++tx_count;
  4059. @@ -1059,6 +1070,7 @@
  4060.                     arg->packetID) {
  4061.                 priv->bss_loss_status =
  4062.                     CW1200_BSS_LOSS_CONFIRMED;
  4063. +               priv->bss_loss_checking = 0;
  4064.                 spin_unlock(&priv->bss_loss_lock);
  4065.                 cancel_delayed_work(&priv->bss_loss_work);
  4066.                 queue_delayed_work(priv->workqueue,
  4067. diff -ruN a/sound/soc/codecs/av8100_audio.c b/sound/soc/codecs/av8100_audio.c
  4068. --- a/sound/soc/codecs/av8100_audio.c   2012-10-27 17:11:53.682781797 +0900
  4069. +++ b/sound/soc/codecs/av8100_audio.c   2012-10-24 23:38:24.000000000 +0900
  4070. @@ -179,14 +179,12 @@
  4071.     config.hdmi_format.hdmi_mode = AV8100_HDMI_ON;
  4072.     config.hdmi_format.hdmi_format = AV8100_HDMI;
  4073.     config.hdmi_format.dvi_format = AV8100_DVI_CTRL_CTL0;
  4074. -   av8100_conf_lock();
  4075.     ret = av8100_conf_prep(AV8100_COMMAND_HDMI, &config);
  4076.     if (ret != 0) {
  4077.         pr_err("%s: Setting hdmi_format failed "
  4078.             "(av8100_conf_prep returned %d)!\n",
  4079.             __func__,
  4080.             ret);
  4081. -       av8100_conf_unlock();
  4082.         return -EINVAL;
  4083.     }
  4084.     ret = av8100_conf_w(AV8100_COMMAND_HDMI,
  4085. @@ -198,11 +196,9 @@
  4086.             "(av8100_conf_w returned %d)!\n",
  4087.             __func__,
  4088.             ret);
  4089. -       av8100_conf_unlock();
  4090.         return -EINVAL;
  4091.     }
  4092.  
  4093. -   av8100_conf_unlock();
  4094.     return 0;
  4095.  }
  4096.  
  4097. @@ -262,14 +258,12 @@
  4098.  
  4099.     /* Send audio info-frame */
  4100.     pr_info("%s: Sending audio info-frame.", __func__);
  4101. -   av8100_conf_lock();
  4102.     ret = av8100_conf_prep(AV8100_COMMAND_INFOFRAMES, &config);
  4103.     if (ret != 0) {
  4104.         pr_err("%s: Sending audio info-frame failed "
  4105.             "(av8100_conf_prep returned %d)!\n",
  4106.             __func__,
  4107.             ret);
  4108. -       av8100_conf_unlock();
  4109.         return -EINVAL;
  4110.     }
  4111.     ret = av8100_conf_w(AV8100_COMMAND_INFOFRAMES,
  4112. @@ -281,11 +275,9 @@
  4113.             "(av8100_conf_w returned %d)!\n",
  4114.             __func__,
  4115.             ret);
  4116. -       av8100_conf_unlock();
  4117.         return -EINVAL;
  4118.     }
  4119.  
  4120. -   av8100_conf_unlock();
  4121.     return 0;
  4122.  }
  4123.  
  4124. @@ -310,8 +302,7 @@
  4125.     pr_debug("%s: Enter.\n", __func__);
  4126.  
  4127.     /* Get HDMI resource */
  4128. -   if (av8100_hdmi_get(AV8100_HDMI_USER_AUDIO) < 0)
  4129. -       return -EBUSY;
  4130. +   av8100_hdmi_get();
  4131.  
  4132.     /* Startup AV8100 if it is not already started */
  4133.     ret = av8100_codec_powerup();
  4134. @@ -321,7 +312,7 @@
  4135.             __func__,
  4136.             ret);
  4137.         /* Put HDMI resource */
  4138. -       av8100_hdmi_put(AV8100_HDMI_USER_AUDIO);
  4139. +       av8100_hdmi_put();
  4140.         return -EINVAL;
  4141.     }
  4142.  
  4143. @@ -332,7 +323,7 @@
  4144.                 struct snd_soc_dai *codec_dai)
  4145.  {
  4146.     /* Put HDMI resource */
  4147. -   av8100_hdmi_put(AV8100_HDMI_USER_AUDIO);
  4148. +   av8100_hdmi_put();
  4149.  
  4150.     pr_debug("%s: Enter.\n", __func__);
  4151.  }
  4152. @@ -376,14 +367,12 @@
  4153.     config.audio_input_format.audio_word_lg = AV8100_AUDIO_16BITS;
  4154.     config.audio_input_format.audio_format = AV8100_AUDIO_LPCM_MODE;
  4155.     config.audio_input_format.audio_mute = AV8100_AUDIO_MUTE_DISABLE;
  4156. -   av8100_conf_lock();
  4157.     ret = av8100_conf_prep(AV8100_COMMAND_AUDIO_INPUT_FORMAT, &config);
  4158.     if (ret != 0) {
  4159.         pr_err("%s: Setting audio_input_format failed "
  4160.             "(av8100_conf_prep returned %d)!\n",
  4161.             __func__,
  4162.             ret);
  4163. -       av8100_conf_unlock();
  4164.         return -EINVAL;
  4165.     }
  4166.     ret = av8100_conf_w(AV8100_COMMAND_AUDIO_INPUT_FORMAT,
  4167. @@ -395,11 +384,9 @@
  4168.             "(av8100_conf_w returned %d)!\n",
  4169.             __func__,
  4170.             ret);
  4171. -       av8100_conf_unlock();
  4172. -       return -EINVAL;
  4173. +           return -EINVAL;
  4174.     }
  4175.  
  4176. -   av8100_conf_unlock();
  4177.     return 0;
  4178.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement