18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Driver for the Conexant CX25821 PCIe bridge 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2009 Conexant Systems Inc. 68c2ecf20Sopenharmony_ci * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> 78c2ecf20Sopenharmony_ci * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef CX25821_H_ 118c2ecf20Sopenharmony_ci#define CX25821_H_ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/pci.h> 148c2ecf20Sopenharmony_ci#include <linux/i2c.h> 158c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 168c2ecf20Sopenharmony_ci#include <linux/delay.h> 178c2ecf20Sopenharmony_ci#include <linux/sched.h> 188c2ecf20Sopenharmony_ci#include <linux/kdev_t.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <media/v4l2-common.h> 218c2ecf20Sopenharmony_ci#include <media/v4l2-device.h> 228c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h> 238c2ecf20Sopenharmony_ci#include <media/videobuf2-v4l2.h> 248c2ecf20Sopenharmony_ci#include <media/videobuf2-dma-sg.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include "cx25821-reg.h" 278c2ecf20Sopenharmony_ci#include "cx25821-medusa-reg.h" 288c2ecf20Sopenharmony_ci#include "cx25821-sram.h" 298c2ecf20Sopenharmony_ci#include "cx25821-audio.h" 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#include <linux/version.h> 328c2ecf20Sopenharmony_ci#include <linux/mutex.h> 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define UNSET (-1U) 358c2ecf20Sopenharmony_ci#define NO_SYNC_LINE (-1U) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define CX25821_MAXBOARDS 2 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define LINE_SIZE_D1 1440 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* Number of decoders and encoders */ 428c2ecf20Sopenharmony_ci#define MAX_DECODERS 8 438c2ecf20Sopenharmony_ci#define MAX_ENCODERS 2 448c2ecf20Sopenharmony_ci#define QUAD_DECODERS 4 458c2ecf20Sopenharmony_ci#define MAX_CAMERAS 16 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* Max number of inputs by card */ 488c2ecf20Sopenharmony_ci#define MAX_CX25821_INPUT 8 498c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO0 1 508c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO1 2 518c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO2 4 528c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO3 8 538c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO4 16 548c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO5 32 558c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO6 64 568c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO7 128 578c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO8 256 588c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO9 512 598c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO10 1024 608c2ecf20Sopenharmony_ci#define RESOURCE_VIDEO11 2048 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */ 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define UNKNOWN_BOARD 0 658c2ecf20Sopenharmony_ci#define CX25821_BOARD 1 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* Currently supported by the driver */ 688c2ecf20Sopenharmony_ci#define CX25821_NORMS (\ 698c2ecf20Sopenharmony_ci V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR | \ 708c2ecf20Sopenharmony_ci V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \ 718c2ecf20Sopenharmony_ci V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_H | \ 728c2ecf20Sopenharmony_ci V4L2_STD_PAL_Nc) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define CX25821_BOARD_CONEXANT_ATHENA10 1 758c2ecf20Sopenharmony_ci#define MAX_VID_CHANNEL_NUM 12 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* 788c2ecf20Sopenharmony_ci * Maximum capture-only channels. This can go away once video/audio output 798c2ecf20Sopenharmony_ci * is fully supported in this driver. 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_ci#define MAX_VID_CAP_CHANNEL_NUM 10 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define VID_CHANNEL_NUM 8 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistruct cx25821_fmt { 868c2ecf20Sopenharmony_ci u32 fourcc; /* v4l2 format id */ 878c2ecf20Sopenharmony_ci int depth; 888c2ecf20Sopenharmony_ci int flags; 898c2ecf20Sopenharmony_ci u32 cxformat; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistruct cx25821_tvnorm { 938c2ecf20Sopenharmony_ci char *name; 948c2ecf20Sopenharmony_ci v4l2_std_id id; 958c2ecf20Sopenharmony_ci u32 cxiformat; 968c2ecf20Sopenharmony_ci u32 cxoformat; 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cienum cx25821_src_sel_type { 1008c2ecf20Sopenharmony_ci CX25821_SRC_SEL_EXT_656_VIDEO = 0, 1018c2ecf20Sopenharmony_ci CX25821_SRC_SEL_PARALLEL_MPEG_VIDEO 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistruct cx25821_riscmem { 1058c2ecf20Sopenharmony_ci unsigned int size; 1068c2ecf20Sopenharmony_ci __le32 *cpu; 1078c2ecf20Sopenharmony_ci __le32 *jmp; 1088c2ecf20Sopenharmony_ci dma_addr_t dma; 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* buffer for one video frame */ 1128c2ecf20Sopenharmony_cistruct cx25821_buffer { 1138c2ecf20Sopenharmony_ci /* common v4l buffer stuff -- must be first */ 1148c2ecf20Sopenharmony_ci struct vb2_v4l2_buffer vb; 1158c2ecf20Sopenharmony_ci struct list_head queue; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci /* cx25821 specific */ 1188c2ecf20Sopenharmony_ci unsigned int bpl; 1198c2ecf20Sopenharmony_ci struct cx25821_riscmem risc; 1208c2ecf20Sopenharmony_ci const struct cx25821_fmt *fmt; 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cienum port { 1248c2ecf20Sopenharmony_ci CX25821_UNDEFINED = 0, 1258c2ecf20Sopenharmony_ci CX25821_RAW, 1268c2ecf20Sopenharmony_ci CX25821_264 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistruct cx25821_board { 1308c2ecf20Sopenharmony_ci const char *name; 1318c2ecf20Sopenharmony_ci enum port porta; 1328c2ecf20Sopenharmony_ci enum port portb; 1338c2ecf20Sopenharmony_ci enum port portc; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci u32 clk_freq; 1368c2ecf20Sopenharmony_ci}; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cistruct cx25821_i2c { 1398c2ecf20Sopenharmony_ci struct cx25821_dev *dev; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci int nr; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci /* i2c i/o */ 1448c2ecf20Sopenharmony_ci struct i2c_adapter i2c_adap; 1458c2ecf20Sopenharmony_ci struct i2c_client i2c_client; 1468c2ecf20Sopenharmony_ci u32 i2c_rc; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci /* cx25821 registers used for raw address */ 1498c2ecf20Sopenharmony_ci u32 i2c_period; 1508c2ecf20Sopenharmony_ci u32 reg_ctrl; 1518c2ecf20Sopenharmony_ci u32 reg_stat; 1528c2ecf20Sopenharmony_ci u32 reg_addr; 1538c2ecf20Sopenharmony_ci u32 reg_rdata; 1548c2ecf20Sopenharmony_ci u32 reg_wdata; 1558c2ecf20Sopenharmony_ci}; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistruct cx25821_dmaqueue { 1588c2ecf20Sopenharmony_ci struct list_head active; 1598c2ecf20Sopenharmony_ci u32 count; 1608c2ecf20Sopenharmony_ci}; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cistruct cx25821_dev; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_cistruct cx25821_channel; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistruct cx25821_video_out_data { 1678c2ecf20Sopenharmony_ci struct cx25821_channel *chan; 1688c2ecf20Sopenharmony_ci int _line_size; 1698c2ecf20Sopenharmony_ci int _prog_cnt; 1708c2ecf20Sopenharmony_ci int _pixel_format; 1718c2ecf20Sopenharmony_ci int _is_first_frame; 1728c2ecf20Sopenharmony_ci int _is_running; 1738c2ecf20Sopenharmony_ci int _file_status; 1748c2ecf20Sopenharmony_ci int _lines_count; 1758c2ecf20Sopenharmony_ci int _frame_count; 1768c2ecf20Sopenharmony_ci unsigned int _risc_size; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci __le32 *_dma_virt_start_addr; 1798c2ecf20Sopenharmony_ci __le32 *_dma_virt_addr; 1808c2ecf20Sopenharmony_ci dma_addr_t _dma_phys_addr; 1818c2ecf20Sopenharmony_ci dma_addr_t _dma_phys_start_addr; 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci unsigned int _data_buf_size; 1848c2ecf20Sopenharmony_ci __le32 *_data_buf_virt_addr; 1858c2ecf20Sopenharmony_ci dma_addr_t _data_buf_phys_addr; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci u32 upstream_riscbuf_size; 1888c2ecf20Sopenharmony_ci u32 upstream_databuf_size; 1898c2ecf20Sopenharmony_ci int is_60hz; 1908c2ecf20Sopenharmony_ci int _frame_index; 1918c2ecf20Sopenharmony_ci int cur_frame_index; 1928c2ecf20Sopenharmony_ci int curpos; 1938c2ecf20Sopenharmony_ci wait_queue_head_t waitq; 1948c2ecf20Sopenharmony_ci}; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_cistruct cx25821_channel { 1978c2ecf20Sopenharmony_ci unsigned id; 1988c2ecf20Sopenharmony_ci struct cx25821_dev *dev; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler hdl; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci struct video_device vdev; 2038c2ecf20Sopenharmony_ci struct cx25821_dmaqueue dma_vidq; 2048c2ecf20Sopenharmony_ci struct vb2_queue vidq; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci const struct sram_channel *sram_channels; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci const struct cx25821_fmt *fmt; 2098c2ecf20Sopenharmony_ci unsigned field; 2108c2ecf20Sopenharmony_ci unsigned int width, height; 2118c2ecf20Sopenharmony_ci int pixel_formats; 2128c2ecf20Sopenharmony_ci int use_cif_resolution; 2138c2ecf20Sopenharmony_ci int cif_width; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci /* video output data for the video output channel */ 2168c2ecf20Sopenharmony_ci struct cx25821_video_out_data *out; 2178c2ecf20Sopenharmony_ci}; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_cistruct snd_card; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_cistruct cx25821_dev { 2228c2ecf20Sopenharmony_ci struct v4l2_device v4l2_dev; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci /* pci stuff */ 2258c2ecf20Sopenharmony_ci struct pci_dev *pci; 2268c2ecf20Sopenharmony_ci unsigned char pci_rev, pci_lat; 2278c2ecf20Sopenharmony_ci int pci_bus, pci_slot; 2288c2ecf20Sopenharmony_ci u32 base_io_addr; 2298c2ecf20Sopenharmony_ci u32 __iomem *lmmio; 2308c2ecf20Sopenharmony_ci u8 __iomem *bmmio; 2318c2ecf20Sopenharmony_ci int pci_irqmask; 2328c2ecf20Sopenharmony_ci int hwrevision; 2338c2ecf20Sopenharmony_ci /* used by cx25821-alsa */ 2348c2ecf20Sopenharmony_ci struct snd_card *card; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci u32 clk_freq; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ 2398c2ecf20Sopenharmony_ci struct cx25821_i2c i2c_bus[3]; 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci int nr; 2428c2ecf20Sopenharmony_ci struct mutex lock; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci struct cx25821_channel channels[MAX_VID_CHANNEL_NUM]; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci /* board details */ 2478c2ecf20Sopenharmony_ci unsigned int board; 2488c2ecf20Sopenharmony_ci char name[32]; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci /* Analog video */ 2518c2ecf20Sopenharmony_ci unsigned int input; 2528c2ecf20Sopenharmony_ci v4l2_std_id tvnorm; 2538c2ecf20Sopenharmony_ci unsigned short _max_num_decoders; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci /* Analog Audio Upstream */ 2568c2ecf20Sopenharmony_ci int _audio_is_running; 2578c2ecf20Sopenharmony_ci int _audiopixel_format; 2588c2ecf20Sopenharmony_ci int _is_first_audio_frame; 2598c2ecf20Sopenharmony_ci int _audiofile_status; 2608c2ecf20Sopenharmony_ci int _audio_lines_count; 2618c2ecf20Sopenharmony_ci int _audioframe_count; 2628c2ecf20Sopenharmony_ci int _audio_upstream_channel; 2638c2ecf20Sopenharmony_ci int _last_index_irq; /* The last interrupt index processed. */ 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci __le32 *_risc_audio_jmp_addr; 2668c2ecf20Sopenharmony_ci __le32 *_risc_virt_start_addr; 2678c2ecf20Sopenharmony_ci __le32 *_risc_virt_addr; 2688c2ecf20Sopenharmony_ci dma_addr_t _risc_phys_addr; 2698c2ecf20Sopenharmony_ci dma_addr_t _risc_phys_start_addr; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci unsigned int _audiorisc_size; 2728c2ecf20Sopenharmony_ci unsigned int _audiodata_buf_size; 2738c2ecf20Sopenharmony_ci __le32 *_audiodata_buf_virt_addr; 2748c2ecf20Sopenharmony_ci dma_addr_t _audiodata_buf_phys_addr; 2758c2ecf20Sopenharmony_ci char *_audiofilename; 2768c2ecf20Sopenharmony_ci u32 audio_upstream_riscbuf_size; 2778c2ecf20Sopenharmony_ci u32 audio_upstream_databuf_size; 2788c2ecf20Sopenharmony_ci int _audioframe_index; 2798c2ecf20Sopenharmony_ci struct work_struct _audio_work_entry; 2808c2ecf20Sopenharmony_ci char *input_audiofilename; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci /* V4l */ 2838c2ecf20Sopenharmony_ci spinlock_t slock; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci /* Video Upstream */ 2868c2ecf20Sopenharmony_ci struct cx25821_video_out_data vid_out_data[2]; 2878c2ecf20Sopenharmony_ci}; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_cistatic inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev) 2908c2ecf20Sopenharmony_ci{ 2918c2ecf20Sopenharmony_ci return container_of(v4l2_dev, struct cx25821_dev, v4l2_dev); 2928c2ecf20Sopenharmony_ci} 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ciextern struct cx25821_board cx25821_boards[]; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci#define SRAM_CH00 0 /* Video A */ 2978c2ecf20Sopenharmony_ci#define SRAM_CH01 1 /* Video B */ 2988c2ecf20Sopenharmony_ci#define SRAM_CH02 2 /* Video C */ 2998c2ecf20Sopenharmony_ci#define SRAM_CH03 3 /* Video D */ 3008c2ecf20Sopenharmony_ci#define SRAM_CH04 4 /* Video E */ 3018c2ecf20Sopenharmony_ci#define SRAM_CH05 5 /* Video F */ 3028c2ecf20Sopenharmony_ci#define SRAM_CH06 6 /* Video G */ 3038c2ecf20Sopenharmony_ci#define SRAM_CH07 7 /* Video H */ 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci#define SRAM_CH08 8 /* Audio A */ 3068c2ecf20Sopenharmony_ci#define SRAM_CH09 9 /* Video Upstream I */ 3078c2ecf20Sopenharmony_ci#define SRAM_CH10 10 /* Video Upstream J */ 3088c2ecf20Sopenharmony_ci#define SRAM_CH11 11 /* Audio Upstream AUD_CHANNEL_B */ 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci#define VID_UPSTREAM_SRAM_CHANNEL_I SRAM_CH09 3118c2ecf20Sopenharmony_ci#define VID_UPSTREAM_SRAM_CHANNEL_J SRAM_CH10 3128c2ecf20Sopenharmony_ci#define AUDIO_UPSTREAM_SRAM_CHANNEL_B SRAM_CH11 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_cistruct sram_channel { 3158c2ecf20Sopenharmony_ci char *name; 3168c2ecf20Sopenharmony_ci u32 i; 3178c2ecf20Sopenharmony_ci u32 cmds_start; 3188c2ecf20Sopenharmony_ci u32 ctrl_start; 3198c2ecf20Sopenharmony_ci u32 cdt; 3208c2ecf20Sopenharmony_ci u32 fifo_start; 3218c2ecf20Sopenharmony_ci u32 fifo_size; 3228c2ecf20Sopenharmony_ci u32 ptr1_reg; 3238c2ecf20Sopenharmony_ci u32 ptr2_reg; 3248c2ecf20Sopenharmony_ci u32 cnt1_reg; 3258c2ecf20Sopenharmony_ci u32 cnt2_reg; 3268c2ecf20Sopenharmony_ci u32 int_msk; 3278c2ecf20Sopenharmony_ci u32 int_stat; 3288c2ecf20Sopenharmony_ci u32 int_mstat; 3298c2ecf20Sopenharmony_ci u32 dma_ctl; 3308c2ecf20Sopenharmony_ci u32 gpcnt_ctl; 3318c2ecf20Sopenharmony_ci u32 gpcnt; 3328c2ecf20Sopenharmony_ci u32 aud_length; 3338c2ecf20Sopenharmony_ci u32 aud_cfg; 3348c2ecf20Sopenharmony_ci u32 fld_aud_fifo_en; 3358c2ecf20Sopenharmony_ci u32 fld_aud_risc_en; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci /* For Upstream Video */ 3388c2ecf20Sopenharmony_ci u32 vid_fmt_ctl; 3398c2ecf20Sopenharmony_ci u32 vid_active_ctl1; 3408c2ecf20Sopenharmony_ci u32 vid_active_ctl2; 3418c2ecf20Sopenharmony_ci u32 vid_cdt_size; 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci u32 vip_ctl; 3448c2ecf20Sopenharmony_ci u32 pix_frmt; 3458c2ecf20Sopenharmony_ci u32 jumponly; 3468c2ecf20Sopenharmony_ci u32 irq_bit; 3478c2ecf20Sopenharmony_ci}; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ciextern const struct sram_channel cx25821_sram_channels[]; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci#define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) 3528c2ecf20Sopenharmony_ci#define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2)) 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci#define cx_andor(reg, mask, value) \ 3558c2ecf20Sopenharmony_ci writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ 3568c2ecf20Sopenharmony_ci ((value) & (mask)), dev->lmmio+((reg)>>2)) 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci#define cx_set(reg, bit) cx_andor((reg), (bit), (bit)) 3598c2ecf20Sopenharmony_ci#define cx_clear(reg, bit) cx_andor((reg), (bit), 0) 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci#define Set_GPIO_Bit(Bit) (1 << Bit) 3628c2ecf20Sopenharmony_ci#define Clear_GPIO_Bit(Bit) (~(1 << Bit)) 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci#define CX25821_ERR(fmt, args...) \ 3658c2ecf20Sopenharmony_ci pr_err("(%d): " fmt, dev->board, ##args) 3668c2ecf20Sopenharmony_ci#define CX25821_WARN(fmt, args...) \ 3678c2ecf20Sopenharmony_ci pr_warn("(%d): " fmt, dev->board, ##args) 3688c2ecf20Sopenharmony_ci#define CX25821_INFO(fmt, args...) \ 3698c2ecf20Sopenharmony_ci pr_info("(%d): " fmt, dev->board, ##args) 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ciextern int cx25821_i2c_register(struct cx25821_i2c *bus); 3728c2ecf20Sopenharmony_ciextern int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value); 3738c2ecf20Sopenharmony_ciextern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value); 3748c2ecf20Sopenharmony_ciextern int cx25821_i2c_unregister(struct cx25821_i2c *bus); 3758c2ecf20Sopenharmony_ciextern void cx25821_gpio_init(struct cx25821_dev *dev); 3768c2ecf20Sopenharmony_ciextern void cx25821_set_gpiopin_direction(struct cx25821_dev *dev, 3778c2ecf20Sopenharmony_ci int pin_number, int pin_logic_value); 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ciextern int medusa_video_init(struct cx25821_dev *dev); 3808c2ecf20Sopenharmony_ciextern int medusa_set_videostandard(struct cx25821_dev *dev); 3818c2ecf20Sopenharmony_ciextern void medusa_set_resolution(struct cx25821_dev *dev, int width, 3828c2ecf20Sopenharmony_ci int decoder_select); 3838c2ecf20Sopenharmony_ciextern int medusa_set_brightness(struct cx25821_dev *dev, int brightness, 3848c2ecf20Sopenharmony_ci int decoder); 3858c2ecf20Sopenharmony_ciextern int medusa_set_contrast(struct cx25821_dev *dev, int contrast, 3868c2ecf20Sopenharmony_ci int decoder); 3878c2ecf20Sopenharmony_ciextern int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder); 3888c2ecf20Sopenharmony_ciextern int medusa_set_saturation(struct cx25821_dev *dev, int saturation, 3898c2ecf20Sopenharmony_ci int decoder); 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ciextern int cx25821_sram_channel_setup(struct cx25821_dev *dev, 3928c2ecf20Sopenharmony_ci const struct sram_channel *ch, unsigned int bpl, 3938c2ecf20Sopenharmony_ci u32 risc); 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ciextern int cx25821_riscmem_alloc(struct pci_dev *pci, 3968c2ecf20Sopenharmony_ci struct cx25821_riscmem *risc, 3978c2ecf20Sopenharmony_ci unsigned int size); 3988c2ecf20Sopenharmony_ciextern int cx25821_risc_buffer(struct pci_dev *pci, struct cx25821_riscmem *risc, 3998c2ecf20Sopenharmony_ci struct scatterlist *sglist, 4008c2ecf20Sopenharmony_ci unsigned int top_offset, 4018c2ecf20Sopenharmony_ci unsigned int bottom_offset, 4028c2ecf20Sopenharmony_ci unsigned int bpl, 4038c2ecf20Sopenharmony_ci unsigned int padding, unsigned int lines); 4048c2ecf20Sopenharmony_ciextern int cx25821_risc_databuffer_audio(struct pci_dev *pci, 4058c2ecf20Sopenharmony_ci struct cx25821_riscmem *risc, 4068c2ecf20Sopenharmony_ci struct scatterlist *sglist, 4078c2ecf20Sopenharmony_ci unsigned int bpl, 4088c2ecf20Sopenharmony_ci unsigned int lines, unsigned int lpi); 4098c2ecf20Sopenharmony_ciextern void cx25821_free_buffer(struct cx25821_dev *dev, 4108c2ecf20Sopenharmony_ci struct cx25821_buffer *buf); 4118c2ecf20Sopenharmony_ciextern void cx25821_sram_channel_dump(struct cx25821_dev *dev, 4128c2ecf20Sopenharmony_ci const struct sram_channel *ch); 4138c2ecf20Sopenharmony_ciextern void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev, 4148c2ecf20Sopenharmony_ci const struct sram_channel *ch); 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ciextern struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci); 4178c2ecf20Sopenharmony_ciextern void cx25821_print_irqbits(char *name, char *tag, char **strings, 4188c2ecf20Sopenharmony_ci int len, u32 bits, u32 mask); 4198c2ecf20Sopenharmony_ciextern void cx25821_dev_unregister(struct cx25821_dev *dev); 4208c2ecf20Sopenharmony_ciextern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, 4218c2ecf20Sopenharmony_ci const struct sram_channel *ch, 4228c2ecf20Sopenharmony_ci unsigned int bpl, u32 risc); 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ciextern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, 4258c2ecf20Sopenharmony_ci u32 format); 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci#endif 428