Changeset 2e01b3f in mainline


Ignore:
Timestamp:
2012-07-19T17:43:47Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f0241bda
Parents:
c5cbc1b7
Message:

libdrv: Add method to query audio capabilities.

Location:
uspace/lib/drv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_audio_pcm.c

    rc5cbc1b7 r2e01b3f  
    4545typedef enum {
    4646        IPC_M_AUDIO_PCM_GET_INFO_STR,
     47        IPC_M_AUDIO_PCM_QUERY_CAPS,
    4748        IPC_M_AUDIO_PCM_TEST_FORMAT,
    4849        IPC_M_AUDIO_PCM_GET_BUFFER,
     
    104105        }
    105106        async_exchange_end(exch);
     107        return ret;
     108}
     109
     110int audio_pcm_query_cap(audio_pcm_sess_t *sess, audio_cap_t cap, unsigned *val)
     111{
     112        if (!val)
     113                return EINVAL;
     114        async_exch_t *exch = async_exchange_begin(sess);
     115        sysarg_t value = *val;
     116        const int ret = async_req_2_1(exch,
     117            DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_QUERY_CAPS,
     118            value, &value);
     119        if (ret == EOK)
     120                *val = value;
    106121        return ret;
    107122}
     
    232247 */
    233248static void remote_audio_pcm_get_info_str(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     249static void remote_audio_pcm_query_caps(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    234250static void remote_audio_pcm_test_format(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    235251static void remote_audio_pcm_get_buffer(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    243259static remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = {
    244260        [IPC_M_AUDIO_PCM_GET_INFO_STR] = remote_audio_pcm_get_info_str,
     261        [IPC_M_AUDIO_PCM_QUERY_CAPS] = remote_audio_pcm_query_caps,
    245262        [IPC_M_AUDIO_PCM_TEST_FORMAT] = remote_audio_pcm_test_format,
    246263        [IPC_M_AUDIO_PCM_GET_BUFFER] = remote_audio_pcm_get_buffer,
     
    288305}
    289306
    290 static void remote_audio_pcm_test_format(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     307void remote_audio_pcm_query_caps(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     308{
     309        const audio_pcm_iface_t *pcm_iface = iface;
     310        const audio_cap_t cap = DEV_IPC_GET_ARG1(*call);
     311        if (pcm_iface->query_cap) {
     312                const unsigned value = pcm_iface->query_cap(fun, cap);
     313                async_answer_1(callid, EOK, value);
     314        } else {
     315                async_answer_0(callid, ENOTSUP);
     316        }
     317}
     318
     319void remote_audio_pcm_test_format(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
    291320{
    292321        const audio_pcm_iface_t *pcm_iface = iface;
  • uspace/lib/drv/include/audio_pcm_iface.h

    rc5cbc1b7 r2e01b3f  
    4444#include "ddf/driver.h"
    4545
     46typedef enum {
     47        AUDIO_CAP_RECORD,
     48        AUDIO_CAP_PLAYBACK,
     49        AUDIO_CAP_MAX_BUFFER,
     50        AUDIO_CAP_BUFFER_POS,
     51        AUDIO_CAP_INTERRUPT,
     52        AUDIO_CAP_INTERRUPT_MIN_FRAMES,
     53        AUDIO_CAP_INTERRUPT_MAX_FRAMES,
     54} audio_cap_t;
     55
    4656enum {
    4757        PCM_EVENT_FRAMES_PLAYED = IPC_FIRST_USER_METHOD,
     
    6070int audio_pcm_test_format(audio_pcm_sess_t *, unsigned *, unsigned *,
    6171    pcm_sample_format_t *);
     72int audio_pcm_query_cap(audio_pcm_sess_t *, audio_cap_t, unsigned *);
    6273
    6374int audio_pcm_get_buffer(audio_pcm_sess_t *, void **, size_t *,
     
    7889        int (*test_format)(ddf_fun_t *, unsigned *, unsigned *,
    7990            pcm_sample_format_t *);
     91        unsigned (*query_cap)(ddf_fun_t *, audio_cap_t);
    8092        int (*get_buffer)(ddf_fun_t *, void **, size_t *);
    8193        int (*release_buffer)(ddf_fun_t *);
Note: See TracChangeset for help on using the changeset viewer.