1 /* compress_plugin.h 2 ** 3 ** Copyright (c) 2019, The Linux Foundation. All rights reserved. 4 ** 5 ** Redistribution and use in source and binary forms, with or without 6 ** modification, are permitted provided that the following conditions are 7 ** met: 8 ** * Redistributions of source code must retain the above copyright 9 ** notice, this list of conditions and the following disclaimer. 10 ** * Redistributions in binary form must reproduce the above 11 ** copyright notice, this list of conditions and the following 12 ** disclaimer in the documentation and/or other materials provided 13 ** with the distribution. 14 ** * Neither the name of The Linux Foundation nor the names of its 15 ** contributors may be used to endorse or promote products derived 16 ** from this software without specific prior written permission. 17 ** 18 ** THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 19 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 21 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 ** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 ** BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 28 ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 **/ 30 31 #ifndef __COMPRESS_PLUGIN_H__ 32 #define __COMPRESS_PLUGIN_H__ 33 34 #include "sound/compress_params.h" 35 #include "sound/compress_offload.h" 36 37 #define COMPRESS_PLUGIN_OPEN_FN(name) \ 38 int name##_open(struct compress_plugin **plugin, \ 39 unsigned int card, \ 40 unsigned int device, \ 41 unsigned int flags) 42 43 #define COMPRESS_PLUGIN_OPEN_FN_PTR() \ 44 int (*plugin_open_fn) (struct compress_plugin **plugin, \ 45 unsigned int card, \ 46 unsigned int device, \ 47 unsigned int flags); 48 49 struct compress_plugin; 50 51 struct compress_plugin_ops { 52 void (*close) (struct compress_plugin *plugin); 53 int (*get_caps) (struct compress_plugin *plugin, 54 struct snd_compr_caps *caps); 55 int (*set_params) (struct compress_plugin *plugin, 56 struct snd_compr_params *params); 57 int (*avail) (struct compress_plugin *plugin, 58 struct snd_compr_avail *avail); 59 int (*tstamp) (struct compress_plugin *plugin, 60 struct snd_compr_tstamp *tstamp); 61 int (*write) (struct compress_plugin *plugin, 62 const void *buf, size_t size); 63 int (*read) (struct compress_plugin *plugin, 64 void *buf, size_t size); 65 int (*start) (struct compress_plugin *plugin); 66 int (*stop) (struct compress_plugin *plugin); 67 int (*pause) (struct compress_plugin *plugin); 68 int (*resume) (struct compress_plugin *plugin); 69 int (*drain) (struct compress_plugin *plugin); 70 int (*partial_drain) (struct compress_plugin *plugin); 71 int (*next_track) (struct compress_plugin *plugin); 72 int (*ioctl) (struct compress_plugin *plugin, int cmd, ...); 73 int (*poll) (struct compress_plugin *plugin, 74 struct pollfd *fds, nfds_t nfds, int timeout); 75 }; 76 77 struct compress_plugin { 78 unsigned int card; 79 80 struct compress_plugin_ops *ops; 81 82 void *node; 83 int mode; 84 void *priv; 85 86 unsigned int state; 87 }; 88 89 #endif /* end of __COMPRESS_PLUGIN_H__ */ 90