// SPDX-License-Identifier: GPL-2.0-or-later /* * Zoran ZR36060 basic configuration functions * * Copyright (C) 2002 Laurent Pinchart <[email protected]> */ #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/types.h> #include <linux/wait.h> /* I/O commands, error codes */ #include <linux/io.h> /* headerfile of this module */ #include "zr36060.h" /* codec io API */ #include "videocodec.h" /* it doesn't make sense to have more than 20 or so, just to prevent some unwanted loops */ #define MAX_CODECS … /* amount of chips attached via this driver */ static int zr36060_codecs; static bool low_bitrate; module_param(low_bitrate, bool, 0); MODULE_PARM_DESC(…) …; /* ========================================================================= * Local hardware I/O functions: * read/write via codec layer (registers are located in the master device) * ========================================================================= */ static u8 zr36060_read(struct zr36060 *ptr, u16 reg) { … } static void zr36060_write(struct zr36060 *ptr, u16 reg, u8 value) { … } /* ========================================================================= * Local helper function: * status read * ========================================================================= */ /* status is kept in datastructure */ static u8 zr36060_read_status(struct zr36060 *ptr) { … } /* scale factor is kept in datastructure */ static u16 zr36060_read_scalefactor(struct zr36060 *ptr) { … } /* wait if codec is ready to proceed (end of processing) or time is over */ static void zr36060_wait_end(struct zr36060 *ptr) { … } /* Basic test of "connectivity", writes/reads to/from memory the SOF marker */ static int zr36060_basic_test(struct zr36060 *ptr) { … } /* simple loop for pushing the init datasets */ static int zr36060_pushit(struct zr36060 *ptr, u16 startreg, u16 len, const char *data) { … } /* ========================================================================= * Basic datasets: * jpeg baseline setup data (you find it on lots places in internet, or just * extract it from any regular .jpg image...) * * Could be variable, but until it's not needed it they are just fixed to save * memory. Otherwise expand zr36060 structure with arrays, push the values to * it and initialize from there, as e.g. the linux zr36057/60 driver does it. * ========================================================================= */ static const char zr36060_dqt[0x86] = …; static const char zr36060_dht[0x1a4] = …; /* jpeg baseline setup, this is just fixed in this driver (YUV pictures) */ #define NO_OF_COMPONENTS … #define BASELINE_PRECISION … static const char zr36060_tq[8] = …; //table idx's QT static const char zr36060_td[8] = …; //table idx's DC static const char zr36060_ta[8] = …; //table idx's AC /* horizontal 422 decimation setup (maybe we support 411 or so later, too) */ static const char zr36060_decimation_h[8] = …; static const char zr36060_decimation_v[8] = …; /* * SOF (start of frame) segment depends on width, height and sampling ratio * of each color component */ static int zr36060_set_sof(struct zr36060 *ptr) { … } /* SOS (start of scan) segment depends on the used scan components of each color component */ static int zr36060_set_sos(struct zr36060 *ptr) { … } /* DRI (define restart interval) */ static int zr36060_set_dri(struct zr36060 *ptr) { … } /* Setup compression/decompression of Zoran's JPEG processor ( see also zoran 36060 manual ) * ... sorry for the spaghetti code ... */ static void zr36060_init(struct zr36060 *ptr) { … } /* ========================================================================= * CODEC API FUNCTIONS * this functions are accessed by the master via the API structure * ========================================================================= */ /* set compressiion/expansion mode and launches codec - * this should be the last call from the master before starting processing */ static int zr36060_set_mode(struct videocodec *codec, int mode) { … } /* set picture size (norm is ignored as the codec doesn't know about it) */ static int zr36060_set_video(struct videocodec *codec, const struct tvnorm *norm, struct vfe_settings *cap, struct vfe_polarity *pol) { … } /* additional control functions */ static int zr36060_control(struct videocodec *codec, int type, int size, void *data) { … } /* ========================================================================= * Exit and unregister function: * Deinitializes Zoran's JPEG processor * ========================================================================= */ static int zr36060_unset(struct videocodec *codec) { … } /* ========================================================================= * Setup and registry function: * Initializes Zoran's JPEG processor * Also sets pixel size, average code size, mode (compr./decompr.) * (the given size is determined by the processor with the video interface) * ========================================================================= */ static int zr36060_setup(struct videocodec *codec) { … } static const struct videocodec zr36060_codec = …; int zr36060_init_module(void) { … } void zr36060_cleanup_module(void) { … }