Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef __SOUND_SOUNDFONT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define __SOUND_SOUNDFONT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Soundfont defines and definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  Copyright (C) 1999 Steve Ratcliffe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Copyright (c) 1999-2000 Takashi iwai <tiwai@suse.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <sound/sfnt_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <sound/util_mem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define SF_MAX_INSTRUMENTS	128	/* maximum instrument number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define SF_MAX_PRESETS  256	/* drums are mapped from 128 to 256 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define SF_IS_DRUM_BANK(z) ((z) == 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct snd_sf_zone {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	struct snd_sf_zone *next;	/* Link to next */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	unsigned char bank;		/* Midi bank for this zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	unsigned char instr;		/* Midi program for this zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	unsigned char mapped;		/* True if mapped to something else */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct soundfont_voice_info v;	/* All the soundfont parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	int counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct snd_sf_sample *sample;	/* Link to sample */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	/* The following deals with preset numbers (programs) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct snd_sf_zone *next_instr;	/* Next zone of this instrument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct snd_sf_zone *next_zone;	/* Next zone in play list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) struct snd_sf_sample {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct soundfont_sample_info v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct snd_util_memblk *block;	/* allocated data block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct snd_sf_sample *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * This represents all the information relating to a soundfont.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) struct snd_soundfont {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct snd_soundfont *next;	/* Link to next */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	/*struct snd_soundfont *prev;*/	/* Link to previous */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	short  id;		/* file id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	short  type;		/* font type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	unsigned char name[SNDRV_SFNT_PATCH_NAME_LEN];	/* identifier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct snd_sf_zone *zones; /* Font information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct snd_sf_sample *samples; /* The sample headers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * Type of the sample access callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) struct snd_sf_callback {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	void *private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	int (*sample_new)(void *private_data, struct snd_sf_sample *sp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			  struct snd_util_memhdr *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			  const void __user *buf, long count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int (*sample_free)(void *private_data, struct snd_sf_sample *sp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			   struct snd_util_memhdr *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	void (*sample_reset)(void *private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * List of soundfonts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) struct snd_sf_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct snd_soundfont *currsf; /* The currently open soundfont */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	int open_client;	/* client pointer for lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	int mem_used;		/* used memory size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct snd_sf_zone *presets[SF_MAX_PRESETS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct snd_soundfont *fonts; /* The list of soundfonts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	int fonts_size;	/* number of fonts allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	int zone_counter;	/* last allocated time for zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int sample_counter;	/* last allocated time for sample */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	int zone_locked;	/* locked time for zone */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	int sample_locked;	/* locked time for sample */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct snd_sf_callback callback;	/* callback functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int presets_locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct mutex presets_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	struct snd_util_memhdr *memhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) /* Prototypes for soundfont.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) int snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		       long count, int client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				long count, int client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) int snd_soundfont_close_check(struct snd_sf_list *sflist, int client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) struct snd_sf_list *snd_sf_new(struct snd_sf_callback *callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			       struct snd_util_memhdr *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) void snd_sf_free(struct snd_sf_list *sflist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) int snd_soundfont_remove_samples(struct snd_sf_list *sflist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int snd_soundfont_remove_unlocked(struct snd_sf_list *sflist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			      int preset, int bank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			      int def_preset, int def_bank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			      struct snd_sf_zone **table, int max_layers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* Parameter conversions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int snd_sf_calc_parm_hold(int msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int snd_sf_calc_parm_attack(int msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int snd_sf_calc_parm_decay(int msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define snd_sf_calc_parm_delay(msec) (0x8000 - (msec) * 1000 / 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) extern int snd_sf_vol_table[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int snd_sf_linear_to_log(unsigned int amount, int offset, int ratio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif /* __SOUND_SOUNDFONT_H */