Exemplo n.º 1
0
/*
 * csi2_set_outaddr - Set memory address to save output image
 * @csi2: Pointer to ISP CSI2a device.
 * @addr: ISP MMU Mapped 32-bit memory address aligned on 32 byte boundary.
 *
 * Sets the memory address where the output will be saved.
 *
 * Returns 0 if successful, or -EINVAL if the address is not in the 32 byte
 * boundary.
 */
static void csi2_set_outaddr(struct isp_csi2_device *csi2, u32 addr)
{
	struct isp_device *isp = csi2->isp;
	struct isp_csi2_ctx_cfg *ctx = &csi2->contexts[0];

	ctx->ping_addr = ctx->pong_addr = addr;
	isp_reg_writel(isp, ctx->ping_addr,
		       csi2->regs1, ISPCSI2_CTX_DAT_PING_ADDR(ctx->ctxnum));
	isp_reg_writel(isp, ctx->pong_addr,
		       csi2->regs1, ISPCSI2_CTX_DAT_PONG_ADDR(ctx->ctxnum));
}
Exemplo n.º 2
0
/*
 * csi2_ctx_config - CSI2 context configuration.
 * @ctx: context configuration
 *
 */
static void csi2_ctx_config(struct isp_device *isp,
                            struct isp_csi2_device *csi2,
                            struct isp_csi2_ctx_cfg *ctx)
{
    u32 reg;

    /* Set up CSI2_CTx_CTRL1 */
    reg = isp_reg_readl(isp, csi2->regs1, ISPCSI2_CTX_CTRL1(ctx->ctxnum));

    if (ctx->eof_enabled)
        reg |= ISPCSI2_CTX_CTRL1_EOF_EN;
    else
        reg &= ~ISPCSI2_CTX_CTRL1_EOF_EN;

    if (ctx->eol_enabled)
        reg |= ISPCSI2_CTX_CTRL1_EOL_EN;
    else
        reg &= ~ISPCSI2_CTX_CTRL1_EOL_EN;

    if (ctx->checksum_enabled)
        reg |= ISPCSI2_CTX_CTRL1_CS_EN;
    else
        reg &= ~ISPCSI2_CTX_CTRL1_CS_EN;

    isp_reg_writel(isp, reg, csi2->regs1, ISPCSI2_CTX_CTRL1(ctx->ctxnum));

    /* Set up CSI2_CTx_CTRL2 */
    reg = isp_reg_readl(isp, csi2->regs1, ISPCSI2_CTX_CTRL2(ctx->ctxnum));

    reg &= ~(ISPCSI2_CTX_CTRL2_VIRTUAL_ID_MASK);
    reg |= ctx->virtual_id << ISPCSI2_CTX_CTRL2_VIRTUAL_ID_SHIFT;

    reg &= ~(ISPCSI2_CTX_CTRL2_FORMAT_MASK);
    reg |= ctx->format_id << ISPCSI2_CTX_CTRL2_FORMAT_SHIFT;

    if (ctx->dpcm_decompress) {
        if (ctx->dpcm_predictor)
            reg |= ISPCSI2_CTX_CTRL2_DPCM_PRED;
        else
            reg &= ~ISPCSI2_CTX_CTRL2_DPCM_PRED;
    }

    if (is_usr_def_mapping(ctx->format_id)) {
        reg &= ~ISPCSI2_CTX_CTRL2_USER_DEF_MAP_MASK;
        reg |= 2 << ISPCSI2_CTX_CTRL2_USER_DEF_MAP_SHIFT;
    }

    isp_reg_writel(isp, reg, csi2->regs1, ISPCSI2_CTX_CTRL2(ctx->ctxnum));

    /* Set up CSI2_CTx_CTRL3 */
    reg = isp_reg_readl(isp, csi2->regs1, ISPCSI2_CTX_CTRL3(ctx->ctxnum));
    reg &= ~(ISPCSI2_CTX_CTRL3_ALPHA_MASK);
    reg |= (ctx->alpha << ISPCSI2_CTX_CTRL3_ALPHA_SHIFT);

    isp_reg_writel(isp, reg, csi2->regs1, ISPCSI2_CTX_CTRL3(ctx->ctxnum));

    /* Set up CSI2_CTx_DAT_OFST */
    reg = isp_reg_readl(isp, csi2->regs1,
                        ISPCSI2_CTX_DAT_OFST(ctx->ctxnum));
    reg &= ~ISPCSI2_CTX_DAT_OFST_OFST_MASK;
    reg |= ctx->data_offset << ISPCSI2_CTX_DAT_OFST_OFST_SHIFT;
    isp_reg_writel(isp, reg, csi2->regs1,
                   ISPCSI2_CTX_DAT_OFST(ctx->ctxnum));

    isp_reg_writel(isp, ctx->ping_addr,
                   csi2->regs1, ISPCSI2_CTX_DAT_PING_ADDR(ctx->ctxnum));

    isp_reg_writel(isp, ctx->pong_addr,
                   csi2->regs1, ISPCSI2_CTX_DAT_PONG_ADDR(ctx->ctxnum));
}