Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Register interface file for Samsung Camera Interface (FIMC) driver |
| 3 | * |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 4 | * Copyright (C) 2010 - 2013 Samsung Electronics Co., Ltd. |
| 5 | * Sylwester Nawrocki <s.nawrocki@samsung.com> |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 12 | #include <linux/delay.h> |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 13 | #include <linux/io.h> |
| 14 | #include <linux/regmap.h> |
| 15 | |
Mauro Carvalho Chehab | d647f0b | 2015-11-13 19:40:07 -0200 | [diff] [blame] | 16 | #include <media/drv-intf/exynos-fimc.h> |
Sylwester Nawrocki | 56fa1a6 | 2013-03-24 16:54:25 +0100 | [diff] [blame] | 17 | #include "media-dev.h" |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 18 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 19 | #include "fimc-reg.h" |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 20 | #include "fimc-core.h" |
| 21 | |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 22 | void fimc_hw_reset(struct fimc_dev *dev) |
| 23 | { |
| 24 | u32 cfg; |
| 25 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 26 | cfg = readl(dev->regs + FIMC_REG_CISRCFMT); |
| 27 | cfg |= FIMC_REG_CISRCFMT_ITU601_8BIT; |
| 28 | writel(cfg, dev->regs + FIMC_REG_CISRCFMT); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 29 | |
| 30 | /* Software reset. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 31 | cfg = readl(dev->regs + FIMC_REG_CIGCTRL); |
| 32 | cfg |= (FIMC_REG_CIGCTRL_SWRST | FIMC_REG_CIGCTRL_IRQ_LEVEL); |
| 33 | writel(cfg, dev->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | e9e2108 | 2011-09-02 06:25:32 -0300 | [diff] [blame] | 34 | udelay(10); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 35 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 36 | cfg = readl(dev->regs + FIMC_REG_CIGCTRL); |
| 37 | cfg &= ~FIMC_REG_CIGCTRL_SWRST; |
| 38 | writel(cfg, dev->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 2c1bb62 | 2011-10-05 14:20:45 -0300 | [diff] [blame] | 39 | |
Sylwester Nawrocki | e80cb1f | 2013-03-26 08:22:21 -0300 | [diff] [blame] | 40 | if (dev->drv_data->out_buf_count > 4) |
Sylwester Nawrocki | 2c1bb62 | 2011-10-05 14:20:45 -0300 | [diff] [blame] | 41 | fimc_hw_set_dma_seq(dev, 0xF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 42 | } |
| 43 | |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 44 | static u32 fimc_hw_get_in_flip(struct fimc_ctx *ctx) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 45 | { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 46 | u32 flip = FIMC_REG_MSCTRL_FLIP_NORMAL; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 47 | |
Sylwester Nawrocki | 131b6c6 | 2011-08-24 19:25:10 -0300 | [diff] [blame] | 48 | if (ctx->hflip) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 49 | flip = FIMC_REG_MSCTRL_FLIP_Y_MIRROR; |
Sylwester Nawrocki | 1bc05e7 | 2012-11-26 11:08:26 -0300 | [diff] [blame] | 50 | if (ctx->vflip) |
| 51 | flip = FIMC_REG_MSCTRL_FLIP_X_MIRROR; |
Sylwester Nawrocki | 131b6c6 | 2011-08-24 19:25:10 -0300 | [diff] [blame] | 52 | |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 53 | if (ctx->rotation <= 90) |
| 54 | return flip; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 55 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 56 | return (flip ^ FIMC_REG_MSCTRL_FLIP_180) & FIMC_REG_MSCTRL_FLIP_180; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 57 | } |
| 58 | |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 59 | static u32 fimc_hw_get_target_flip(struct fimc_ctx *ctx) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 60 | { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 61 | u32 flip = FIMC_REG_CITRGFMT_FLIP_NORMAL; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 62 | |
Sylwester Nawrocki | 131b6c6 | 2011-08-24 19:25:10 -0300 | [diff] [blame] | 63 | if (ctx->hflip) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 64 | flip |= FIMC_REG_CITRGFMT_FLIP_Y_MIRROR; |
Sylwester Nawrocki | 1bc05e7 | 2012-11-26 11:08:26 -0300 | [diff] [blame] | 65 | if (ctx->vflip) |
| 66 | flip |= FIMC_REG_CITRGFMT_FLIP_X_MIRROR; |
Sylwester Nawrocki | 131b6c6 | 2011-08-24 19:25:10 -0300 | [diff] [blame] | 67 | |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 68 | if (ctx->rotation <= 90) |
| 69 | return flip; |
| 70 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 71 | return (flip ^ FIMC_REG_CITRGFMT_FLIP_180) & FIMC_REG_CITRGFMT_FLIP_180; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 72 | } |
| 73 | |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 74 | void fimc_hw_set_rotation(struct fimc_ctx *ctx) |
| 75 | { |
| 76 | u32 cfg, flip; |
| 77 | struct fimc_dev *dev = ctx->fimc_dev; |
| 78 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 79 | cfg = readl(dev->regs + FIMC_REG_CITRGFMT); |
| 80 | cfg &= ~(FIMC_REG_CITRGFMT_INROT90 | FIMC_REG_CITRGFMT_OUTROT90 | |
| 81 | FIMC_REG_CITRGFMT_FLIP_180); |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * The input and output rotator cannot work simultaneously. |
| 85 | * Use the output rotator in output DMA mode or the input rotator |
| 86 | * in direct fifo output mode. |
| 87 | */ |
| 88 | if (ctx->rotation == 90 || ctx->rotation == 270) { |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 89 | if (ctx->out_path == FIMC_IO_LCDFIFO) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 90 | cfg |= FIMC_REG_CITRGFMT_INROT90; |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 91 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 92 | cfg |= FIMC_REG_CITRGFMT_OUTROT90; |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 93 | } |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 94 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 95 | if (ctx->out_path == FIMC_IO_DMA) { |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 96 | cfg |= fimc_hw_get_target_flip(ctx); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 97 | writel(cfg, dev->regs + FIMC_REG_CITRGFMT); |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 98 | } else { |
| 99 | /* LCD FIFO path */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 100 | flip = readl(dev->regs + FIMC_REG_MSCTRL); |
| 101 | flip &= ~FIMC_REG_MSCTRL_FLIP_MASK; |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 102 | flip |= fimc_hw_get_in_flip(ctx); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 103 | writel(flip, dev->regs + FIMC_REG_MSCTRL); |
Sylwester Nawrocki | ac75934 | 2010-12-27 14:47:32 -0300 | [diff] [blame] | 104 | } |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 105 | } |
| 106 | |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 107 | void fimc_hw_set_target_format(struct fimc_ctx *ctx) |
| 108 | { |
| 109 | u32 cfg; |
| 110 | struct fimc_dev *dev = ctx->fimc_dev; |
| 111 | struct fimc_frame *frame = &ctx->d_frame; |
| 112 | |
| 113 | dbg("w= %d, h= %d color: %d", frame->width, |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 114 | frame->height, frame->fmt->color); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 115 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 116 | cfg = readl(dev->regs + FIMC_REG_CITRGFMT); |
| 117 | cfg &= ~(FIMC_REG_CITRGFMT_FMT_MASK | FIMC_REG_CITRGFMT_HSIZE_MASK | |
| 118 | FIMC_REG_CITRGFMT_VSIZE_MASK); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 119 | |
| 120 | switch (frame->fmt->color) { |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 121 | case FIMC_FMT_RGB444...FIMC_FMT_RGB888: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 122 | cfg |= FIMC_REG_CITRGFMT_RGB; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 123 | break; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 124 | case FIMC_FMT_YCBCR420: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 125 | cfg |= FIMC_REG_CITRGFMT_YCBCR420; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 126 | break; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 127 | case FIMC_FMT_YCBYCR422...FIMC_FMT_CRYCBY422: |
Sylwester Nawrocki | ef7af59 | 2010-12-08 14:05:08 -0300 | [diff] [blame] | 128 | if (frame->fmt->colplanes == 1) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 129 | cfg |= FIMC_REG_CITRGFMT_YCBCR422_1P; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 130 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 131 | cfg |= FIMC_REG_CITRGFMT_YCBCR422; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 132 | break; |
| 133 | default: |
| 134 | break; |
| 135 | } |
| 136 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 137 | if (ctx->rotation == 90 || ctx->rotation == 270) |
| 138 | cfg |= (frame->height << 16) | frame->width; |
| 139 | else |
| 140 | cfg |= (frame->width << 16) | frame->height; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 141 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 142 | writel(cfg, dev->regs + FIMC_REG_CITRGFMT); |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 143 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 144 | cfg = readl(dev->regs + FIMC_REG_CITAREA); |
| 145 | cfg &= ~FIMC_REG_CITAREA_MASK; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 146 | cfg |= (frame->width * frame->height); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 147 | writel(cfg, dev->regs + FIMC_REG_CITAREA); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static void fimc_hw_set_out_dma_size(struct fimc_ctx *ctx) |
| 151 | { |
| 152 | struct fimc_dev *dev = ctx->fimc_dev; |
| 153 | struct fimc_frame *frame = &ctx->d_frame; |
Sylwester Nawrocki | 47654df | 2010-10-08 05:01:22 -0300 | [diff] [blame] | 154 | u32 cfg; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 155 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 156 | cfg = (frame->f_height << 16) | frame->f_width; |
| 157 | writel(cfg, dev->regs + FIMC_REG_ORGOSIZE); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 158 | |
| 159 | /* Select color space conversion equation (HD/SD size).*/ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 160 | cfg = readl(dev->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 161 | if (frame->f_width >= 1280) /* HD */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 162 | cfg |= FIMC_REG_CIGCTRL_CSC_ITU601_709; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 163 | else /* SD */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 164 | cfg &= ~FIMC_REG_CIGCTRL_CSC_ITU601_709; |
| 165 | writel(cfg, dev->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 166 | |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | void fimc_hw_set_out_dma(struct fimc_ctx *ctx) |
| 170 | { |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 171 | struct fimc_dev *dev = ctx->fimc_dev; |
| 172 | struct fimc_frame *frame = &ctx->d_frame; |
| 173 | struct fimc_dma_offset *offset = &frame->dma_offset; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 174 | struct fimc_fmt *fmt = frame->fmt; |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 175 | u32 cfg; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 176 | |
| 177 | /* Set the input dma offsets. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 178 | cfg = (offset->y_v << 16) | offset->y_h; |
| 179 | writel(cfg, dev->regs + FIMC_REG_CIOYOFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 180 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 181 | cfg = (offset->cb_v << 16) | offset->cb_h; |
| 182 | writel(cfg, dev->regs + FIMC_REG_CIOCBOFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 183 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 184 | cfg = (offset->cr_v << 16) | offset->cr_h; |
| 185 | writel(cfg, dev->regs + FIMC_REG_CIOCROFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 186 | |
| 187 | fimc_hw_set_out_dma_size(ctx); |
| 188 | |
| 189 | /* Configure chroma components order. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 190 | cfg = readl(dev->regs + FIMC_REG_CIOCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 191 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 192 | cfg &= ~(FIMC_REG_CIOCTRL_ORDER2P_MASK | |
| 193 | FIMC_REG_CIOCTRL_ORDER422_MASK | |
| 194 | FIMC_REG_CIOCTRL_YCBCR_PLANE_MASK | |
| 195 | FIMC_REG_CIOCTRL_RGB16FMT_MASK); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 196 | |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 197 | if (fmt->colplanes == 1) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 198 | cfg |= ctx->out_order_1p; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 199 | else if (fmt->colplanes == 2) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 200 | cfg |= ctx->out_order_2p | FIMC_REG_CIOCTRL_YCBCR_2PLANE; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 201 | else if (fmt->colplanes == 3) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 202 | cfg |= FIMC_REG_CIOCTRL_YCBCR_3PLANE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 203 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 204 | if (fmt->color == FIMC_FMT_RGB565) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 205 | cfg |= FIMC_REG_CIOCTRL_RGB565; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 206 | else if (fmt->color == FIMC_FMT_RGB555) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 207 | cfg |= FIMC_REG_CIOCTRL_ARGB1555; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 208 | else if (fmt->color == FIMC_FMT_RGB444) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 209 | cfg |= FIMC_REG_CIOCTRL_ARGB4444; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 210 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 211 | writel(cfg, dev->regs + FIMC_REG_CIOCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | static void fimc_hw_en_autoload(struct fimc_dev *dev, int enable) |
| 215 | { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 216 | u32 cfg = readl(dev->regs + FIMC_REG_ORGISIZE); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 217 | if (enable) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 218 | cfg |= FIMC_REG_CIREAL_ISIZE_AUTOLOAD_EN; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 219 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 220 | cfg &= ~FIMC_REG_CIREAL_ISIZE_AUTOLOAD_EN; |
| 221 | writel(cfg, dev->regs + FIMC_REG_ORGISIZE); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | void fimc_hw_en_lastirq(struct fimc_dev *dev, int enable) |
| 225 | { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 226 | u32 cfg = readl(dev->regs + FIMC_REG_CIOCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 227 | if (enable) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 228 | cfg |= FIMC_REG_CIOCTRL_LASTIRQ_ENABLE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 229 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 230 | cfg &= ~FIMC_REG_CIOCTRL_LASTIRQ_ENABLE; |
| 231 | writel(cfg, dev->regs + FIMC_REG_CIOCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 232 | } |
| 233 | |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 234 | void fimc_hw_set_prescaler(struct fimc_ctx *ctx) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 235 | { |
| 236 | struct fimc_dev *dev = ctx->fimc_dev; |
| 237 | struct fimc_scaler *sc = &ctx->scaler; |
Sylwester Nawrocki | 548aafc | 2010-10-08 05:01:14 -0300 | [diff] [blame] | 238 | u32 cfg, shfactor; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 239 | |
| 240 | shfactor = 10 - (sc->hfactor + sc->vfactor); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 241 | cfg = shfactor << 28; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 242 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 243 | cfg |= (sc->pre_hratio << 16) | sc->pre_vratio; |
| 244 | writel(cfg, dev->regs + FIMC_REG_CISCPRERATIO); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 245 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 246 | cfg = (sc->pre_dst_width << 16) | sc->pre_dst_height; |
| 247 | writel(cfg, dev->regs + FIMC_REG_CISCPREDST); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 248 | } |
| 249 | |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 250 | static void fimc_hw_set_scaler(struct fimc_ctx *ctx) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 251 | { |
| 252 | struct fimc_dev *dev = ctx->fimc_dev; |
| 253 | struct fimc_scaler *sc = &ctx->scaler; |
| 254 | struct fimc_frame *src_frame = &ctx->s_frame; |
| 255 | struct fimc_frame *dst_frame = &ctx->d_frame; |
Sylwester Nawrocki | 2c1bb62 | 2011-10-05 14:20:45 -0300 | [diff] [blame] | 256 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 257 | u32 cfg = readl(dev->regs + FIMC_REG_CISCCTRL); |
Sylwester Nawrocki | 2c1bb62 | 2011-10-05 14:20:45 -0300 | [diff] [blame] | 258 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 259 | cfg &= ~(FIMC_REG_CISCCTRL_CSCR2Y_WIDE | FIMC_REG_CISCCTRL_CSCY2R_WIDE | |
| 260 | FIMC_REG_CISCCTRL_SCALEUP_H | FIMC_REG_CISCCTRL_SCALEUP_V | |
| 261 | FIMC_REG_CISCCTRL_SCALERBYPASS | FIMC_REG_CISCCTRL_ONE2ONE | |
| 262 | FIMC_REG_CISCCTRL_INRGB_FMT_MASK | FIMC_REG_CISCCTRL_OUTRGB_FMT_MASK | |
| 263 | FIMC_REG_CISCCTRL_INTERLACE | FIMC_REG_CISCCTRL_RGB_EXT); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 264 | |
| 265 | if (!(ctx->flags & FIMC_COLOR_RANGE_NARROW)) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 266 | cfg |= (FIMC_REG_CISCCTRL_CSCR2Y_WIDE | |
| 267 | FIMC_REG_CISCCTRL_CSCY2R_WIDE); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 268 | |
| 269 | if (!sc->enabled) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 270 | cfg |= FIMC_REG_CISCCTRL_SCALERBYPASS; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 271 | |
| 272 | if (sc->scaleup_h) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 273 | cfg |= FIMC_REG_CISCCTRL_SCALEUP_H; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 274 | |
| 275 | if (sc->scaleup_v) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 276 | cfg |= FIMC_REG_CISCCTRL_SCALEUP_V; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 277 | |
| 278 | if (sc->copy_mode) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 279 | cfg |= FIMC_REG_CISCCTRL_ONE2ONE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 280 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 281 | if (ctx->in_path == FIMC_IO_DMA) { |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 282 | switch (src_frame->fmt->color) { |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 283 | case FIMC_FMT_RGB565: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 284 | cfg |= FIMC_REG_CISCCTRL_INRGB_FMT_RGB565; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 285 | break; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 286 | case FIMC_FMT_RGB666: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 287 | cfg |= FIMC_REG_CISCCTRL_INRGB_FMT_RGB666; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 288 | break; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 289 | case FIMC_FMT_RGB888: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 290 | cfg |= FIMC_REG_CISCCTRL_INRGB_FMT_RGB888; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 291 | break; |
| 292 | } |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 293 | } |
| 294 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 295 | if (ctx->out_path == FIMC_IO_DMA) { |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 296 | u32 color = dst_frame->fmt->color; |
| 297 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 298 | if (color >= FIMC_FMT_RGB444 && color <= FIMC_FMT_RGB565) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 299 | cfg |= FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB565; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 300 | else if (color == FIMC_FMT_RGB666) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 301 | cfg |= FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB666; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 302 | else if (color == FIMC_FMT_RGB888) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 303 | cfg |= FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB888; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 304 | } else { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 305 | cfg |= FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB888; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 306 | |
| 307 | if (ctx->flags & FIMC_SCAN_MODE_INTERLACED) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 308 | cfg |= FIMC_REG_CISCCTRL_INTERLACE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 309 | } |
| 310 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 311 | writel(cfg, dev->regs + FIMC_REG_CISCCTRL); |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | void fimc_hw_set_mainscaler(struct fimc_ctx *ctx) |
| 315 | { |
| 316 | struct fimc_dev *dev = ctx->fimc_dev; |
Sylwester Nawrocki | 405f230 | 2012-08-02 10:27:46 -0300 | [diff] [blame] | 317 | const struct fimc_variant *variant = dev->variant; |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 318 | struct fimc_scaler *sc = &ctx->scaler; |
| 319 | u32 cfg; |
| 320 | |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 321 | dbg("main_hratio= 0x%X main_vratio= 0x%X", |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 322 | sc->main_hratio, sc->main_vratio); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 323 | |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 324 | fimc_hw_set_scaler(ctx); |
| 325 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 326 | cfg = readl(dev->regs + FIMC_REG_CISCCTRL); |
| 327 | cfg &= ~(FIMC_REG_CISCCTRL_MHRATIO_MASK | |
| 328 | FIMC_REG_CISCCTRL_MVRATIO_MASK); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 329 | |
Sylwester Nawrocki | 70f66ea | 2010-12-28 11:37:55 -0300 | [diff] [blame] | 330 | if (variant->has_mainscaler_ext) { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 331 | cfg |= FIMC_REG_CISCCTRL_MHRATIO_EXT(sc->main_hratio); |
| 332 | cfg |= FIMC_REG_CISCCTRL_MVRATIO_EXT(sc->main_vratio); |
| 333 | writel(cfg, dev->regs + FIMC_REG_CISCCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 334 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 335 | cfg = readl(dev->regs + FIMC_REG_CIEXTEN); |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 336 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 337 | cfg &= ~(FIMC_REG_CIEXTEN_MVRATIO_EXT_MASK | |
| 338 | FIMC_REG_CIEXTEN_MHRATIO_EXT_MASK); |
| 339 | cfg |= FIMC_REG_CIEXTEN_MHRATIO_EXT(sc->main_hratio); |
| 340 | cfg |= FIMC_REG_CIEXTEN_MVRATIO_EXT(sc->main_vratio); |
| 341 | writel(cfg, dev->regs + FIMC_REG_CIEXTEN); |
Sylwester Nawrocki | 70f66ea | 2010-12-28 11:37:55 -0300 | [diff] [blame] | 342 | } else { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 343 | cfg |= FIMC_REG_CISCCTRL_MHRATIO(sc->main_hratio); |
| 344 | cfg |= FIMC_REG_CISCCTRL_MVRATIO(sc->main_vratio); |
| 345 | writel(cfg, dev->regs + FIMC_REG_CISCCTRL); |
Sylwester Nawrocki | 70f66ea | 2010-12-28 11:37:55 -0300 | [diff] [blame] | 346 | } |
Hyunwoong Kim | b241c6d | 2010-12-28 11:27:13 -0300 | [diff] [blame] | 347 | } |
| 348 | |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 349 | void fimc_hw_enable_capture(struct fimc_ctx *ctx) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 350 | { |
| 351 | struct fimc_dev *dev = ctx->fimc_dev; |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 352 | u32 cfg; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 353 | |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 354 | cfg = readl(dev->regs + FIMC_REG_CIIMGCPT); |
| 355 | cfg |= FIMC_REG_CIIMGCPT_CPT_FREN_ENABLE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 356 | |
| 357 | if (ctx->scaler.enabled) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 358 | cfg |= FIMC_REG_CIIMGCPT_IMGCPTEN_SC; |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 359 | else |
| 360 | cfg &= FIMC_REG_CIIMGCPT_IMGCPTEN_SC; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 361 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 362 | cfg |= FIMC_REG_CIIMGCPT_IMGCPTEN; |
| 363 | writel(cfg, dev->regs + FIMC_REG_CIIMGCPT); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 364 | } |
| 365 | |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 366 | void fimc_hw_disable_capture(struct fimc_dev *dev) |
| 367 | { |
| 368 | u32 cfg = readl(dev->regs + FIMC_REG_CIIMGCPT); |
| 369 | cfg &= ~(FIMC_REG_CIIMGCPT_IMGCPTEN | |
| 370 | FIMC_REG_CIIMGCPT_IMGCPTEN_SC); |
| 371 | writel(cfg, dev->regs + FIMC_REG_CIIMGCPT); |
| 372 | } |
| 373 | |
Sylwester Nawrocki | 9448ab7 | 2012-04-02 06:41:22 -0300 | [diff] [blame] | 374 | void fimc_hw_set_effect(struct fimc_ctx *ctx) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 375 | { |
| 376 | struct fimc_dev *dev = ctx->fimc_dev; |
| 377 | struct fimc_effect *effect = &ctx->effect; |
Sylwester Nawrocki | ee7160e | 2011-08-26 14:57:06 -0300 | [diff] [blame] | 378 | u32 cfg = 0; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 379 | |
Sylwester Nawrocki | 9448ab7 | 2012-04-02 06:41:22 -0300 | [diff] [blame] | 380 | if (effect->type != FIMC_REG_CIIMGEFF_FIN_BYPASS) { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 381 | cfg |= FIMC_REG_CIIMGEFF_IE_SC_AFTER | |
| 382 | FIMC_REG_CIIMGEFF_IE_ENABLE; |
Sylwester Nawrocki | ee7160e | 2011-08-26 14:57:06 -0300 | [diff] [blame] | 383 | cfg |= effect->type; |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 384 | if (effect->type == FIMC_REG_CIIMGEFF_FIN_ARBITRARY) |
| 385 | cfg |= (effect->pat_cb << 13) | effect->pat_cr; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 386 | } |
| 387 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 388 | writel(cfg, dev->regs + FIMC_REG_CIIMGEFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 389 | } |
| 390 | |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 391 | void fimc_hw_set_rgb_alpha(struct fimc_ctx *ctx) |
| 392 | { |
| 393 | struct fimc_dev *dev = ctx->fimc_dev; |
| 394 | struct fimc_frame *frame = &ctx->d_frame; |
| 395 | u32 cfg; |
| 396 | |
| 397 | if (!(frame->fmt->flags & FMT_HAS_ALPHA)) |
| 398 | return; |
| 399 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 400 | cfg = readl(dev->regs + FIMC_REG_CIOCTRL); |
| 401 | cfg &= ~FIMC_REG_CIOCTRL_ALPHA_OUT_MASK; |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 402 | cfg |= (frame->alpha << 4); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 403 | writel(cfg, dev->regs + FIMC_REG_CIOCTRL); |
Sylwester Nawrocki | dafb9c7 | 2011-12-01 14:02:24 -0300 | [diff] [blame] | 404 | } |
| 405 | |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 406 | static void fimc_hw_set_in_dma_size(struct fimc_ctx *ctx) |
| 407 | { |
| 408 | struct fimc_dev *dev = ctx->fimc_dev; |
| 409 | struct fimc_frame *frame = &ctx->s_frame; |
| 410 | u32 cfg_o = 0; |
| 411 | u32 cfg_r = 0; |
| 412 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 413 | if (FIMC_IO_LCDFIFO == ctx->out_path) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 414 | cfg_r |= FIMC_REG_CIREAL_ISIZE_AUTOLOAD_EN; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 415 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 416 | cfg_o |= (frame->f_height << 16) | frame->f_width; |
| 417 | cfg_r |= (frame->height << 16) | frame->width; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 418 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 419 | writel(cfg_o, dev->regs + FIMC_REG_ORGISIZE); |
| 420 | writel(cfg_r, dev->regs + FIMC_REG_CIREAL_ISIZE); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | void fimc_hw_set_in_dma(struct fimc_ctx *ctx) |
| 424 | { |
| 425 | struct fimc_dev *dev = ctx->fimc_dev; |
| 426 | struct fimc_frame *frame = &ctx->s_frame; |
| 427 | struct fimc_dma_offset *offset = &frame->dma_offset; |
Sylwester Nawrocki | 548aafc | 2010-10-08 05:01:14 -0300 | [diff] [blame] | 428 | u32 cfg; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 429 | |
| 430 | /* Set the pixel offsets. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 431 | cfg = (offset->y_v << 16) | offset->y_h; |
| 432 | writel(cfg, dev->regs + FIMC_REG_CIIYOFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 433 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 434 | cfg = (offset->cb_v << 16) | offset->cb_h; |
| 435 | writel(cfg, dev->regs + FIMC_REG_CIICBOFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 436 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 437 | cfg = (offset->cr_v << 16) | offset->cr_h; |
| 438 | writel(cfg, dev->regs + FIMC_REG_CIICROFF); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 439 | |
| 440 | /* Input original and real size. */ |
| 441 | fimc_hw_set_in_dma_size(ctx); |
| 442 | |
Sylwester Nawrocki | 548aafc | 2010-10-08 05:01:14 -0300 | [diff] [blame] | 443 | /* Use DMA autoload only in FIFO mode. */ |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 444 | fimc_hw_en_autoload(dev, ctx->out_path == FIMC_IO_LCDFIFO); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 445 | |
| 446 | /* Set the input DMA to process single frame only. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 447 | cfg = readl(dev->regs + FIMC_REG_MSCTRL); |
| 448 | cfg &= ~(FIMC_REG_MSCTRL_INFORMAT_MASK |
| 449 | | FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK |
| 450 | | FIMC_REG_MSCTRL_INPUT_MASK |
| 451 | | FIMC_REG_MSCTRL_C_INT_IN_MASK |
Sylwester Nawrocki | 4397979 | 2013-03-21 14:22:34 -0300 | [diff] [blame] | 452 | | FIMC_REG_MSCTRL_2P_IN_ORDER_MASK |
| 453 | | FIMC_REG_MSCTRL_ORDER422_MASK); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 454 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 455 | cfg |= (FIMC_REG_MSCTRL_IN_BURST_COUNT(4) |
| 456 | | FIMC_REG_MSCTRL_INPUT_MEMORY |
| 457 | | FIMC_REG_MSCTRL_FIFO_CTRL_FULL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 458 | |
| 459 | switch (frame->fmt->color) { |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 460 | case FIMC_FMT_RGB565...FIMC_FMT_RGB888: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 461 | cfg |= FIMC_REG_MSCTRL_INFORMAT_RGB; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 462 | break; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 463 | case FIMC_FMT_YCBCR420: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 464 | cfg |= FIMC_REG_MSCTRL_INFORMAT_YCBCR420; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 465 | |
Sylwester Nawrocki | ef7af59 | 2010-12-08 14:05:08 -0300 | [diff] [blame] | 466 | if (frame->fmt->colplanes == 2) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 467 | cfg |= ctx->in_order_2p | FIMC_REG_MSCTRL_C_INT_IN_2PLANE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 468 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 469 | cfg |= FIMC_REG_MSCTRL_C_INT_IN_3PLANE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 470 | |
| 471 | break; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 472 | case FIMC_FMT_YCBYCR422...FIMC_FMT_CRYCBY422: |
Sylwester Nawrocki | ef7af59 | 2010-12-08 14:05:08 -0300 | [diff] [blame] | 473 | if (frame->fmt->colplanes == 1) { |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 474 | cfg |= ctx->in_order_1p |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 475 | | FIMC_REG_MSCTRL_INFORMAT_YCBCR422_1P; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 476 | } else { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 477 | cfg |= FIMC_REG_MSCTRL_INFORMAT_YCBCR422; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 478 | |
Sylwester Nawrocki | ef7af59 | 2010-12-08 14:05:08 -0300 | [diff] [blame] | 479 | if (frame->fmt->colplanes == 2) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 480 | cfg |= ctx->in_order_2p |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 481 | | FIMC_REG_MSCTRL_C_INT_IN_2PLANE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 482 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 483 | cfg |= FIMC_REG_MSCTRL_C_INT_IN_3PLANE; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 484 | } |
| 485 | break; |
| 486 | default: |
| 487 | break; |
| 488 | } |
| 489 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 490 | writel(cfg, dev->regs + FIMC_REG_MSCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 491 | |
| 492 | /* Input/output DMA linear/tiled mode. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 493 | cfg = readl(dev->regs + FIMC_REG_CIDMAPARAM); |
| 494 | cfg &= ~FIMC_REG_CIDMAPARAM_TILE_MASK; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 495 | |
| 496 | if (tiled_fmt(ctx->s_frame.fmt)) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 497 | cfg |= FIMC_REG_CIDMAPARAM_R_64X32; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 498 | |
| 499 | if (tiled_fmt(ctx->d_frame.fmt)) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 500 | cfg |= FIMC_REG_CIDMAPARAM_W_64X32; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 501 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 502 | writel(cfg, dev->regs + FIMC_REG_CIDMAPARAM); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | |
| 506 | void fimc_hw_set_input_path(struct fimc_ctx *ctx) |
| 507 | { |
| 508 | struct fimc_dev *dev = ctx->fimc_dev; |
| 509 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 510 | u32 cfg = readl(dev->regs + FIMC_REG_MSCTRL); |
| 511 | cfg &= ~FIMC_REG_MSCTRL_INPUT_MASK; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 512 | |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 513 | if (ctx->in_path == FIMC_IO_DMA) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 514 | cfg |= FIMC_REG_MSCTRL_INPUT_MEMORY; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 515 | else |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 516 | cfg |= FIMC_REG_MSCTRL_INPUT_EXTCAM; |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 517 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 518 | writel(cfg, dev->regs + FIMC_REG_MSCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | void fimc_hw_set_output_path(struct fimc_ctx *ctx) |
| 522 | { |
| 523 | struct fimc_dev *dev = ctx->fimc_dev; |
| 524 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 525 | u32 cfg = readl(dev->regs + FIMC_REG_CISCCTRL); |
| 526 | cfg &= ~FIMC_REG_CISCCTRL_LCDPATHEN_FIFO; |
Sylwester Nawrocki | 3d112d9 | 2012-04-26 06:26:29 -0300 | [diff] [blame] | 527 | if (ctx->out_path == FIMC_IO_LCDFIFO) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 528 | cfg |= FIMC_REG_CISCCTRL_LCDPATHEN_FIFO; |
| 529 | writel(cfg, dev->regs + FIMC_REG_CISCCTRL); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | void fimc_hw_set_input_addr(struct fimc_dev *dev, struct fimc_addr *paddr) |
| 533 | { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 534 | u32 cfg = readl(dev->regs + FIMC_REG_CIREAL_ISIZE); |
| 535 | cfg |= FIMC_REG_CIREAL_ISIZE_ADDR_CH_DIS; |
| 536 | writel(cfg, dev->regs + FIMC_REG_CIREAL_ISIZE); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 537 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 538 | writel(paddr->y, dev->regs + FIMC_REG_CIIYSA(0)); |
| 539 | writel(paddr->cb, dev->regs + FIMC_REG_CIICBSA(0)); |
| 540 | writel(paddr->cr, dev->regs + FIMC_REG_CIICRSA(0)); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 541 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 542 | cfg &= ~FIMC_REG_CIREAL_ISIZE_ADDR_CH_DIS; |
| 543 | writel(cfg, dev->regs + FIMC_REG_CIREAL_ISIZE); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 544 | } |
| 545 | |
Sylwester Nawrocki | 548aafc | 2010-10-08 05:01:14 -0300 | [diff] [blame] | 546 | void fimc_hw_set_output_addr(struct fimc_dev *dev, |
| 547 | struct fimc_addr *paddr, int index) |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 548 | { |
Sylwester Nawrocki | 548aafc | 2010-10-08 05:01:14 -0300 | [diff] [blame] | 549 | int i = (index == -1) ? 0 : index; |
| 550 | do { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 551 | writel(paddr->y, dev->regs + FIMC_REG_CIOYSA(i)); |
| 552 | writel(paddr->cb, dev->regs + FIMC_REG_CIOCBSA(i)); |
| 553 | writel(paddr->cr, dev->regs + FIMC_REG_CIOCRSA(i)); |
Sylwester Nawrocki | 548aafc | 2010-10-08 05:01:14 -0300 | [diff] [blame] | 554 | dbg("dst_buf[%d]: 0x%X, cb: 0x%X, cr: 0x%X", |
| 555 | i, paddr->y, paddr->cb, paddr->cr); |
| 556 | } while (index == -1 && ++i < FIMC_MAX_OUT_BUFS); |
Sylwester Nawrocki | 5fd8f73 | 2010-08-03 09:50:29 -0300 | [diff] [blame] | 557 | } |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 558 | |
| 559 | int fimc_hw_set_camera_polarity(struct fimc_dev *fimc, |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 560 | struct fimc_source_info *cam) |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 561 | { |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 562 | u32 cfg = readl(fimc->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 563 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 564 | cfg &= ~(FIMC_REG_CIGCTRL_INVPOLPCLK | FIMC_REG_CIGCTRL_INVPOLVSYNC | |
| 565 | FIMC_REG_CIGCTRL_INVPOLHREF | FIMC_REG_CIGCTRL_INVPOLHSYNC | |
| 566 | FIMC_REG_CIGCTRL_INVPOLFIELD); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 567 | |
Sylwester Nawrocki | 12ecf56 | 2011-09-19 12:38:35 -0300 | [diff] [blame] | 568 | if (cam->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 569 | cfg |= FIMC_REG_CIGCTRL_INVPOLPCLK; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 570 | |
Sylwester Nawrocki | 12ecf56 | 2011-09-19 12:38:35 -0300 | [diff] [blame] | 571 | if (cam->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 572 | cfg |= FIMC_REG_CIGCTRL_INVPOLVSYNC; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 573 | |
Sylwester Nawrocki | 12ecf56 | 2011-09-19 12:38:35 -0300 | [diff] [blame] | 574 | if (cam->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 575 | cfg |= FIMC_REG_CIGCTRL_INVPOLHREF; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 576 | |
Sylwester Nawrocki | 12ecf56 | 2011-09-19 12:38:35 -0300 | [diff] [blame] | 577 | if (cam->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 578 | cfg |= FIMC_REG_CIGCTRL_INVPOLHSYNC; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 579 | |
Sylwester Nawrocki | 12ecf56 | 2011-09-19 12:38:35 -0300 | [diff] [blame] | 580 | if (cam->flags & V4L2_MBUS_FIELD_EVEN_LOW) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 581 | cfg |= FIMC_REG_CIGCTRL_INVPOLFIELD; |
Sylwester Nawrocki | 12ecf56 | 2011-09-19 12:38:35 -0300 | [diff] [blame] | 582 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 583 | writel(cfg, fimc->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 584 | |
| 585 | return 0; |
| 586 | } |
| 587 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 588 | struct mbus_pixfmt_desc { |
| 589 | u32 pixelcode; |
| 590 | u32 cisrcfmt; |
| 591 | u16 bus_width; |
| 592 | }; |
| 593 | |
| 594 | static const struct mbus_pixfmt_desc pix_desc[] = { |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 595 | { MEDIA_BUS_FMT_YUYV8_2X8, FIMC_REG_CISRCFMT_ORDER422_YCBYCR, 8 }, |
| 596 | { MEDIA_BUS_FMT_YVYU8_2X8, FIMC_REG_CISRCFMT_ORDER422_YCRYCB, 8 }, |
| 597 | { MEDIA_BUS_FMT_VYUY8_2X8, FIMC_REG_CISRCFMT_ORDER422_CRYCBY, 8 }, |
| 598 | { MEDIA_BUS_FMT_UYVY8_2X8, FIMC_REG_CISRCFMT_ORDER422_CBYCRY, 8 }, |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 599 | }; |
| 600 | |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 601 | int fimc_hw_set_camera_source(struct fimc_dev *fimc, |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 602 | struct fimc_source_info *source) |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 603 | { |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 604 | struct fimc_vid_cap *vc = &fimc->vid_cap; |
| 605 | struct fimc_frame *f = &vc->ctx->s_frame; |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 606 | u32 bus_width, cfg = 0; |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 607 | int i; |
| 608 | |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 609 | switch (source->fimc_bus_type) { |
| 610 | case FIMC_BUS_TYPE_ITU_601: |
| 611 | case FIMC_BUS_TYPE_ITU_656: |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 612 | for (i = 0; i < ARRAY_SIZE(pix_desc); i++) { |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 613 | if (vc->ci_fmt.code == pix_desc[i].pixelcode) { |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 614 | cfg = pix_desc[i].cisrcfmt; |
| 615 | bus_width = pix_desc[i].bus_width; |
| 616 | break; |
| 617 | } |
| 618 | } |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 619 | |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 620 | if (i == ARRAY_SIZE(pix_desc)) { |
Sylwester Nawrocki | bc7584b | 2013-05-31 11:37:18 -0300 | [diff] [blame] | 621 | v4l2_err(&vc->ve.vdev, |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 622 | "Camera color format not supported: %d\n", |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 623 | vc->ci_fmt.code); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 624 | return -EINVAL; |
| 625 | } |
| 626 | |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 627 | if (source->fimc_bus_type == FIMC_BUS_TYPE_ITU_601) { |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 628 | if (bus_width == 8) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 629 | cfg |= FIMC_REG_CISRCFMT_ITU601_8BIT; |
Sylwester Nawrocki | 3d0ce7e | 2010-12-27 15:02:16 -0300 | [diff] [blame] | 630 | else if (bus_width == 16) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 631 | cfg |= FIMC_REG_CISRCFMT_ITU601_16BIT; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 632 | } /* else defaults to ITU-R BT.656 8-bit */ |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 633 | break; |
| 634 | case FIMC_BUS_TYPE_MIPI_CSI2: |
Sylwester Nawrocki | 14783d2 | 2012-09-24 11:08:45 -0300 | [diff] [blame] | 635 | if (fimc_fmt_is_user_defined(f->fmt->color)) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 636 | cfg |= FIMC_REG_CISRCFMT_ITU601_8BIT; |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 637 | break; |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 638 | default: |
| 639 | case FIMC_BUS_TYPE_ISP_WRITEBACK: |
| 640 | /* Anything to do here ? */ |
| 641 | break; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 642 | } |
| 643 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 644 | cfg |= (f->o_width << 16) | f->o_height; |
| 645 | writel(cfg, fimc->regs + FIMC_REG_CISRCFMT); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 646 | return 0; |
| 647 | } |
| 648 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 649 | void fimc_hw_set_camera_offset(struct fimc_dev *fimc, struct fimc_frame *f) |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 650 | { |
| 651 | u32 hoff2, voff2; |
| 652 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 653 | u32 cfg = readl(fimc->regs + FIMC_REG_CIWDOFST); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 654 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 655 | cfg &= ~(FIMC_REG_CIWDOFST_HOROFF_MASK | FIMC_REG_CIWDOFST_VEROFF_MASK); |
| 656 | cfg |= FIMC_REG_CIWDOFST_OFF_EN | |
| 657 | (f->offs_h << 16) | f->offs_v; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 658 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 659 | writel(cfg, fimc->regs + FIMC_REG_CIWDOFST); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 660 | |
| 661 | /* See CIWDOFSTn register description in the datasheet for details. */ |
| 662 | hoff2 = f->o_width - f->width - f->offs_h; |
| 663 | voff2 = f->o_height - f->height - f->offs_v; |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 664 | cfg = (hoff2 << 16) | voff2; |
| 665 | writel(cfg, fimc->regs + FIMC_REG_CIWDOFST2); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | int fimc_hw_set_camera_type(struct fimc_dev *fimc, |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 669 | struct fimc_source_info *source) |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 670 | { |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 671 | struct fimc_vid_cap *vid_cap = &fimc->vid_cap; |
Sylwester Nawrocki | 20676a4 | 2012-03-21 06:21:30 -0300 | [diff] [blame] | 672 | u32 csis_data_alignment = 32; |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 673 | u32 cfg, tmp; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 674 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 675 | cfg = readl(fimc->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 676 | |
| 677 | /* Select ITU B interface, disable Writeback path and test pattern. */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 678 | cfg &= ~(FIMC_REG_CIGCTRL_TESTPAT_MASK | FIMC_REG_CIGCTRL_SELCAM_ITU_A | |
| 679 | FIMC_REG_CIGCTRL_SELCAM_MIPI | FIMC_REG_CIGCTRL_CAMIF_SELWB | |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 680 | FIMC_REG_CIGCTRL_SELCAM_MIPI_A | FIMC_REG_CIGCTRL_CAM_JPEG | |
| 681 | FIMC_REG_CIGCTRL_SELWB_A); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 682 | |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 683 | switch (source->fimc_bus_type) { |
| 684 | case FIMC_BUS_TYPE_MIPI_CSI2: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 685 | cfg |= FIMC_REG_CIGCTRL_SELCAM_MIPI; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 686 | |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 687 | if (source->mux_id == 0) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 688 | cfg |= FIMC_REG_CIGCTRL_SELCAM_MIPI_A; |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 689 | |
| 690 | /* TODO: add remaining supported formats. */ |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 691 | switch (vid_cap->ci_fmt.code) { |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 692 | case MEDIA_BUS_FMT_VYUY8_2X8: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 693 | tmp = FIMC_REG_CSIIMGFMT_YCBCR422_8BIT; |
Sylwester Nawrocki | ee7160e | 2011-08-26 14:57:06 -0300 | [diff] [blame] | 694 | break; |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 695 | case MEDIA_BUS_FMT_JPEG_1X8: |
| 696 | case MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 697 | tmp = FIMC_REG_CSIIMGFMT_USER(1); |
| 698 | cfg |= FIMC_REG_CIGCTRL_CAM_JPEG; |
Sylwester Nawrocki | ee7160e | 2011-08-26 14:57:06 -0300 | [diff] [blame] | 699 | break; |
| 700 | default: |
Sylwester Nawrocki | bc7584b | 2013-05-31 11:37:18 -0300 | [diff] [blame] | 701 | v4l2_err(&vid_cap->ve.vdev, |
Sachin Kamat | a516d08 | 2012-06-12 03:12:26 -0300 | [diff] [blame] | 702 | "Not supported camera pixel format: %#x\n", |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 703 | vid_cap->ci_fmt.code); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 704 | return -EINVAL; |
| 705 | } |
Sylwester Nawrocki | 20676a4 | 2012-03-21 06:21:30 -0300 | [diff] [blame] | 706 | tmp |= (csis_data_alignment == 32) << 8; |
Sylwester Nawrocki | e0eec9a | 2011-02-21 12:09:01 -0300 | [diff] [blame] | 707 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 708 | writel(tmp, fimc->regs + FIMC_REG_CSIIMGFMT); |
Sylwester Nawrocki | 31ce54f | 2012-07-24 12:06:26 -0300 | [diff] [blame] | 709 | break; |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 710 | case FIMC_BUS_TYPE_ITU_601...FIMC_BUS_TYPE_ITU_656: |
| 711 | if (source->mux_id == 0) /* ITU-A, ITU-B: 0, 1 */ |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 712 | cfg |= FIMC_REG_CIGCTRL_SELCAM_ITU_A; |
Sylwester Nawrocki | 31ce54f | 2012-07-24 12:06:26 -0300 | [diff] [blame] | 713 | break; |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 714 | case FIMC_BUS_TYPE_LCD_WRITEBACK_A: |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 715 | cfg |= FIMC_REG_CIGCTRL_CAMIF_SELWB; |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 716 | /* fall through */ |
| 717 | case FIMC_BUS_TYPE_ISP_WRITEBACK: |
| 718 | if (fimc->variant->has_isp_wb) |
| 719 | cfg |= FIMC_REG_CIGCTRL_CAMIF_SELWB; |
| 720 | else |
| 721 | WARN_ONCE(1, "ISP Writeback input is not supported\n"); |
Sylwester Nawrocki | 31ce54f | 2012-07-24 12:06:26 -0300 | [diff] [blame] | 722 | break; |
| 723 | default: |
Sylwester Nawrocki | bc7584b | 2013-05-31 11:37:18 -0300 | [diff] [blame] | 724 | v4l2_err(&vid_cap->ve.vdev, |
| 725 | "Invalid FIMC bus type selected: %d\n", |
Sylwester Nawrocki | 56bc911 | 2013-02-01 15:00:40 -0300 | [diff] [blame] | 726 | source->fimc_bus_type); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 727 | return -EINVAL; |
| 728 | } |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 729 | writel(cfg, fimc->regs + FIMC_REG_CIGCTRL); |
Sylwester Nawrocki | 5f3cc44 | 2010-10-07 10:06:16 -0300 | [diff] [blame] | 730 | |
| 731 | return 0; |
| 732 | } |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 733 | |
| 734 | void fimc_hw_clear_irq(struct fimc_dev *dev) |
| 735 | { |
| 736 | u32 cfg = readl(dev->regs + FIMC_REG_CIGCTRL); |
| 737 | cfg |= FIMC_REG_CIGCTRL_IRQ_CLR; |
| 738 | writel(cfg, dev->regs + FIMC_REG_CIGCTRL); |
| 739 | } |
| 740 | |
| 741 | void fimc_hw_enable_scaler(struct fimc_dev *dev, bool on) |
| 742 | { |
| 743 | u32 cfg = readl(dev->regs + FIMC_REG_CISCCTRL); |
| 744 | if (on) |
| 745 | cfg |= FIMC_REG_CISCCTRL_SCALERSTART; |
| 746 | else |
| 747 | cfg &= ~FIMC_REG_CISCCTRL_SCALERSTART; |
| 748 | writel(cfg, dev->regs + FIMC_REG_CISCCTRL); |
| 749 | } |
| 750 | |
| 751 | void fimc_hw_activate_input_dma(struct fimc_dev *dev, bool on) |
| 752 | { |
| 753 | u32 cfg = readl(dev->regs + FIMC_REG_MSCTRL); |
| 754 | if (on) |
| 755 | cfg |= FIMC_REG_MSCTRL_ENVID; |
| 756 | else |
| 757 | cfg &= ~FIMC_REG_MSCTRL_ENVID; |
| 758 | writel(cfg, dev->regs + FIMC_REG_MSCTRL); |
| 759 | } |
| 760 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 761 | /* Return an index to the buffer actually being written. */ |
Sylwester Nawrocki | 14783d2 | 2012-09-24 11:08:45 -0300 | [diff] [blame] | 762 | s32 fimc_hw_get_frame_index(struct fimc_dev *dev) |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 763 | { |
Sylwester Nawrocki | 14783d2 | 2012-09-24 11:08:45 -0300 | [diff] [blame] | 764 | s32 reg; |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 765 | |
Sylwester Nawrocki | e80cb1f | 2013-03-26 08:22:21 -0300 | [diff] [blame] | 766 | if (dev->drv_data->cistatus2) { |
Sylwester Nawrocki | 14783d2 | 2012-09-24 11:08:45 -0300 | [diff] [blame] | 767 | reg = readl(dev->regs + FIMC_REG_CISTATUS2) & 0x3f; |
| 768 | return reg - 1; |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | reg = readl(dev->regs + FIMC_REG_CISTATUS); |
| 772 | |
| 773 | return (reg & FIMC_REG_CISTATUS_FRAMECNT_MASK) >> |
| 774 | FIMC_REG_CISTATUS_FRAMECNT_SHIFT; |
| 775 | } |
| 776 | |
Sylwester Nawrocki | 14783d2 | 2012-09-24 11:08:45 -0300 | [diff] [blame] | 777 | /* Return an index to the buffer being written previously. */ |
| 778 | s32 fimc_hw_get_prev_frame_index(struct fimc_dev *dev) |
| 779 | { |
| 780 | s32 reg; |
| 781 | |
Sylwester Nawrocki | e80cb1f | 2013-03-26 08:22:21 -0300 | [diff] [blame] | 782 | if (!dev->drv_data->cistatus2) |
Sylwester Nawrocki | 14783d2 | 2012-09-24 11:08:45 -0300 | [diff] [blame] | 783 | return -1; |
| 784 | |
| 785 | reg = readl(dev->regs + FIMC_REG_CISTATUS2); |
| 786 | return ((reg >> 7) & 0x3f) - 1; |
| 787 | } |
| 788 | |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 789 | /* Locking: the caller holds fimc->slock */ |
| 790 | void fimc_activate_capture(struct fimc_ctx *ctx) |
| 791 | { |
| 792 | fimc_hw_enable_scaler(ctx->fimc_dev, ctx->scaler.enabled); |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 793 | fimc_hw_enable_capture(ctx); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | void fimc_deactivate_capture(struct fimc_dev *fimc) |
| 797 | { |
| 798 | fimc_hw_en_lastirq(fimc, true); |
Sylwester Nawrocki | 35f2924 | 2012-11-22 14:01:39 -0300 | [diff] [blame] | 799 | fimc_hw_disable_capture(fimc); |
Sylwester Nawrocki | c83a1ff | 2012-05-02 06:14:49 -0300 | [diff] [blame] | 800 | fimc_hw_enable_scaler(fimc, false); |
| 801 | fimc_hw_en_lastirq(fimc, false); |
| 802 | } |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 803 | |
| 804 | int fimc_hw_camblk_cfg_writeback(struct fimc_dev *fimc) |
| 805 | { |
| 806 | struct regmap *map = fimc->sysreg; |
| 807 | unsigned int mask, val, camblk_cfg; |
| 808 | int ret; |
| 809 | |
Sylwester Nawrocki | b3d8b55 | 2013-03-31 20:31:02 -0300 | [diff] [blame] | 810 | if (map == NULL) |
| 811 | return 0; |
| 812 | |
Sylwester Nawrocki | 88fa831 | 2013-03-20 10:44:39 -0300 | [diff] [blame] | 813 | ret = regmap_read(map, SYSREG_CAMBLK, &camblk_cfg); |
| 814 | if (ret < 0 || ((camblk_cfg & 0x00700000) >> 20 != 0x3)) |
| 815 | return ret; |
| 816 | |
| 817 | if (!WARN(fimc->id >= 3, "not supported id: %d\n", fimc->id)) |
| 818 | val = 0x1 << (fimc->id + 20); |
| 819 | else |
| 820 | val = 0; |
| 821 | |
| 822 | mask = SYSREG_CAMBLK_FIFORST_ISP | SYSREG_CAMBLK_ISPWB_FULL_EN; |
| 823 | ret = regmap_update_bits(map, SYSREG_CAMBLK, mask, val); |
| 824 | if (ret < 0) |
| 825 | return ret; |
| 826 | |
| 827 | usleep_range(1000, 2000); |
| 828 | |
| 829 | val |= SYSREG_CAMBLK_FIFORST_ISP; |
| 830 | ret = regmap_update_bits(map, SYSREG_CAMBLK, mask, val); |
| 831 | if (ret < 0) |
| 832 | return ret; |
| 833 | |
| 834 | mask = SYSREG_ISPBLK_FIFORST_CAM_BLK; |
| 835 | ret = regmap_update_bits(map, SYSREG_ISPBLK, mask, ~mask); |
| 836 | if (ret < 0) |
| 837 | return ret; |
| 838 | |
| 839 | usleep_range(1000, 2000); |
| 840 | |
| 841 | return regmap_update_bits(map, SYSREG_ISPBLK, mask, mask); |
| 842 | } |