xref: /linux/sound/pci/ctxfi/ctsrc.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
15765e78eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2a08b9f2fSAditya Srivastava /*
38cc72361SWai Yew CHAY  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
48cc72361SWai Yew CHAY  *
58cc72361SWai Yew CHAY  * @File	ctsrc.h
68cc72361SWai Yew CHAY  *
78cc72361SWai Yew CHAY  * @Brief
88cc72361SWai Yew CHAY  * This file contains the definition of the Sample Rate Convertor
98cc72361SWai Yew CHAY  * resource management object.
108cc72361SWai Yew CHAY  *
118cc72361SWai Yew CHAY  * @Author	Liu Chun
128cc72361SWai Yew CHAY  * @Date 	May 13 2008
138cc72361SWai Yew CHAY  */
148cc72361SWai Yew CHAY 
158cc72361SWai Yew CHAY #ifndef CTSRC_H
168cc72361SWai Yew CHAY #define CTSRC_H
178cc72361SWai Yew CHAY 
188cc72361SWai Yew CHAY #include "ctresource.h"
198cc72361SWai Yew CHAY #include "ctimap.h"
208cc72361SWai Yew CHAY #include <linux/spinlock.h>
218cc72361SWai Yew CHAY #include <linux/list.h>
223d0fdc86SSudip Mukherjee #include <sound/core.h>
238cc72361SWai Yew CHAY 
248cc72361SWai Yew CHAY #define SRC_STATE_OFF	0x0
258cc72361SWai Yew CHAY #define SRC_STATE_INIT	0x4
268cc72361SWai Yew CHAY #define SRC_STATE_RUN	0x5
278cc72361SWai Yew CHAY 
288cc72361SWai Yew CHAY #define SRC_SF_U8	0x0
298cc72361SWai Yew CHAY #define SRC_SF_S16	0x1
308cc72361SWai Yew CHAY #define SRC_SF_S24	0x2
318cc72361SWai Yew CHAY #define SRC_SF_S32	0x3
328cc72361SWai Yew CHAY #define SRC_SF_F32	0x4
338cc72361SWai Yew CHAY 
348cc72361SWai Yew CHAY /* Define the descriptor of a src resource */
358cc72361SWai Yew CHAY enum SRCMODE {
368cc72361SWai Yew CHAY 	MEMRD,		/* Read data from host memory */
378cc72361SWai Yew CHAY 	MEMWR,		/* Write data to host memory */
388cc72361SWai Yew CHAY 	ARCRW,		/* Read from and write to audio ring channel */
398cc72361SWai Yew CHAY 	NUM_SRCMODES
408cc72361SWai Yew CHAY };
418cc72361SWai Yew CHAY 
428cc72361SWai Yew CHAY struct src_rsc_ops;
438cc72361SWai Yew CHAY 
448cc72361SWai Yew CHAY struct src {
458cc72361SWai Yew CHAY 	struct rsc rsc; /* Basic resource info */
468cc72361SWai Yew CHAY 	struct src *intlv; /* Pointer to next interleaved SRC in a series */
4743f2cdebSJulia Lawall 	const struct src_rsc_ops *ops; /* SRC specific operations */
488cc72361SWai Yew CHAY 	/* Number of contiguous srcs for interleaved usage */
498cc72361SWai Yew CHAY 	unsigned char multi;
508cc72361SWai Yew CHAY 	unsigned char mode; /* Working mode of this SRC resource */
518cc72361SWai Yew CHAY };
528cc72361SWai Yew CHAY 
538cc72361SWai Yew CHAY struct src_rsc_ops {
548cc72361SWai Yew CHAY 	int (*set_state)(struct src *src, unsigned int state);
558cc72361SWai Yew CHAY 	int (*set_bm)(struct src *src, unsigned int bm);
568cc72361SWai Yew CHAY 	int (*set_sf)(struct src *src, unsigned int sf);
578cc72361SWai Yew CHAY 	int (*set_pm)(struct src *src, unsigned int pm);
588cc72361SWai Yew CHAY 	int (*set_rom)(struct src *src, unsigned int rom);
598cc72361SWai Yew CHAY 	int (*set_vo)(struct src *src, unsigned int vo);
608cc72361SWai Yew CHAY 	int (*set_st)(struct src *src, unsigned int st);
618cc72361SWai Yew CHAY 	int (*set_bp)(struct src *src, unsigned int bp);
628cc72361SWai Yew CHAY 	int (*set_cisz)(struct src *src, unsigned int cisz);
638cc72361SWai Yew CHAY 	int (*set_ca)(struct src *src, unsigned int ca);
648cc72361SWai Yew CHAY 	int (*set_sa)(struct src *src, unsigned int sa);
658cc72361SWai Yew CHAY 	int (*set_la)(struct src *src, unsigned int la);
668cc72361SWai Yew CHAY 	int (*set_pitch)(struct src *src, unsigned int pitch);
678cc72361SWai Yew CHAY 	int (*set_clr_zbufs)(struct src *src);
688cc72361SWai Yew CHAY 	int (*commit_write)(struct src *src);
698cc72361SWai Yew CHAY 	int (*get_ca)(struct src *src);
708cc72361SWai Yew CHAY 	int (*init)(struct src *src);
718cc72361SWai Yew CHAY 	struct src* (*next_interleave)(struct src *src);
728cc72361SWai Yew CHAY };
738cc72361SWai Yew CHAY 
748cc72361SWai Yew CHAY /* Define src resource request description info */
758cc72361SWai Yew CHAY struct src_desc {
768cc72361SWai Yew CHAY 	/* Number of contiguous master srcs for interleaved usage */
778cc72361SWai Yew CHAY 	unsigned char multi;
788cc72361SWai Yew CHAY 	unsigned char msr;
798cc72361SWai Yew CHAY 	unsigned char mode; /* Working mode of the requested srcs */
808cc72361SWai Yew CHAY };
818cc72361SWai Yew CHAY 
828cc72361SWai Yew CHAY /* Define src manager object */
838cc72361SWai Yew CHAY struct src_mgr {
848cc72361SWai Yew CHAY 	struct rsc_mgr mgr;	/* Basic resource manager info */
853d0fdc86SSudip Mukherjee 	struct snd_card *card;	/* pointer to this card */
868cc72361SWai Yew CHAY 	spinlock_t mgr_lock;
878cc72361SWai Yew CHAY 
888cc72361SWai Yew CHAY 	 /* request src resource */
898cc72361SWai Yew CHAY 	int (*get_src)(struct src_mgr *mgr,
908cc72361SWai Yew CHAY 		       const struct src_desc *desc, struct src **rsrc);
918cc72361SWai Yew CHAY 	/* return src resource */
928cc72361SWai Yew CHAY 	int (*put_src)(struct src_mgr *mgr, struct src *src);
938cc72361SWai Yew CHAY 	int (*src_enable_s)(struct src_mgr *mgr, struct src *src);
948cc72361SWai Yew CHAY 	int (*src_enable)(struct src_mgr *mgr, struct src *src);
958cc72361SWai Yew CHAY 	int (*src_disable)(struct src_mgr *mgr, struct src *src);
968cc72361SWai Yew CHAY 	int (*commit_write)(struct src_mgr *mgr);
978cc72361SWai Yew CHAY };
988cc72361SWai Yew CHAY 
998cc72361SWai Yew CHAY /* Define the descriptor of a SRC Input Mapper resource */
1008cc72361SWai Yew CHAY struct srcimp_mgr;
1018cc72361SWai Yew CHAY struct srcimp_rsc_ops;
1028cc72361SWai Yew CHAY 
1038cc72361SWai Yew CHAY struct srcimp {
1048cc72361SWai Yew CHAY 	struct rsc rsc;
1058cc72361SWai Yew CHAY 	unsigned char idx[8];
1068cc72361SWai Yew CHAY 	struct imapper *imappers;
1078cc72361SWai Yew CHAY 	unsigned int mapped; /* A bit-map indicating which conj rsc is mapped */
1088cc72361SWai Yew CHAY 	struct srcimp_mgr *mgr;
10943f2cdebSJulia Lawall 	const struct srcimp_rsc_ops *ops;
1108cc72361SWai Yew CHAY };
1118cc72361SWai Yew CHAY 
1128cc72361SWai Yew CHAY struct srcimp_rsc_ops {
1138cc72361SWai Yew CHAY 	int (*map)(struct srcimp *srcimp, struct src *user, struct rsc *input);
1148cc72361SWai Yew CHAY 	int (*unmap)(struct srcimp *srcimp);
1158cc72361SWai Yew CHAY };
1168cc72361SWai Yew CHAY 
1178cc72361SWai Yew CHAY /* Define SRCIMP resource request description info */
1188cc72361SWai Yew CHAY struct srcimp_desc {
1198cc72361SWai Yew CHAY 	unsigned int msr;
1208cc72361SWai Yew CHAY };
1218cc72361SWai Yew CHAY 
1228cc72361SWai Yew CHAY struct srcimp_mgr {
1238cc72361SWai Yew CHAY 	struct rsc_mgr mgr;	/* Basic resource manager info */
1243d0fdc86SSudip Mukherjee 	struct snd_card *card;	/* pointer to this card */
1258cc72361SWai Yew CHAY 	spinlock_t mgr_lock;
1268cc72361SWai Yew CHAY 	spinlock_t imap_lock;
1278cc72361SWai Yew CHAY 	struct list_head imappers;
1288cc72361SWai Yew CHAY 	struct imapper *init_imap;
1298cc72361SWai Yew CHAY 	unsigned int init_imap_added;
1308cc72361SWai Yew CHAY 
1318cc72361SWai Yew CHAY 	 /* request srcimp resource */
1328cc72361SWai Yew CHAY 	int (*get_srcimp)(struct srcimp_mgr *mgr,
1338cc72361SWai Yew CHAY 			  const struct srcimp_desc *desc,
1348cc72361SWai Yew CHAY 			  struct srcimp **rsrcimp);
1358cc72361SWai Yew CHAY 	/* return srcimp resource */
1368cc72361SWai Yew CHAY 	int (*put_srcimp)(struct srcimp_mgr *mgr, struct srcimp *srcimp);
1378cc72361SWai Yew CHAY 	int (*imap_add)(struct srcimp_mgr *mgr, struct imapper *entry);
1388cc72361SWai Yew CHAY 	int (*imap_delete)(struct srcimp_mgr *mgr, struct imapper *entry);
1398cc72361SWai Yew CHAY };
1408cc72361SWai Yew CHAY 
1418cc72361SWai Yew CHAY /* Constructor and destructor of SRC resource manager */
142*aabdedf4SArnd Bergmann int src_mgr_create(struct hw *hw, void **ptr);
143*aabdedf4SArnd Bergmann int src_mgr_destroy(void *ptr);
1448cc72361SWai Yew CHAY /* Constructor and destructor of SRCIMP resource manager */
145*aabdedf4SArnd Bergmann int srcimp_mgr_create(struct hw *hw, void **ptr);
146*aabdedf4SArnd Bergmann int srcimp_mgr_destroy(void *ptr);
1478cc72361SWai Yew CHAY 
1488cc72361SWai Yew CHAY #endif /* CTSRC_H */
149