]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/imx-drm/ipu-v3/ipu-common.c
Merge remote-tracking branch 'staging/staging-next'
[karo-tx-linux.git] / drivers / staging / imx-drm / ipu-v3 / ipu-common.c
index 54466df9daf53571d323c760e78ec36074f88cf8..a0e7fc2f40319fbb78a1cdd483f37ffcd122f2fd 100644 (file)
@@ -324,6 +324,14 @@ static const struct ipu_rgb def_rgb_16 = {
        .bits_per_pixel = 16,
 };
 
+static const struct ipu_rgb def_bgr_16 = {
+       .red    = { .offset =  0, .length = 5, },
+       .green  = { .offset =  5, .length = 6, },
+       .blue   = { .offset = 11, .length = 5, },
+       .transp = { .offset =  0, .length = 0, },
+       .bits_per_pixel = 16,
+};
+
 #define Y_OFFSET(pix, x, y)    ((x) + pix->width * (y))
 #define U_OFFSET(pix, x, y)    ((pix->width * pix->height) + \
                                        (pix->width * (y) / 4) + (x) / 2)
@@ -374,6 +382,9 @@ int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, u32 drm_fourcc)
        case DRM_FORMAT_RGB565:
                ipu_cpmem_set_format_rgb(cpmem, &def_rgb_16);
                break;
+       case DRM_FORMAT_BGR565:
+               ipu_cpmem_set_format_rgb(cpmem, &def_bgr_16);
+               break;
        default:
                return -EINVAL;
        }
@@ -687,24 +698,29 @@ int ipu_idmac_enable_channel(struct ipuv3_channel *channel)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_enable_channel);
 
-int ipu_idmac_disable_channel(struct ipuv3_channel *channel)
+int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms)
 {
        struct ipu_soc *ipu = channel->ipu;
-       u32 val;
-       unsigned long flags;
        unsigned long timeout;
 
-       timeout = jiffies + msecs_to_jiffies(50);
+       timeout = jiffies + msecs_to_jiffies(ms);
        while (ipu_idmac_read(ipu, IDMAC_CHA_BUSY(channel->num)) &
                        idma_mask(channel->num)) {
-               if (time_after(jiffies, timeout)) {
-                       dev_warn(ipu->dev, "disabling busy idmac channel %d\n",
-                                       channel->num);
-                       break;
-               }
+               if (time_after(jiffies, timeout))
+                       return -ETIMEDOUT;
                cpu_relax();
        }
 
+       return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_wait_busy);
+
+int ipu_idmac_disable_channel(struct ipuv3_channel *channel)
+{
+       struct ipu_soc *ipu = channel->ipu;
+       u32 val;
+       unsigned long flags;
+
        spin_lock_irqsave(&ipu->lock, flags);
 
        /* Disable DMA channel(s) */
@@ -965,7 +981,7 @@ static const struct ipu_platform_reg client_reg[] = {
                        .dc = 5,
                        .dp = IPU_DP_FLOW_SYNC_BG,
                        .dma[0] = IPUV3_CHANNEL_MEM_BG_SYNC,
-                       .dma[1] = -EINVAL,
+                       .dma[1] = IPUV3_CHANNEL_MEM_FG_SYNC,
                },
                .name = "imx-ipuv3-crtc",
        }, {