static int fimc_try_fmt_mplane(struct fimc_ctx *ctx, struct v4l2_format *f) { struct fimc_dev *fimc = ctx->fimc_dev; struct fimc_variant *variant = fimc->variant; struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; struct fimc_fmt *fmt; u32 max_w, mod_x, mod_y; if (!IS_M2M(f->type)) return -EINVAL; dbg("w: %d, h: %d", pix->width, pix->height); fmt = fimc_find_format(&pix->pixelformat, NULL, get_m2m_fmt_flags(f->type), 0); if (WARN(fmt == NULL, "Pixel format lookup failed")) return -EINVAL; if (pix->field == V4L2_FIELD_ANY) pix->field = V4L2_FIELD_NONE; else if (pix->field != V4L2_FIELD_NONE) return -EINVAL; if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { max_w = variant->pix_limit->scaler_dis_w; mod_x = ffs(variant->min_inp_pixsize) - 1; } else { max_w = variant->pix_limit->out_rot_dis_w; mod_x = ffs(variant->min_out_pixsize) - 1; } if (tiled_fmt(fmt)) { mod_x = 6; /* 64 x 32 pixels tile */ mod_y = 5; } else { if (variant->min_vsize_align == 1) mod_y = fimc_fmt_is_rgb(fmt->color) ? 0 : 1; else mod_y = ffs(variant->min_vsize_align) - 1; } v4l_bound_align_image(&pix->width, 16, max_w, mod_x, &pix->height, 8, variant->pix_limit->scaler_dis_w, mod_y, 0); fimc_adjust_mplane_format(fmt, pix->width, pix->height, &f->fmt.pix_mp); return 0; }
void fimc_hw_set_in_dma(struct fimc_ctx *ctx) { struct fimc_dev *dev = ctx->fimc_dev; struct fimc_frame *frame = &ctx->s_frame; struct fimc_dma_offset *offset = &frame->dma_offset; u32 cfg; /* Set the pixel offsets. */ cfg = S5P_CIO_OFFS_HOR(offset->y_h); cfg |= S5P_CIO_OFFS_VER(offset->y_v); writel(cfg, dev->regs + S5P_CIIYOFF); cfg = S5P_CIO_OFFS_HOR(offset->cb_h); cfg |= S5P_CIO_OFFS_VER(offset->cb_v); writel(cfg, dev->regs + S5P_CIICBOFF); cfg = S5P_CIO_OFFS_HOR(offset->cr_h); cfg |= S5P_CIO_OFFS_VER(offset->cr_v); writel(cfg, dev->regs + S5P_CIICROFF); /* Input original and real size. */ fimc_hw_set_in_dma_size(ctx); /* Use DMA autoload only in FIFO mode. */ fimc_hw_en_autoload(dev, ctx->out_path == FIMC_LCDFIFO); /* Set the input DMA to process single frame only. */ cfg = readl(dev->regs + S5P_MSCTRL); cfg &= ~(S5P_MSCTRL_INFORMAT_MASK | S5P_MSCTRL_IN_BURST_COUNT_MASK | S5P_MSCTRL_INPUT_MASK | S5P_MSCTRL_C_INT_IN_MASK | S5P_MSCTRL_2P_IN_ORDER_MASK); cfg |= (S5P_MSCTRL_IN_BURST_COUNT(4) | S5P_MSCTRL_INPUT_MEMORY | S5P_MSCTRL_FIFO_CTRL_FULL); switch (frame->fmt->color) { case S5P_FIMC_RGB565...S5P_FIMC_RGB888: cfg |= S5P_MSCTRL_INFORMAT_RGB; break; case S5P_FIMC_YCBCR420: cfg |= S5P_MSCTRL_INFORMAT_YCBCR420; if (frame->fmt->colplanes == 2) cfg |= ctx->in_order_2p | S5P_MSCTRL_C_INT_IN_2PLANE; else cfg |= S5P_MSCTRL_C_INT_IN_3PLANE; break; case S5P_FIMC_YCBYCR422...S5P_FIMC_CRYCBY422: if (frame->fmt->colplanes == 1) { cfg |= ctx->in_order_1p | S5P_MSCTRL_INFORMAT_YCBCR422_1P; } else { cfg |= S5P_MSCTRL_INFORMAT_YCBCR422; if (frame->fmt->colplanes == 2) cfg |= ctx->in_order_2p | S5P_MSCTRL_C_INT_IN_2PLANE; else cfg |= S5P_MSCTRL_C_INT_IN_3PLANE; } break; default: break; } writel(cfg, dev->regs + S5P_MSCTRL); /* Input/output DMA linear/tiled mode. */ cfg = readl(dev->regs + S5P_CIDMAPARAM); cfg &= ~S5P_CIDMAPARAM_TILE_MASK; if (tiled_fmt(ctx->s_frame.fmt)) cfg |= S5P_CIDMAPARAM_R_64X32; if (tiled_fmt(ctx->d_frame.fmt)) cfg |= S5P_CIDMAPARAM_W_64X32; writel(cfg, dev->regs + S5P_CIDMAPARAM); }