linux/sound/pci/ctxfi/cthw20k2.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
 *
 * @File	cthw20k2.c
 *
 * @Brief
 * This file contains the implementation of hardware access method for 20k2.
 *
 * @Author	Liu Chun
 * @Date 	May 14 2008
 */

#include <linux/types.h>
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/io.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include "cthw20k2.h"
#include "ct20k2reg.h"

struct hw20k2 {};

static u32 hw_read_20kx(struct hw *hw, u32 reg);
static void hw_write_20kx(struct hw *hw, u32 reg, u32 data);

/*
 * Type definition block.
 * The layout of control structures can be directly applied on 20k2 chip.
 */

/*
 * SRC control block definitions.
 */

/* SRC resource control block */
#define SRCCTL_STATE
#define SRCCTL_BM
#define SRCCTL_RSR
#define SRCCTL_SF
#define SRCCTL_WR
#define SRCCTL_PM
#define SRCCTL_ROM
#define SRCCTL_VO
#define SRCCTL_ST
#define SRCCTL_IE
#define SRCCTL_ILSZ
#define SRCCTL_BP

#define SRCCCR_CISZ
#define SRCCCR_CWA
#define SRCCCR_D
#define SRCCCR_RS
#define SRCCCR_NAL
#define SRCCCR_RA

#define SRCCA_CA
#define SRCCA_RS

#define SRCSA_SA

#define SRCLA_LA

/* Mixer Parameter Ring ram Low and Hight register.
 * Fixed-point value in 8.24 format for parameter channel */
#define MPRLH_PITCH

/* SRC resource register dirty flags */
src_dirty;

struct src_rsc_ctrl_blk {};

/* SRC manager control block */
src_mgr_dirty;

struct src_mgr_ctrl_blk {};

/* SRCIMP manager control block */
#define SRCAIM_ARC
#define SRCAIM_NXT
#define SRCAIM_SRC

struct srcimap {};

/* SRCIMP manager register dirty flags */
srcimp_mgr_dirty;

struct srcimp_mgr_ctrl_blk {};

/*
 * Function implementation block.
 */

static int src_get_rsc_ctrl_blk(void **rblk)
{}

static int src_put_rsc_ctrl_blk(void *blk)
{}

static int src_set_state(void *blk, unsigned int state)
{}

static int src_set_bm(void *blk, unsigned int bm)
{}

static int src_set_rsr(void *blk, unsigned int rsr)
{}

static int src_set_sf(void *blk, unsigned int sf)
{}

static int src_set_wr(void *blk, unsigned int wr)
{}

static int src_set_pm(void *blk, unsigned int pm)
{}

static int src_set_rom(void *blk, unsigned int rom)
{}

static int src_set_vo(void *blk, unsigned int vo)
{}

static int src_set_st(void *blk, unsigned int st)
{}

static int src_set_ie(void *blk, unsigned int ie)
{}

static int src_set_ilsz(void *blk, unsigned int ilsz)
{}

static int src_set_bp(void *blk, unsigned int bp)
{}

static int src_set_cisz(void *blk, unsigned int cisz)
{}

static int src_set_ca(void *blk, unsigned int ca)
{}

static int src_set_sa(void *blk, unsigned int sa)
{}

static int src_set_la(void *blk, unsigned int la)
{}

static int src_set_pitch(void *blk, unsigned int pitch)
{}

static int src_set_clear_zbufs(void *blk, unsigned int clear)
{}

static int src_set_dirty(void *blk, unsigned int flags)
{}

static int src_set_dirty_all(void *blk)
{}

#define AR_SLOT_SIZE
#define AR_SLOT_BLOCK_SIZE
#define AR_PTS_PITCH
#define AR_PARAM_SRC_OFFSET

static unsigned int src_param_pitch_mixer(unsigned int src_idx)
{}

static int src_commit_write(struct hw *hw, unsigned int idx, void *blk)
{}

static int src_get_ca(struct hw *hw, unsigned int idx, void *blk)
{}

static unsigned int src_get_dirty(void *blk)
{}

static unsigned int src_dirty_conj_mask(void)
{}

static int src_mgr_enbs_src(void *blk, unsigned int idx)
{}

static int src_mgr_enb_src(void *blk, unsigned int idx)
{}

static int src_mgr_dsb_src(void *blk, unsigned int idx)
{}

static int src_mgr_commit_write(struct hw *hw, void *blk)
{}

static int src_mgr_get_ctrl_blk(void **rblk)
{}

static int src_mgr_put_ctrl_blk(void *blk)
{}

static int srcimp_mgr_get_ctrl_blk(void **rblk)
{}

static int srcimp_mgr_put_ctrl_blk(void *blk)
{}

static int srcimp_mgr_set_imaparc(void *blk, unsigned int slot)
{}

static int srcimp_mgr_set_imapuser(void *blk, unsigned int user)
{}

static int srcimp_mgr_set_imapnxt(void *blk, unsigned int next)
{}

static int srcimp_mgr_set_imapaddr(void *blk, unsigned int addr)
{}

static int srcimp_mgr_commit_write(struct hw *hw, void *blk)
{}

/*
 * AMIXER control block definitions.
 */

#define AMOPLO_M
#define AMOPLO_IV
#define AMOPLO_X
#define AMOPLO_Y

#define AMOPHI_SADR
#define AMOPHI_SE

/* AMIXER resource register dirty flags */
amixer_dirty;

/* AMIXER resource control block */
struct amixer_rsc_ctrl_blk {};

static int amixer_set_mode(void *blk, unsigned int mode)
{}

static int amixer_set_iv(void *blk, unsigned int iv)
{}

static int amixer_set_x(void *blk, unsigned int x)
{}

static int amixer_set_y(void *blk, unsigned int y)
{}

static int amixer_set_sadr(void *blk, unsigned int sadr)
{}

static int amixer_set_se(void *blk, unsigned int se)
{}

static int amixer_set_dirty(void *blk, unsigned int flags)
{}

static int amixer_set_dirty_all(void *blk)
{}

static int amixer_commit_write(struct hw *hw, unsigned int idx, void *blk)
{}

static int amixer_get_y(void *blk)
{}

static unsigned int amixer_get_dirty(void *blk)
{}

static int amixer_rsc_get_ctrl_blk(void **rblk)
{}

static int amixer_rsc_put_ctrl_blk(void *blk)
{}

static int amixer_mgr_get_ctrl_blk(void **rblk)
{}

static int amixer_mgr_put_ctrl_blk(void *blk)
{}

/*
 * DAIO control block definitions.
 */

/* Receiver Sample Rate Tracker Control register */
#define SRTCTL_SRCO
#define SRTCTL_SRCM
#define SRTCTL_RSR
#define SRTCTL_DRAT
#define SRTCTL_EC
#define SRTCTL_ET

/* DAIO Receiver register dirty flags */
dai_dirty;

/* DAIO Receiver control block */
struct dai_ctrl_blk {};

/* Audio Input Mapper RAM */
#define AIM_ARC
#define AIM_NXT

struct daoimap {};

/* Audio Transmitter Control and Status register */
#define ATXCTL_EN
#define ATXCTL_MODE
#define ATXCTL_CD
#define ATXCTL_RAW
#define ATXCTL_MT
#define ATXCTL_NUC
#define ATXCTL_BEN
#define ATXCTL_BMUX
#define ATXCTL_B24
#define ATXCTL_CPF
#define ATXCTL_RIV
#define ATXCTL_LIV
#define ATXCTL_RSAT
#define ATXCTL_LSAT

/* XDIF Transmitter register dirty flags */
dao_dirty;

/* XDIF Transmitter control block */
struct dao_ctrl_blk {};

/* Audio Receiver Control register */
#define ARXCTL_EN

/* DAIO manager register dirty flags */
daio_mgr_dirty;

/* DAIO manager control block */
struct daio_mgr_ctrl_blk {};

static int dai_srt_set_srco(void *blk, unsigned int src)
{}

static int dai_srt_set_srcm(void *blk, unsigned int src)
{}

static int dai_srt_set_rsr(void *blk, unsigned int rsr)
{}

static int dai_srt_set_drat(void *blk, unsigned int drat)
{}

static int dai_srt_set_ec(void *blk, unsigned int ec)
{}

static int dai_srt_set_et(void *blk, unsigned int et)
{}

static int dai_commit_write(struct hw *hw, unsigned int idx, void *blk)
{}

static int dai_get_ctrl_blk(void **rblk)
{}

static int dai_put_ctrl_blk(void *blk)
{}

static int dao_set_spos(void *blk, unsigned int spos)
{}

static int dao_commit_write(struct hw *hw, unsigned int idx, void *blk)
{}

static int dao_get_spos(void *blk, unsigned int *spos)
{}

static int dao_get_ctrl_blk(void **rblk)
{}

static int dao_put_ctrl_blk(void *blk)
{}

static int daio_mgr_enb_dai(void *blk, unsigned int idx)
{}

static int daio_mgr_dsb_dai(void *blk, unsigned int idx)
{}

static int daio_mgr_enb_dao(void *blk, unsigned int idx)
{}

static int daio_mgr_dsb_dao(void *blk, unsigned int idx)
{}

static int daio_mgr_dao_init(void *blk, unsigned int idx, unsigned int conf)
{}

static int daio_mgr_set_imaparc(void *blk, unsigned int slot)
{}

static int daio_mgr_set_imapnxt(void *blk, unsigned int next)
{}

static int daio_mgr_set_imapaddr(void *blk, unsigned int addr)
{}

static int daio_mgr_commit_write(struct hw *hw, void *blk)
{}

static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk)
{}

static int daio_mgr_put_ctrl_blk(void *blk)
{}

/* Timer interrupt */
static int set_timer_irq(struct hw *hw, int enable)
{}

static int set_timer_tick(struct hw *hw, unsigned int ticks)
{}

static unsigned int get_wc(struct hw *hw)
{}

/* Card hardware initialization block */
struct dac_conf {};

struct adc_conf {};

struct daio_conf {};

struct trn_conf {};

static int hw_daio_init(struct hw *hw, const struct daio_conf *info)
{}

/* TRANSPORT operations */
static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
{}

/* Card initialization */
#define GCTL_AIE
#define GCTL_UAA
#define GCTL_DPC
#define GCTL_DBP
#define GCTL_ABP
#define GCTL_TBP
#define GCTL_SBP
#define GCTL_FBP
#define GCTL_ME
#define GCTL_AID

#define PLLCTL_SRC
#define PLLCTL_SPE
#define PLLCTL_RD
#define PLLCTL_FD
#define PLLCTL_OD
#define PLLCTL_B
#define PLLCTL_AS
#define PLLCTL_LF
#define PLLCTL_SPS
#define PLLCTL_AD

#define PLLSTAT_CCS
#define PLLSTAT_SPL
#define PLLSTAT_CRD
#define PLLSTAT_CFD
#define PLLSTAT_SL
#define PLLSTAT_FAS
#define PLLSTAT_B
#define PLLSTAT_PD
#define PLLSTAT_OCA
#define PLLSTAT_NCA

static int hw_pll_init(struct hw *hw, unsigned int rsr)
{}

static int hw_auto_init(struct hw *hw)
{}

/* DAC operations */

#define CS4382_MC1
#define CS4382_MC2
#define CS4382_MC3
#define CS4382_FC
#define CS4382_IC
#define CS4382_XC1
#define CS4382_VCA1
#define CS4382_VCB1
#define CS4382_XC2
#define CS4382_VCA2
#define CS4382_VCB2
#define CS4382_XC3
#define CS4382_VCA3
#define CS4382_VCB3
#define CS4382_XC4
#define CS4382_VCA4
#define CS4382_VCB4
#define CS4382_CREV

/* I2C status */
#define STATE_LOCKED
#define STATE_UNLOCKED
#define DATA_READY
#define DATA_ABORT

#define I2C_STATUS_DCM
#define I2C_STATUS_BC
#define I2C_STATUS_APD
#define I2C_STATUS_AB
#define I2C_STATUS_DR

#define I2C_ADDRESS_PTAD
#define I2C_ADDRESS_SLAD

struct regs_cs4382 {};

static int hw20k2_i2c_unlock_full_access(struct hw *hw)
{}

static int hw20k2_i2c_lock_chip(struct hw *hw)
{}

static int hw20k2_i2c_init(struct hw *hw, u8 dev_id, u8 addr_size, u8 data_size)
{}

static int hw20k2_i2c_uninit(struct hw *hw)
{}

static int hw20k2_i2c_wait_data_ready(struct hw *hw)
{}

static int hw20k2_i2c_read(struct hw *hw, u16 addr, u32 *datap)
{}

static int hw20k2_i2c_write(struct hw *hw, u16 addr, u32 data)
{}

static void hw_dac_stop(struct hw *hw)
{}

static void hw_dac_start(struct hw *hw)
{}

static void hw_dac_reset(struct hw *hw)
{}

static int hw_dac_init(struct hw *hw, const struct dac_conf *info)
{}

/* ADC operations */
#define MAKE_WM8775_ADDR(addr, data)
#define MAKE_WM8775_DATA(data)

#define WM8775_IC
#define WM8775_MMC
#define WM8775_AADCL
#define WM8775_AADCR
#define WM8775_ADCMC
#define WM8775_RESET

static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type)
{}

#define MIC_BOOST_0DB
#define MIC_BOOST_STEPS_PER_DB

static void hw_wm8775_input_select(struct hw *hw, u8 input, s8 gain_in_db)
{}

static int hw_adc_input_select(struct hw *hw, enum ADCSRC type)
{}

static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
{}

static struct capabilities hw_capabilities(struct hw *hw)
{}

static int hw_output_switch_get(struct hw *hw)
{}

static int hw_output_switch_put(struct hw *hw, int position)
{}

static int hw_mic_source_switch_get(struct hw *hw)
{}

static int hw_mic_source_switch_put(struct hw *hw, int position)
{}

static irqreturn_t ct_20k2_interrupt(int irq, void *dev_id)
{}

static int hw_card_start(struct hw *hw)
{}

static int hw_card_stop(struct hw *hw)
{}

static int hw_card_shutdown(struct hw *hw)
{}

static int hw_card_init(struct hw *hw, struct card_conf *info)
{}

#ifdef CONFIG_PM_SLEEP
static int hw_suspend(struct hw *hw)
{}

static int hw_resume(struct hw *hw, struct card_conf *info)
{}
#endif

static u32 hw_read_20kx(struct hw *hw, u32 reg)
{}

static void hw_write_20kx(struct hw *hw, u32 reg, u32 data)
{}

static const struct hw ct20k2_preset =;

int create_20k2_hw_obj(struct hw **rhw)
{}

int destroy_20k2_hw_obj(struct hw *hw)
{}