linux/drivers/media/pci/zoran/videocodec.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * VIDEO MOTION CODECs internal API for video devices
 *
 * Interface for MJPEG (and maybe later MPEG/WAVELETS) codec's
 * bound to a master device.
 *
 * (c) 2002 Wolfgang Scherr <[email protected]>
 */

/* =================== */
/* general description */
/* =================== */

/*
 * Should ease the (re-)usage of drivers supporting cards with (different)
 * video codecs. The codecs register to this module their functionality,
 * and the processors (masters) can attach to them if they fit.
 *
 * The codecs are typically have a "strong" binding to their master - so I
 * don't think it makes sense to have a full blown interfacing as with e.g.
 * i2c. If you have an other opinion, let's discuss & implement it :-)))
 *
 * Usage:
 *
 * The slave has just to setup the videocodec structure and use two functions:
 * videocodec_register(codecdata);
 * videocodec_unregister(codecdata);
 * The best is just calling them at module (de-)initialisation.
 *
 * The master sets up the structure videocodec_master and calls:
 * codecdata=videocodec_attach(master_codecdata);
 * videocodec_detach(codecdata);
 *
 * The slave is called during attach/detach via functions setup previously
 * during register. At that time, the master_data pointer is set up
 * and the slave can access any io registers of the master device (in the case
 * the slave is bound to it). Otherwise it doesn't need this functions and
 * therefor they may not be initialized.
 *
 * The other functions are just for convenience, as they are for sure used by
 * most/all of the codecs. The last ones may be omitted, too.
 *
 * See the structure declaration below for more information and which data has
 * to be set up for the master and the slave.
 *
 * ----------------------------------------------------------------------------
 * The master should have "knowledge" of the slave and vice versa.  So the data
 * structures sent to/from slave via set_data/get_data set_image/get_image are
 * device dependent and vary between MJPEG/MPEG/WAVELET/... devices. (!!!!)
 * ----------------------------------------------------------------------------
 */

/* ========================================== */
/* description of the videocodec_io structure */
/* ========================================== */

/*
 * ==== master setup ====
 * name -> name of the device structure for reference and debugging
 * master_data ->  data ref. for the master (e.g. the zr36055,57,67)
 * readreg -> ref. to read-fn from register (setup by master, used by slave)
 * writereg -> ref. to write-fn to register (setup by master, used by slave)
 *	       this two functions do the lowlevel I/O job
 *
 * ==== slave functionality setup ====
 * slave_data -> data ref. for the slave (e.g. the zr36050,60)
 * check -> fn-ref. checks availability of an device, returns -EIO on failure or
 *	    the type on success
 *	    this makes espcecially sense if a driver module supports more than
 *	    one codec which may be quite similar to access, nevertheless it
 *	    is good for a first functionality check
 *
 * -- main functions you always need for compression/decompression --
 *
 * set_mode -> this fn-ref. resets the entire codec, and sets up the mode
 *	       with the last defined norm/size (or device default if not
 *	       available) - it returns 0 if the mode is possible
 * set_size -> this fn-ref. sets the norm and image size for
 *	       compression/decompression (returns 0 on success)
 *	       the norm param is defined in videodev2.h (V4L2_STD_*)
 *
 * additional setup may be available, too - but the codec should work with
 * some default values even without this
 *
 * set_data -> sets device-specific data (tables, quality etc.)
 * get_data -> query device-specific data (tables, quality etc.)
 *
 * if the device delivers interrupts, they may be setup/handled here
 * setup_interrupt -> codec irq setup (not needed for 36050/60)
 * handle_interrupt -> codec irq handling (not needed for 36050/60)

 * if the device delivers pictures, they may be handled here
 * put_image -> puts image data to the codec (not needed for 36050/60)
 * get_image -> gets image data from the codec (not needed for 36050/60)
 *		the calls include frame numbers and flags (even/odd/...)
 *		if needed and a flag which allows blocking until its ready
 */

/* ============== */
/* user interface */
/* ============== */

/*
 * Currently there is only a information display planned, as the layer
 * is not visible for the user space at all.
 *
 * Information is available via procfs. The current entry is "/proc/videocodecs"
 * but it makes sense to "hide" it in the /proc/video tree of v4l(2) --TODO--.
 *
 * A example for such an output is:
 *
 * <S>lave or attached <M>aster name  type flags    magic    (connected as)
 * S                          zr36050 0002 0000d001 00000000 (TEMPLATE)
 * M                       zr36055[0] 0001 0000c001 00000000 (zr36050[0])
 * M                       zr36055[1] 0001 0000c001 00000000 (zr36050[1])
 */

/* =============================================== */
/* special defines for the videocodec_io structure */
/* =============================================== */

#ifndef __LINUX_VIDEOCODEC_H
#define __LINUX_VIDEOCODEC_H

#include <linux/debugfs.h>
#include <linux/videodev2.h>

#define CODEC_DO_COMPRESSION
#define CODEC_DO_EXPANSION

/* this are the current codec flags I think they are needed */
/*  -> type value in structure */
#define CODEC_FLAG_JPEG
#define CODEC_FLAG_MPEG
#define CODEC_FLAG_DIVX
#define CODEC_FLAG_WAVELET
					  // room for other types

#define CODEC_FLAG_MAGIC
#define CODEC_FLAG_HARDWARE
#define CODEC_FLAG_VFE
#define CODEC_FLAG_ENCODER
#define CODEC_FLAG_DECODER
#define CODEC_FLAG_NEEDIRQ
#define CODEC_FLAG_RDWRPIC

/* a list of modes, some are just examples (is there any HW?) */
#define CODEC_MODE_BJPG
#define CODEC_MODE_LJPG
#define CODEC_MODE_MPEG1
#define CODEC_MODE_MPEG2
#define CODEC_MODE_MPEG4
#define CODEC_MODE_MSDIVX
#define CODEC_MODE_ODIVX
#define CODEC_MODE_WAVELET

/* this are the current codec types I want to implement */
/*  -> type value in structure */
#define CODEC_TYPE_NONE
#define CODEC_TYPE_L64702
#define CODEC_TYPE_ZR36050
#define CODEC_TYPE_ZR36016
#define CODEC_TYPE_ZR36060

/* the type of data may be enhanced by future implementations (data-fn.'s) */
/*  -> used in command                                                     */
#define CODEC_G_STATUS
#define CODEC_S_CODEC_MODE
#define CODEC_G_CODEC_MODE
#define CODEC_S_VFE
#define CODEC_G_VFE
#define CODEC_S_MMAP

#define CODEC_S_JPEG_TDS_BYTE
#define CODEC_G_JPEG_TDS_BYTE
#define CODEC_S_JPEG_SCALE
#define CODEC_G_JPEG_SCALE
#define CODEC_S_JPEG_HDT_DATA
#define CODEC_G_JPEG_HDT_DATA
#define CODEC_S_JPEG_QDT_DATA
#define CODEC_G_JPEG_QDT_DATA
#define CODEC_S_JPEG_APP_DATA
#define CODEC_G_JPEG_APP_DATA
#define CODEC_S_JPEG_COM_DATA
#define CODEC_G_JPEG_COM_DATA

#define CODEC_S_PRIVATE
#define CODEC_G_PRIVATE

#define CODEC_G_FLAG

/* types of transfer, directly user space or a kernel buffer (image-fn.'s) */
/*  -> used in get_image, put_image */
#define CODEC_TRANSFER_KERNEL
#define CODEC_TRANSFER_USER

/* ========================= */
/* the structures itself ... */
/* ========================= */

struct vfe_polarity {};

struct vfe_settings {};

struct tvnorm {};

struct jpeg_com_marker {};

struct jpeg_app_marker {};

struct videocodec {};

struct videocodec_master {};

/* ================================================= */
/* function prototypes of the master/slave interface */
/* ================================================= */

/* attach and detach commands for the master */
// * master structure needs to be kmalloc'ed before calling attach
//   and free'd after calling detach
// * returns pointer on success, NULL on failure
struct videocodec *videocodec_attach(struct videocodec_master *master);
// * 0 on success, <0 (errno) on failure
int videocodec_detach(struct videocodec *codec);

/* register and unregister commands for the slaves */
// * 0 on success, <0 (errno) on failure
int videocodec_register(const struct videocodec *codec);
// * 0 on success, <0 (errno) on failure
int videocodec_unregister(const struct videocodec *codec);

/* the other calls are directly done via the videocodec structure! */

int videocodec_debugfs_show(struct seq_file *m);

#include "zoran.h"
static inline struct zoran *videocodec_master_to_zoran(struct videocodec_master *master)
{}

static inline struct zoran *videocodec_to_zoran(struct videocodec *codec)
{}

#endif				/*ifndef __LINUX_VIDEOCODEC_H */