Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static int mxc_pf_init ( pf_init_params pf_init  )  [static]

This function handles PF_IOCTL_INIT calls. It initializes the PF channels, interrupt handlers, and channel buffers.

Returns:
This function returns 0 on success or negative error code on error.

Definition at line 88 of file mxc_pf.c.

References pf_init_params::height, ipu_channel_params_t::mem_pf_mem, ipu_channel_params_t::operation, pf_init_params::pf_mode, pf_init_params::qp_paddr, pf_init_params::qp_size, pf_init_params::stride, and pf_init_params::width.

Referenced by mxc_pf_ioctl().

{
      int err;
      ipu_channel_params_t params;
      u32 w;
      u32 stride;
      u32 h;
      u32 qp_size = 0;
      u32 qp_stride;

      if ((pf_init->pf_mode > 4) || (pf_init->width > 1024) ||
          (pf_init->height > 1024) || (pf_init->stride < pf_init->width)) {
            return -EINVAL;
      }

      pf_data.mode = pf_init->pf_mode;
      w = pf_data.width = pf_init->width;
      h = pf_data.height = pf_init->height;
      stride = pf_data.stride = pf_init->stride;
      pf_data.qp_size = pf_init->qp_size;

      memset(&params, 0, sizeof(params));
      params.mem_pf_mem.operation = pf_data.mode;
      err = ipu_init_channel(MEM_PF_Y_MEM, &params);
      if (err < 0) {
            printk(KERN_ERR "mxc_pf: error initializing channel\n");
            goto err0;
      }

      err = ipu_init_channel_buffer(MEM_PF_Y_MEM, IPU_INPUT_BUFFER,
                              IPU_PIX_FMT_GENERIC, w, h, stride,
                              IPU_ROTATE_NONE, 0, 0, 0, 0);
      if (err < 0) {
            printk(KERN_ERR "mxc_pf: error initializing Y input buffer\n");
            goto err0;
      }

      err = ipu_init_channel_buffer(MEM_PF_Y_MEM, IPU_OUTPUT_BUFFER,
                              IPU_PIX_FMT_GENERIC, w, h, stride,
                              IPU_ROTATE_NONE, 0, 0, 0, 0);
      if (err < 0) {
            printk(KERN_ERR "mxc_pf: error initializing Y output buffer\n");
            goto err0;
      }

      w = w / 2;
      h = h / 2;
      stride = stride / 2;

      if (pf_data.mode != PF_MPEG4_DERING) {
            err = ipu_init_channel_buffer(MEM_PF_U_MEM, IPU_INPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC, w, h, stride,
                                    IPU_ROTATE_NONE, 0, 0, 0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing U input buffer\n");
                  goto err0;
            }

            err = ipu_init_channel_buffer(MEM_PF_U_MEM, IPU_OUTPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC, w, h, stride,
                                    IPU_ROTATE_NONE, 0, 0, 0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing U output buffer\n");
                  goto err0;
            }

            err = ipu_init_channel_buffer(MEM_PF_V_MEM, IPU_INPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC, w, h, stride,
                                    IPU_ROTATE_NONE, 0, 0, 0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing V input buffer\n");
                  goto err0;
            }

            err = ipu_init_channel_buffer(MEM_PF_V_MEM, IPU_OUTPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC, w, h, stride,
                                    IPU_ROTATE_NONE, 0, 0, 0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing V output buffer\n");
                  goto err0;
            }
      }

      /*Setup Channel QF and BSC Params */
      if (pf_data.mode == PF_H264_DEBLOCK) {
            w = ((pf_data.width + 15) / 16);
            h = (pf_data.height + 15) / 16;
            qp_stride = w;
            qp_size = 4 * qp_stride * h;
            pr_debug("H264 QP width = %d, height = %d\n", w, h);
            err = ipu_init_channel_buffer(MEM_PF_Y_MEM,
                                    IPU_SEC_INPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC_32, w, h,
                                    qp_stride, IPU_ROTATE_NONE, 0, 0,
                                    0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing H264 QP buffer\n");
                  goto err0;
            }
/*                w = (pf_data.width + 3) / 4; */
            w *= 4;
            h *= 4;
            qp_stride = w;
            err = ipu_init_channel_buffer(MEM_PF_U_MEM,
                                    IPU_SEC_INPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC, w, h,
                                    qp_stride, IPU_ROTATE_NONE, 0, 0,
                                    0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing H264 BSB buffer\n");
                  goto err0;
            }
            qp_size += qp_stride * h;
      } else {          /* MPEG4 mode */

            w = (pf_data.width + 15) / 16;
            h = (pf_data.height + 15) / 16;
            qp_stride = (w + 3) & ~0x3UL;
            pr_debug("MPEG4 QP width = %d, height = %d, stride = %d\n",
                   w, h, qp_stride);
            err = ipu_init_channel_buffer(MEM_PF_Y_MEM,
                                    IPU_SEC_INPUT_BUFFER,
                                    IPU_PIX_FMT_GENERIC, w, h,
                                    qp_stride, IPU_ROTATE_NONE, 0, 0,
                                    0, 0);
            if (err < 0) {
                  printk(KERN_ERR
                         "mxc_pf: error initializing MPEG4 QP buffer\n");
                  goto err0;
            }
            qp_size = qp_stride * h;
      }

      /* Support 2 QP buffers */
      qp_size *= 2;

      if (pf_data.qp_size > qp_size)
            qp_size = pf_data.qp_size;
      else
            pf_data.qp_size = qp_size;

      pf_data.qp_vaddr = dma_alloc_coherent(NULL, pf_data.qp_size,
                                    &pf_data.qp_paddr,
                                    GFP_KERNEL | GFP_DMA);
      if (!pf_data.qp_vaddr)
            return -ENOMEM;

      pf_init->qp_paddr = pf_data.qp_paddr;
      pf_init->qp_size = pf_data.qp_size;

      return 0;

      err0:
      return err;
}


Generated by  Doxygen 1.6.0   Back to index