/*
 * Copyright 2005 Freescale Semiconductor, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Driver for the Freescale Semiconductor MXC IPU MPEG4/H.264 Post Filter
 *
 */
/*!
 * @defgroup MXC_PF MPEG4/H.264 Post Filter Driver
 */
/*!
 * @file mxc_pf.h
 * 
 * @brief MXC IPU MPEG4/H.264 Post-filtering driver 
 * 
 * User-level API for IPU Hardware MPEG4/H.264 Post-filtering.
 *
 * @ingroup MXC_PF
 */
#ifndef _INCLUDED_MXC_PF_H
#define _INCLUDED_MXC_PF_H


#define PF_MAX_BUFFER_CNT       16
 
/*!
 * Enumeration of buffer allocation modes.
 */
enum pf_memory {
        PF_MEMORY_NONE,
        PF_MEMORY_USERPTR,      /*!< User allocated buffers */
        PF_MEMORY_MMAP,         /*!< Driver allocated buffers */
};


/*!
 * Structure for Post Filter initialization parameters.
 */
typedef struct {
        uint16_t pf_mode;       /*!< Post filter operation mode */
        uint16_t width;         /*!< Width of frame in pixels */
        uint16_t height;        /*!< Height of frame in pixels */
        uint16_t stride;        /*!< Stride of Y plane in pixels. Stride for U and V planes is half Y stride */
        uint32_t qp_size;
        unsigned long qp_paddr;
} pf_init_params;

/*!
 * Structure for Post Filter buffer request parameters.
 */
typedef struct {
        int count;              /*!< Number of buffers requested */
//        enum pf_buffer_type type;/*!< Type of buffer requested */
        enum pf_memory mode;    /*!< Buffer allocation mode requested */
} pf_reqbufs_params;

/*!
 * Structure for Post Filter buffer request parameters.
 */
typedef struct {
        int index;
        int size;               /*!< Size of buffer allocated */
        __u32 offset;
} pf_buf;

/*!
 * Structure for Post Filter start parameters.
 */
typedef struct {
        pf_buf in;             /*!< Input buffer address and offsets */
        pf_buf out;            /*!< Output buffer address and offsets */
        int wait;
        uint32_t h264_pause_row;/*!< Row to pause at for H.264 mode. 0 to disable pause */
} pf_start_params;

/*! @name User Client Ioctl Interface */
/*! @{ */

/*!
 * IOCTL to Initialize the Post Filter.
 */
#define PF_IOCTL_INIT           _IOW('F',0x0, pf_init_params)

/*!
 * IOCTL to Uninitialize the Post Filter.
 */
#define PF_IOCTL_UNINIT         _IO('F',0x1)

/*!
 * IOCTL to set the buffer mode and allocate buffers if driver allocated.
 */
#define PF_IOCTL_REQBUFS        _IOWR('F',0x2, pf_reqbufs_params)

/*!
 * IOCTL to set the buffer mode and allocate buffers if driver allocated.
 */
#define PF_IOCTL_QUERYBUF       _IOR('F',0x2, pf_buf)

/*!
 * IOCTL to start post filtering on a frame of data. This ioctl may block until
 * processing is done or return immediately.
 */
#define PF_IOCTL_START          _IOWR('F',0x3, pf_start_params)

/*!
 * IOCTL to resume post-filtering after an intra frame pause in H.264 mode.
 */
#define PF_IOCTL_RESUME         _IOW('F',0x4, int)

/*!
 * IOCTL to wait for post-filtering to complete.
 */
#define PF_IOCTL_WAIT           _IO('F',0x5)
/*! @} */

#endif /* _INCLUDED_MXC_PF_H */
