Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
0004  *
0005  * @File    ctatc.h
0006  *
0007  * @Brief
0008  * This file contains the definition of the device resource management object.
0009  *
0010  * @Author  Liu Chun
0011  * @Date    Mar 28 2008
0012  */
0013 
0014 #ifndef CTATC_H
0015 #define CTATC_H
0016 
0017 #include <linux/types.h>
0018 #include <linux/mutex.h>
0019 #include <linux/pci.h>
0020 #include <linux/timer.h>
0021 #include <sound/core.h>
0022 
0023 #include "ctvmem.h"
0024 #include "cthardware.h"
0025 #include "ctresource.h"
0026 
0027 enum CTALSADEVS {       /* Types of alsa devices */
0028     FRONT,
0029     SURROUND,
0030     CLFE,
0031     SIDE,
0032     IEC958,
0033     MIXER,
0034     NUM_CTALSADEVS      /* This should always be the last */
0035 };
0036 
0037 struct ct_atc_chip_sub_details {
0038     u16 subsys;
0039     const char *nm_model;
0040 };
0041 
0042 struct ct_atc_chip_details {
0043     u16 vendor;
0044     u16 device;
0045     const struct ct_atc_chip_sub_details *sub_details;
0046     const char *nm_card;
0047 };
0048 
0049 struct ct_atc;
0050 struct ct_timer;
0051 struct ct_timer_instance;
0052 
0053 /* alsa pcm stream descriptor */
0054 struct ct_atc_pcm {
0055     struct snd_pcm_substream *substream;
0056     void (*interrupt)(struct ct_atc_pcm *apcm);
0057     struct ct_timer_instance *timer;
0058     unsigned int started:1;
0059 
0060     /* Only mono and interleaved modes are supported now. */
0061     struct ct_vm_block *vm_block;
0062     void *src;      /* SRC for interacting with host memory */
0063     void **srccs;       /* SRCs for sample rate conversion */
0064     void **srcimps;     /* SRC Input Mappers */
0065     void **amixers;     /* AMIXERs for routing converted data */
0066     void *mono;     /* A SUM resource for mixing chs to one */
0067     unsigned char n_srcc;   /* Number of converting SRCs */
0068     unsigned char n_srcimp; /* Number of SRC Input Mappers */
0069     unsigned char n_amixer; /* Number of AMIXERs */
0070 };
0071 
0072 /* Chip resource management object */
0073 struct ct_atc {
0074     struct pci_dev *pci;
0075     struct snd_card *card;
0076     unsigned int rsr; /* reference sample rate in Hz */
0077     unsigned int msr; /* master sample rate in rsr */
0078     unsigned int pll_rate; /* current rate of Phase Lock Loop */
0079 
0080     int chip_type;
0081     int model;
0082     const char *chip_name;
0083     const char *model_name;
0084 
0085     struct ct_vm *vm; /* device virtual memory manager for this card */
0086     int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0087     void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0088     unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);
0089 
0090     struct mutex atc_mutex;
0091 
0092     int (*pcm_playback_prepare)(struct ct_atc *atc,
0093                     struct ct_atc_pcm *apcm);
0094     int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0095     int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0096     int (*pcm_playback_position)(struct ct_atc *atc,
0097                      struct ct_atc_pcm *apcm);
0098     int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
0099                            struct ct_atc_pcm *apcm);
0100     int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0101     int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0102     int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
0103     int (*pcm_capture_position)(struct ct_atc *atc,
0104                     struct ct_atc_pcm *apcm);
0105     int (*pcm_release_resources)(struct ct_atc *atc,
0106                      struct ct_atc_pcm *apcm);
0107     int (*select_line_in)(struct ct_atc *atc);
0108     int (*select_mic_in)(struct ct_atc *atc);
0109     int (*select_digit_io)(struct ct_atc *atc);
0110     int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
0111     int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
0112     int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
0113     int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
0114     int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
0115     int (*mic_unmute)(struct ct_atc *atc, unsigned char state);
0116     int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
0117     int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
0118     int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
0119     int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
0120     int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
0121     struct capabilities (*capabilities)(struct ct_atc *atc);
0122     int (*output_switch_get)(struct ct_atc *atc);
0123     int (*output_switch_put)(struct ct_atc *atc, int position);
0124     int (*mic_source_switch_get)(struct ct_atc *atc);
0125     int (*mic_source_switch_put)(struct ct_atc *atc, int position);
0126 
0127     /* Don't touch! Used for internal object. */
0128     void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
0129     void *mixer;        /* internal mixer object */
0130     struct hw *hw;      /* chip specific hardware access object */
0131     void **daios;       /* digital audio io resources */
0132     void **pcm;     /* SUMs for collecting all pcm stream */
0133     void **srcs;        /* Sample Rate Converters for input signal */
0134     void **srcimps;     /* input mappers for SRCs */
0135     unsigned char n_daio;
0136     unsigned char n_src;
0137     unsigned char n_srcimp;
0138     unsigned char n_pcm;
0139 
0140     struct ct_timer *timer;
0141 
0142 #ifdef CONFIG_PM_SLEEP
0143     int (*suspend)(struct ct_atc *atc);
0144     int (*resume)(struct ct_atc *atc);
0145 #define NUM_PCMS (NUM_CTALSADEVS - 1)
0146     struct snd_pcm *pcms[NUM_PCMS];
0147 #endif
0148 };
0149 
0150 
0151 int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
0152           unsigned int rsr, unsigned int msr, int chip_type,
0153           unsigned int subsysid, struct ct_atc **ratc);
0154 int ct_atc_create_alsa_devs(struct ct_atc *atc);
0155 
0156 #endif /* CTATC_H */