18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/** 38c2ecf20Sopenharmony_ci * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * @File ctresource.h 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * @Brief 88c2ecf20Sopenharmony_ci * This file contains the definition of generic hardware resources for 98c2ecf20Sopenharmony_ci * resource management. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * @Author Liu Chun 128c2ecf20Sopenharmony_ci * @Date May 13 2008 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef CTRESOURCE_H 168c2ecf20Sopenharmony_ci#define CTRESOURCE_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/types.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cienum RSCTYP { 218c2ecf20Sopenharmony_ci SRC, 228c2ecf20Sopenharmony_ci SRCIMP, 238c2ecf20Sopenharmony_ci AMIXER, 248c2ecf20Sopenharmony_ci SUM, 258c2ecf20Sopenharmony_ci DAIO, 268c2ecf20Sopenharmony_ci NUM_RSCTYP /* This must be the last one and less than 16 */ 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct rsc_ops; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistruct rsc { 328c2ecf20Sopenharmony_ci u32 idx:12; /* The index of a resource */ 338c2ecf20Sopenharmony_ci u32 type:4; /* The type (RSCTYP) of a resource */ 348c2ecf20Sopenharmony_ci u32 conj:12; /* Current conjugate index */ 358c2ecf20Sopenharmony_ci u32 msr:4; /* The Master Sample Rate a resource working on */ 368c2ecf20Sopenharmony_ci void *ctrl_blk; /* Chip specific control info block for a resource */ 378c2ecf20Sopenharmony_ci struct hw *hw; /* Chip specific object for hardware access means */ 388c2ecf20Sopenharmony_ci const struct rsc_ops *ops; /* Generic resource operations */ 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct rsc_ops { 428c2ecf20Sopenharmony_ci void (*master)(struct rsc *rsc); /* Move to master resource */ 438c2ecf20Sopenharmony_ci void (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */ 448c2ecf20Sopenharmony_ci int (*index)(const struct rsc *rsc); /* Return the index of resource */ 458c2ecf20Sopenharmony_ci /* Return the output slot number */ 468c2ecf20Sopenharmony_ci int (*output_slot)(const struct rsc *rsc); 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciint 508c2ecf20Sopenharmony_cirsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, struct hw *hw); 518c2ecf20Sopenharmony_ciint rsc_uninit(struct rsc *rsc); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistruct rsc_mgr { 548c2ecf20Sopenharmony_ci enum RSCTYP type; /* The type (RSCTYP) of resource to manage */ 558c2ecf20Sopenharmony_ci unsigned int amount; /* The total amount of a kind of resource */ 568c2ecf20Sopenharmony_ci unsigned int avail; /* The amount of currently available resources */ 578c2ecf20Sopenharmony_ci unsigned char *rscs; /* The bit-map for resource allocation */ 588c2ecf20Sopenharmony_ci void *ctrl_blk; /* Chip specific control info block */ 598c2ecf20Sopenharmony_ci struct hw *hw; /* Chip specific object for hardware access */ 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* Resource management is based on bit-map mechanism */ 638c2ecf20Sopenharmony_ciint rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type, 648c2ecf20Sopenharmony_ci unsigned int amount, struct hw *hw); 658c2ecf20Sopenharmony_ciint rsc_mgr_uninit(struct rsc_mgr *mgr); 668c2ecf20Sopenharmony_ciint mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx); 678c2ecf20Sopenharmony_ciint mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#endif /* CTRESOURCE_H */ 70