// SPDX-License-Identifier: GPL-2.0-or-later /* * Zoran ZR36050 basic configuration functions * * Copyright (C) 2001 Wolfgang Scherr <[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 "zr36050.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 zr36050_codecs; /* * Local hardware I/O functions: * * read/write via codec layer (registers are located in the master device) */ /* read and write functions */ static u8 zr36050_read(struct zr36050 *ptr, u16 reg) { … } static void zr36050_write(struct zr36050 *ptr, u16 reg, u8 value) { … } /* status is kept in datastructure */ static u8 zr36050_read_status1(struct zr36050 *ptr) { … } /* scale factor is kept in datastructure */ static u16 zr36050_read_scalefactor(struct zr36050 *ptr) { … } /* * Local helper function: * * wait if codec is ready to proceed (end of processing) or time is over */ static void zr36050_wait_end(struct zr36050 *ptr) { … } /* * Local helper function: basic test of "connectivity", writes/reads * to/from memory the SOF marker */ static int zr36050_basic_test(struct zr36050 *ptr) { … } /* Local helper function: simple loop for pushing the init datasets */ static int zr36050_pushit(struct zr36050 *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 zr36050 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 zr36050_dqt[0x86] = …; static const char zr36050_dht[0x1a4] = …; /* jpeg baseline setup, this is just fixed in this driver (YUV pictures) */ #define NO_OF_COMPONENTS … #define BASELINE_PRECISION … static const char zr36050_tq[8] = …; //table idx's QT static const char zr36050_td[8] = …; //table idx's DC static const char zr36050_ta[8] = …; //table idx's AC /* horizontal 422 decimation setup (maybe we support 411 or so later, too) */ static const char zr36050_decimation_h[8] = …; static const char zr36050_decimation_v[8] = …; /* * Local helper functions: * * calculation and setup of parameter-dependent JPEG baseline segments * (needed for compression only) */ /* ------------------------------------------------------------------------- */ /* * SOF (start of frame) segment depends on width, height and sampling ratio * of each color component */ static int zr36050_set_sof(struct zr36050 *ptr) { … } /* ------------------------------------------------------------------------- */ /* * SOS (start of scan) segment depends on the used scan components * of each color component */ static int zr36050_set_sos(struct zr36050 *ptr) { … } /* ------------------------------------------------------------------------- */ /* DRI (define restart interval) */ static int zr36050_set_dri(struct zr36050 *ptr) { … } /* * Setup function: * * Setup compression/decompression of Zoran's JPEG processor * ( see also zoran 36050 manual ) * * ... sorry for the spaghetti code ... */ static void zr36050_init(struct zr36050 *ptr) { … } /* * CODEC API FUNCTIONS * * this functions are accessed by the master via the API structure */ /* * set compression/expansion mode and launches codec - * this should be the last call from the master before starting processing */ static int zr36050_set_mode(struct videocodec *codec, int mode) { … } /* set picture size (norm is ignored as the codec doesn't know about it) */ static int zr36050_set_video(struct videocodec *codec, const struct tvnorm *norm, struct vfe_settings *cap, struct vfe_polarity *pol) { … } /* additional control functions */ static int zr36050_control(struct videocodec *codec, int type, int size, void *data) { … } /* Exit and unregister function: Deinitializes Zoran's JPEG processor */ static int zr36050_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 zr36050_setup(struct videocodec *codec) { … } static const struct videocodec zr36050_codec = …; /* HOOK IN DRIVER AS KERNEL MODULE */ int zr36050_init_module(void) { … } void zr36050_cleanup_module(void) { … }