Changes in / [73e894c:749fe15b] in mainline


Ignore:
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r73e894c r749fe15b  
    2020kernel/arch/amd64/include/arch/common.h
    2121kernel/generic/src/debug/real_map.bin
     22uspace/app/barber/barber
     23uspace/app/barber/images.c
     24uspace/app/barber/images.h
    2225uspace/app/bdsh/bdsh
    2326uspace/app/bdsh/test-bdsh
     
    2528uspace/app/blkdump/blkdump
    2629uspace/app/bnchmark/bnchmark
     30uspace/drv/char/pl050/pl050
    2731uspace/app/date/date
    2832uspace/app/devctl/devctl
     
    4448uspace/app/mkfat/mkfat
    4549uspace/app/mkmfs/mkmfs
     50uspace/app/modplay/modplay
    4651uspace/app/netecho/netecho
    4752uspace/app/nettest1/nettest1
     
    5257uspace/app/ping/ping
    5358uspace/app/ping6/ping6
     59uspace/app/rcubench/rcubench
     60uspace/app/rcutest/rcutest
    5461uspace/app/redir/redir
    5562uspace/app/sbi/sbi
     
    7380uspace/app/wavplay/wavplay
    7481uspace/app/websrv/websrv
     82uspace/dist/app/barber
    7583uspace/dist/app/bdsh
    7684uspace/dist/app/bithenge
     
    95103uspace/dist/app/mkfat
    96104uspace/dist/app/mkmfs
     105uspace/dist/app/modplay
    97106uspace/dist/app/netecho
    98107uspace/dist/app/nettest1
     
    103112uspace/dist/app/ping
    104113uspace/dist/app/ping6
     114uspace/dist/app/rcubench
     115uspace/dist/app/rcutest
    105116uspace/dist/app/redir
    106117uspace/dist/app/sbi
     
    134145uspace/dist/drv/ns8250/
    135146uspace/dist/drv/ohci/
     147uspace/dist/drv/pc/
    136148uspace/dist/drv/pciintel/
    137149uspace/dist/drv/ps2mouse/
     
    209221uspace/drv/root/root/root
    210222uspace/drv/root/virt/virt
     223uspace/drv/platform/icp/icp
     224uspace/drv/platform/pc/pc
    211225uspace/drv/platform/rootpc/rootpc
    212226uspace/drv/nic/e1k/e1k
  • uspace/app/wavplay/drec.c

    r73e894c r749fe15b  
    4747
    4848
    49 #define BUFFER_PARTS   2
     49#define BUFFER_PARTS   16
    5050
    5151/** Recording format */
     
    103103                        printf("Recording terminated\n");
    104104                        record = false;
     105                        break;
    105106                case PCM_EVENT_FRAMES_CAPTURED:
    106107                        printf("%" PRIun " frames\n", IPC_GET_ARG1(call));
    107                         async_answer_0(callid, EOK);
    108108                        break;
    109109                default:
     
    111111                        async_answer_0(callid, ENOTSUP);
    112112                        continue;
    113 
     113                }
     114
     115                if (!record) {
     116                        async_answer_0(callid, EOK);
     117                        break;
    114118                }
    115119
     
    156160        printf("\n");
    157161        audio_pcm_stop_capture(rec->device);
     162        /* XXX Control returns even before we can be sure callbacks finished */
     163        printf("Delay before playback termination\n");
     164        async_usleep(1000000);
     165        printf("Terminate playback\n");
    158166}
    159167
  • uspace/app/wavplay/main.c

    r73e894c r749fe15b  
    308308                        if (direct) {
    309309                                drecord(device, file);
     310                                continue;
    310311                        } else {
    311312                                printf("Indirect recording is not supported "
  • uspace/app/wavplay/wave.c

    r73e894c r749fe15b  
    116116                *channels = uint16_t_le2host(header->channels);
    117117        if (format) {
    118                 const unsigned size = uint32_t_le2host(header->sample_size);
     118                const unsigned size = uint16_t_le2host(header->sample_size);
    119119                switch (size) {
    120120                case 8: *format = PCM_SAMPLE_UINT8; break;
     
    157157        header->channels = host2uint32_t_le(format.channels);
    158158        header->sample_size =
    159             host2uint32_t_le(pcm_sample_format_size(format.sample_format));
     159            host2uint16_t_le(pcm_sample_format_size(format.sample_format) * 8);
    160160}
    161161/**
  • uspace/drv/audio/hdaudio/codec.c

    r73e894c r749fe15b  
    437437        }
    438438
     439        if ((pcaps & BIT_V(uint32_t, pwc_input)) != 0) {
     440                ddf_msg(LVL_NOTE, "PIN %d will enable input", aw);
     441                pctl = pctl | BIT_V(uint8_t, pctl_in_enable);
     442        }
     443
    439444        if ((pcaps & BIT_V(uint32_t, pwc_hpd)) != 0) {
    440445                ddf_msg(LVL_NOTE, "PIN %d will enable headphone drive", aw);
     
    503508        codec->hda = hda;
    504509        codec->address = address;
     510        codec->in_aw = -1;
    505511
    506512        rc = hda_get_subnc(codec, 0, &sfg, &nfg);
     
    587593                                ddf_msg(LVL_NOTE, "Output widget %d: rates=0x%x formats=0x%x",
    588594                                    aw, rates, formats);
     595                        } else if (awtype == awt_audio_input) {
     596                                if (codec->in_aw < 0) {
     597                                        ddf_msg(LVL_NOTE, "Selected input "
     598                                            "widget %d\n", aw);
     599                                        codec->in_aw = aw;
     600                                } else {
     601                                        ddf_msg(LVL_NOTE, "Ignoring input "
     602                                            "widget %d\n", aw);
     603                                }
     604
     605                                rc = hda_get_supp_rates(codec, aw, &rates);
     606                                if (rc != EOK)
     607                                        goto error;
     608
     609                                rc = hda_get_supp_formats(codec, aw, &formats);
     610                                if (rc != EOK)
     611                                        goto error;
     612
     613                                ddf_msg(LVL_NOTE, "Input widget %d: rates=0x%x formats=0x%x",
     614                                    aw, rates, formats);
    589615                        }
    590616
     
    623649                /* Configure converter */
    624650
    625                 ddf_msg(LVL_NOTE, "Configure converter format");
     651                ddf_msg(LVL_NOTE, "Configure output converter format");
    626652                rc = hda_set_converter_fmt(codec, out_aw, stream->fmt);
    627653                if (rc != EOK)
    628654                        goto error;
    629655
    630                 ddf_msg(LVL_NOTE, "Configure converter stream, channel");
     656                ddf_msg(LVL_NOTE, "Configure output converter stream, channel");
    631657                rc = hda_set_converter_ctl(codec, out_aw, stream->sid, 0);
    632658                if (rc != EOK)
    633659                        goto error;
    634660        }
     661
     662        return EOK;
     663error:
     664        return rc;
     665}
     666
     667int hda_in_converter_setup(hda_codec_t *codec, hda_stream_t *stream)
     668{
     669        int rc;
     670
     671        /* Configure converter */
     672
     673        ddf_msg(LVL_NOTE, "Configure input converter format");
     674        rc = hda_set_converter_fmt(codec, codec->in_aw, stream->fmt);
     675        if (rc != EOK)
     676                goto error;
     677
     678        ddf_msg(LVL_NOTE, "Configure input converter stream, channel");
     679        rc = hda_set_converter_ctl(codec, codec->in_aw, stream->sid, 0);
     680        if (rc != EOK)
     681                goto error;
    635682
    636683        return EOK;
  • uspace/drv/audio/hdaudio/codec.h

    r73e894c r749fe15b  
    4747        int out_aw_num;
    4848        int out_aw_sel;
     49        int in_aw;
    4950} hda_codec_t;
    5051
     
    5253extern void hda_codec_fini(hda_codec_t *);
    5354extern int hda_out_converter_setup(hda_codec_t *, hda_stream_t *);
     55extern int hda_in_converter_setup(hda_codec_t *, hda_stream_t *);
    5456
    5557#endif
  • uspace/drv/audio/hdaudio/hdactl.c

    r73e894c r749fe15b  
    562562        ctl->bss = BIT_RANGE_EXTRACT(uint16_t, gcap_bss_h, gcap_bss_l, gcap);
    563563        ddf_msg(LVL_NOTE, "GCAP: 0x%x (64OK=%d)", gcap, ctl->ok64bit);
    564 
     564        ddf_msg(LVL_NOTE, "iss: %d, oss: %d, bss: %d\n",
     565            ctl->iss, ctl->oss, ctl->bss);
    565566        /* Give codecs enough time to enumerate themselves */
    566567        async_usleep(codec_enum_wait_us);
  • uspace/drv/audio/hdaudio/hdaudio.c

    r73e894c r749fe15b  
    385385                        hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED);
    386386                        hda_pcm_event(hda, PCM_EVENT_FRAMES_PLAYED);
     387                } else if (hda->capturing) {
     388                        hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED);
     389                        hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED);
     390                        hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED);
     391                        hda_pcm_event(hda, PCM_EVENT_FRAMES_CAPTURED);
    387392                }
     393
    388394                hda_unlock(hda);
    389395        }
  • uspace/drv/audio/hdaudio/hdaudio.h

    r73e894c r749fe15b  
    5555        struct hda_ctl *ctl;
    5656        struct hda_stream *pcm_stream;
     57        struct hda_stream_buffers *pcm_buffers;
    5758        bool playing;
     59        bool capturing;
    5860} hda_t;
    5961
  • uspace/drv/audio/hdaudio/pcm_iface.c

    r73e894c r749fe15b  
    100100static unsigned hda_query_cap(ddf_fun_t *fun, audio_cap_t cap)
    101101{
     102        hda_t *hda = fun_to_hda(fun);
     103
    102104        ddf_msg(LVL_NOTE, "hda_query_cap(%d)", cap);
    103105        switch (cap) {
    104106        case AUDIO_CAP_PLAYBACK:
    105107        case AUDIO_CAP_INTERRUPT:
     108                /* XXX Only if we have an output converter */
    106109                return 1;
     110        case AUDIO_CAP_CAPTURE:
     111                /* Yes if we have an input converter */
     112                return hda->ctl->codec->in_aw >= 0;
    107113        case AUDIO_CAP_BUFFER_POS:
    108         case AUDIO_CAP_CAPTURE:
    109114                return 0;
    110115        case AUDIO_CAP_MAX_BUFFER:
     
    148153{
    149154        hda_t *hda = fun_to_hda(fun);
     155        int rc;
    150156
    151157        hda_lock(hda);
    152158
    153159        ddf_msg(LVL_NOTE, "hda_get_buffer(): hda=%p", hda);
     160        if (hda->pcm_buffers != NULL) {
     161                hda_unlock(hda);
     162                return EBUSY;
     163        }
     164
     165        ddf_msg(LVL_NOTE, "hda_get_buffer() - allocate stream buffers");
     166        rc = hda_stream_buffers_alloc(hda, &hda->pcm_buffers);
     167        if (rc != EOK) {
     168                assert(rc == ENOMEM);
     169                hda_unlock(hda);
     170                return ENOMEM;
     171        }
     172
     173        ddf_msg(LVL_NOTE, "hda_get_buffer() - fill info");
     174        /* XXX This is only one buffer */
     175        *buffer = hda->pcm_buffers->buf[0];
     176        *size = hda->pcm_buffers->bufsize * hda->pcm_buffers->nbuffers;
     177
     178        ddf_msg(LVL_NOTE, "hda_get_buffer() returing EOK, buffer=%p, size=%zu",
     179            *buffer, *size);
     180
     181        hda_unlock(hda);
     182        return EOK;
     183}
     184
     185static int hda_get_buffer_position(ddf_fun_t *fun, size_t *pos)
     186{
     187        ddf_msg(LVL_NOTE, "hda_get_buffer_position()");
     188        return ENOTSUP;
     189}
     190
     191static int hda_set_event_session(ddf_fun_t *fun, async_sess_t *sess)
     192{
     193        hda_t *hda = fun_to_hda(fun);
     194
     195        ddf_msg(LVL_NOTE, "hda_set_event_session()");
     196        hda_lock(hda);
     197        hda->ev_sess = sess;
     198        hda_unlock(hda);
     199
     200        return EOK;
     201}
     202
     203static async_sess_t *hda_get_event_session(ddf_fun_t *fun)
     204{
     205        hda_t *hda = fun_to_hda(fun);
     206        async_sess_t *sess;
     207
     208        ddf_msg(LVL_NOTE, "hda_get_event_session()");
     209
     210        hda_lock(hda);
     211        sess = hda->ev_sess;
     212        hda_unlock(hda);
     213
     214        return sess;
     215}
     216
     217static int hda_release_buffer(ddf_fun_t *fun)
     218{
     219        hda_t *hda = fun_to_hda(fun);
     220
     221        hda_lock(hda);
     222
     223        ddf_msg(LVL_NOTE, "hda_release_buffer()");
     224        if (hda->pcm_buffers == NULL) {
     225                hda_unlock(hda);
     226                return EINVAL;
     227        }
     228
     229        hda_stream_buffers_free(hda->pcm_buffers);
     230        hda->pcm_buffers = NULL;
     231
     232        hda_unlock(hda);
     233        return EOK;
     234}
     235
     236static int hda_start_playback(ddf_fun_t *fun, unsigned frames,
     237    unsigned channels, unsigned rate, pcm_sample_format_t format)
     238{
     239        hda_t *hda = fun_to_hda(fun);
     240        int rc;
     241
     242        ddf_msg(LVL_NOTE, "hda_start_playback()");
     243        hda_lock(hda);
     244
    154245        if (hda->pcm_stream != NULL) {
    155246                hda_unlock(hda);
     
    162253        fmt = (fmt_base_44khz << fmt_base) | (fmt_bits_16 << fmt_bits_l) | 1;
    163254
    164         ddf_msg(LVL_NOTE, "hda_get_buffer() - create stream");
    165         hda->pcm_stream = hda_stream_create(hda, sdir_output, fmt);
     255        ddf_msg(LVL_NOTE, "hda_start_playback() - create output stream");
     256        hda->pcm_stream = hda_stream_create(hda, sdir_output, hda->pcm_buffers,
     257            fmt);
    166258        if (hda->pcm_stream == NULL) {
    167259                hda_unlock(hda);
    168260                return EIO;
    169261        }
    170 
    171         ddf_msg(LVL_NOTE, "hda_get_buffer() - fill info");
    172         /* XXX This is only one buffer */
    173         *buffer = hda->pcm_stream->buf[0];
    174         *size = hda->pcm_stream->bufsize * hda->pcm_stream->nbuffers;
    175 
    176         ddf_msg(LVL_NOTE, "hda_get_buffer() retturing EOK, buffer=%p, size=%zu",
    177             *buffer, *size);
    178 
    179         hda_unlock(hda);
    180         return EOK;
    181 }
    182 
    183 static int hda_get_buffer_position(ddf_fun_t *fun, size_t *pos)
    184 {
    185         ddf_msg(LVL_NOTE, "hda_get_buffer_position()");
    186         return ENOTSUP;
    187 }
    188 
    189 static int hda_set_event_session(ddf_fun_t *fun, async_sess_t *sess)
    190 {
    191         hda_t *hda = fun_to_hda(fun);
    192 
    193         ddf_msg(LVL_NOTE, "hda_set_event_session()");
    194         hda_lock(hda);
    195         hda->ev_sess = sess;
    196         hda_unlock(hda);
    197 
    198         return EOK;
    199 }
    200 
    201 static async_sess_t *hda_get_event_session(ddf_fun_t *fun)
    202 {
    203         hda_t *hda = fun_to_hda(fun);
    204         async_sess_t *sess;
    205 
    206         ddf_msg(LVL_NOTE, "hda_get_event_session()");
    207 
    208         hda_lock(hda);
    209         sess = hda->ev_sess;
    210         hda_unlock(hda);
    211 
    212         return sess;
    213 }
    214 
    215 static int hda_release_buffer(ddf_fun_t *fun)
    216 {
    217         hda_t *hda = fun_to_hda(fun);
    218 
    219         hda_lock(hda);
    220 
    221         ddf_msg(LVL_NOTE, "hda_release_buffer()");
    222         if (hda->pcm_stream == NULL) {
    223                 hda_unlock(hda);
    224                 return EINVAL;
    225         }
    226 
    227         hda_stream_destroy(hda->pcm_stream);
    228         hda->pcm_stream = NULL;
    229 
    230         hda_unlock(hda);
    231         return EOK;
    232 }
    233 
    234 static int hda_start_playback(ddf_fun_t *fun, unsigned frames,
    235     unsigned channels, unsigned rate, pcm_sample_format_t format)
    236 {
    237         hda_t *hda = fun_to_hda(fun);
    238         int rc;
    239 
    240         ddf_msg(LVL_NOTE, "hda_start_playback()");
    241         hda_lock(hda);
    242262
    243263        rc = hda_out_converter_setup(hda->ctl->codec, hda->pcm_stream);
    244264        if (rc != EOK) {
     265                hda_stream_destroy(hda->pcm_stream);
     266                hda->pcm_stream = NULL;
    245267                hda_unlock(hda);
    246268                return rc;
    247269        }
    248270
     271        hda->playing = true;
    249272        hda_stream_start(hda->pcm_stream);
    250         hda->playing = true;
    251273        hda_unlock(hda);
    252274        return EOK;
     
    262284        hda_stream_reset(hda->pcm_stream);
    263285        hda->playing = false;
     286        hda_stream_destroy(hda->pcm_stream);
     287        hda->pcm_stream = NULL;
     288
    264289        hda_unlock(hda);
    265290
     
    271296    unsigned rate, pcm_sample_format_t format)
    272297{
     298        hda_t *hda = fun_to_hda(fun);
     299        int rc;
     300
    273301        ddf_msg(LVL_NOTE, "hda_start_capture()");
    274         return ENOTSUP;
     302        hda_lock(hda);
     303
     304        if (hda->pcm_stream != NULL) {
     305                hda_unlock(hda);
     306                return EBUSY;
     307        }
     308
     309        /* XXX Choose appropriate parameters */
     310        uint32_t fmt;
     311        /* 48 kHz, 16-bits, 1 channel */
     312        fmt = (fmt_base_44khz << fmt_base) | (fmt_bits_16 << fmt_bits_l) | 1;
     313
     314        ddf_msg(LVL_NOTE, "hda_start_capture() - create input stream");
     315        hda->pcm_stream = hda_stream_create(hda, sdir_input, hda->pcm_buffers,
     316            fmt);
     317        if (hda->pcm_stream == NULL) {
     318                hda_unlock(hda);
     319                return EIO;
     320        }
     321
     322        rc = hda_in_converter_setup(hda->ctl->codec, hda->pcm_stream);
     323        if (rc != EOK) {
     324                hda_stream_destroy(hda->pcm_stream);
     325                hda->pcm_stream = NULL;
     326                hda_unlock(hda);
     327                return rc;
     328        }
     329
     330        hda->capturing = true;
     331        hda_stream_start(hda->pcm_stream);
     332        hda_unlock(hda);
     333        return EOK;
    275334}
    276335
    277336static int hda_stop_capture(ddf_fun_t *fun, bool immediate)
    278337{
     338        hda_t *hda = fun_to_hda(fun);
     339
    279340        ddf_msg(LVL_NOTE, "hda_stop_capture()");
    280         return ENOTSUP;
     341        hda_lock(hda);
     342        hda_stream_stop(hda->pcm_stream);
     343        hda_stream_reset(hda->pcm_stream);
     344        hda->capturing = false;
     345        hda_stream_destroy(hda->pcm_stream);
     346        hda->pcm_stream = NULL;
     347        hda_unlock(hda);
     348
     349        hda_pcm_event(hda, PCM_EVENT_CAPTURE_TERMINATED);
     350        return EOK;
    281351}
    282352
  • uspace/drv/audio/hdaudio/stream.c

    r73e894c r749fe15b  
    4848#include "stream.h"
    4949
    50 static int hda_stream_buffers_alloc(hda_stream_t *stream)
     50int hda_stream_buffers_alloc(hda_t *hda, hda_stream_buffers_t **rbufs)
    5151{
    5252        void *bdl;
    5353        void *buffer;
    5454        uintptr_t buffer_phys;
     55        hda_stream_buffers_t *bufs = NULL;
    5556        size_t i;
    5657//      size_t j, k;
    5758        int rc;
    5859
    59         stream->nbuffers = 4;
    60         stream->bufsize = 16384;
     60        bufs = calloc(1, sizeof(hda_stream_buffers_t));
     61        if (bufs == NULL) {
     62                rc = ENOMEM;
     63                goto error;
     64        }
     65
     66        bufs->nbuffers = 4;
     67        bufs->bufsize = 16384;
    6168
    6269        /*
     
    6572         */
    6673        bdl = AS_AREA_ANY;
    67         rc = dmamem_map_anonymous(stream->nbuffers * sizeof(hda_buffer_desc_t),
    68             stream->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
    69             0, &stream->bdl_phys, &bdl);
     74        rc = dmamem_map_anonymous(bufs->nbuffers * sizeof(hda_buffer_desc_t),
     75            hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
     76            0, &bufs->bdl_phys, &bdl);
    7077        if (rc != EOK)
    7178                goto error;
    7279
    73         stream->bdl = bdl;
     80        bufs->bdl = bdl;
    7481
    7582        /* Allocate arrays of buffer pointers */
    7683
    77         stream->buf = calloc(stream->nbuffers, sizeof(void *));
    78         if (stream->buf == NULL)
    79                 goto error;
    80 
    81         stream->buf_phys = calloc(stream->nbuffers, sizeof(uintptr_t));
    82         if (stream->buf_phys == NULL)
     84        bufs->buf = calloc(bufs->nbuffers, sizeof(void *));
     85        if (bufs->buf == NULL)
     86                goto error;
     87
     88        bufs->buf_phys = calloc(bufs->nbuffers, sizeof(uintptr_t));
     89        if (bufs->buf_phys == NULL)
    8390                goto error;
    8491
    8592        /* Allocate buffers */
    8693/*
    87         for (i = 0; i < stream->nbuffers; i++) {
     94        for (i = 0; i < bufs->nbuffers; i++) {
    8895                buffer = AS_AREA_ANY;
    89                 rc = dmamem_map_anonymous(stream->bufsize,
    90                     stream->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
     96                rc = dmamem_map_anonymous(bufs->bufsize,
     97                    bufs->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
    9198                    0, &buffer_phys, &buffer);
    9299                if (rc != EOK)
     
    96103                    (unsigned long long)buffer_phys, buffer);
    97104
    98                 stream->buf[i] = buffer;
    99                 stream->buf_phys[i] = buffer_phys;
     105                bufs->buf[i] = buffer;
     106                bufs->buf_phys[i] = buffer_phys;
    100107
    101108                k = 0;
    102                 for (j = 0; j < stream->bufsize / 2; j++) {
    103                         int16_t *bp = stream->buf[i];
     109                for (j = 0; j < bufs->bufsize / 2; j++) {
     110                        int16_t *bp = bufs->buf[i];
    104111                        bp[j] = (k > 128) ? -100 : 100;
    105112                        ++k;
     
    111118        /* audio_pcm_iface requires a single contiguous buffer */
    112119        buffer = AS_AREA_ANY;
    113         rc = dmamem_map_anonymous(stream->bufsize * stream->nbuffers,
    114             stream->hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
     120        rc = dmamem_map_anonymous(bufs->bufsize * bufs->nbuffers,
     121            hda->ctl->ok64bit ? 0 : DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
    115122            0, &buffer_phys, &buffer);
    116123        if (rc != EOK) {
     
    119126        }
    120127
    121         for (i = 0; i < stream->nbuffers; i++) {
    122                 stream->buf[i] = buffer + i * stream->bufsize;
    123                 stream->buf_phys[i] = buffer_phys + i * stream->bufsize;
     128        for (i = 0; i < bufs->nbuffers; i++) {
     129                bufs->buf[i] = buffer + i * bufs->bufsize;
     130                bufs->buf_phys[i] = buffer_phys + i * bufs->bufsize;
    124131
    125132                ddf_msg(LVL_NOTE, "Stream buf phys=0x%llx virt=%p",
    126                     (long long unsigned)(uintptr_t)stream->buf[i],
    127                     (void *)stream->buf_phys[i]);
     133                    (long long unsigned)(uintptr_t)bufs->buf[i],
     134                    (void *)bufs->buf_phys[i]);
    128135/*              k = 0;
    129                 for (j = 0; j < stream->bufsize / 2; j++) {
    130                         int16_t *bp = stream->buf[i];
     136                for (j = 0; j < bufs->bufsize / 2; j++) {
     137                        int16_t *bp = bufs->buf[i];
    131138                        bp[j] = (k > 128) ? -10000 : 10000;
    132139                        ++k;
     
    138145
    139146        /* Fill in BDL */
    140         for (i = 0; i < stream->nbuffers; i++) {
    141                 stream->bdl[i].address = host2uint64_t_le(stream->buf_phys[i]);
    142                 stream->bdl[i].length = host2uint32_t_le(stream->bufsize);
    143                 stream->bdl[i].flags = BIT_V(uint32_t, bdf_ioc);
    144         }
    145 
     147        for (i = 0; i < bufs->nbuffers; i++) {
     148                bufs->bdl[i].address = host2uint64_t_le(bufs->buf_phys[i]);
     149                bufs->bdl[i].length = host2uint32_t_le(bufs->bufsize);
     150                bufs->bdl[i].flags = BIT_V(uint32_t, bdf_ioc);
     151        }
     152
     153        *rbufs = bufs;
    146154        return EOK;
    147155error:
     156        hda_stream_buffers_free(bufs);
    148157        return ENOMEM;
    149158}
    150159
     160void hda_stream_buffers_free(hda_stream_buffers_t *bufs)
     161{
     162        if (bufs == NULL)
     163                return;
     164
     165        /* XXX */
     166        free(bufs);
     167}
     168
    151169static void hda_stream_desc_configure(hda_stream_t *stream)
    152170{
    153171        hda_sdesc_regs_t *sdregs;
     172        hda_stream_buffers_t *bufs = stream->buffers;
    154173        uint8_t ctl1;
    155174        uint8_t ctl3;
     
    161180        hda_reg8_write(&sdregs->ctl3, ctl3);
    162181        hda_reg8_write(&sdregs->ctl1, ctl1);
    163         hda_reg32_write(&sdregs->cbl, stream->nbuffers * stream->bufsize);
    164         hda_reg16_write(&sdregs->lvi, stream->nbuffers - 1);
     182        hda_reg32_write(&sdregs->cbl, bufs->nbuffers * bufs->bufsize);
     183        hda_reg16_write(&sdregs->lvi, bufs->nbuffers - 1);
    165184        hda_reg16_write(&sdregs->fmt, stream->fmt);
    166         hda_reg32_write(&sdregs->bdpl, LOWER32(stream->bdl_phys));
    167         hda_reg32_write(&sdregs->bdpu, UPPER32(stream->bdl_phys));
     185        hda_reg32_write(&sdregs->bdpl, LOWER32(bufs->bdl_phys));
     186        hda_reg32_write(&sdregs->bdpu, UPPER32(bufs->bdl_phys));
    168187}
    169188
     
    205224
    206225hda_stream_t *hda_stream_create(hda_t *hda, hda_stream_dir_t dir,
    207     uint32_t fmt)
     226    hda_stream_buffers_t *bufs, uint32_t fmt)
    208227{
    209228        hda_stream_t *stream;
    210         int rc;
     229        uint8_t sdid;
    211230
    212231        stream = calloc(1, sizeof(hda_stream_t));
     
    214233                return NULL;
    215234
     235        sdid = 0;
     236
     237        switch (dir) {
     238        case sdir_input:
     239                sdid = 0; /* XXX Allocate - first input SDESC */
     240                break;
     241        case sdir_output:
     242                sdid = hda->ctl->iss; /* XXX Allocate - First output SDESC */
     243                break;
     244        case sdir_bidi:
     245                sdid = hda->ctl->iss + hda->ctl->oss; /* XXX Allocate - First bidi SDESC */
     246                break;
     247        }
     248
    216249        stream->hda = hda;
    217250        stream->dir = dir;
    218251        stream->sid = 1; /* XXX Allocate this */
    219         stream->sdid = hda->ctl->iss; /* XXX Allocate - First output SDESC */
     252        stream->sdid = sdid;
    220253        stream->fmt = fmt;
     254        stream->buffers = bufs;
    221255
    222256        ddf_msg(LVL_NOTE, "snum=%d sdidx=%d", stream->sid, stream->sdid);
    223 
    224         ddf_msg(LVL_NOTE, "Allocate buffers");
    225         rc = hda_stream_buffers_alloc(stream);
    226         if (rc != EOK)
    227                 goto error;
    228257
    229258        ddf_msg(LVL_NOTE, "Configure stream descriptor");
    230259        hda_stream_desc_configure(stream);
    231260        return stream;
    232 error:
    233         return NULL;
    234261}
    235262
  • uspace/drv/audio/hdaudio/stream.h

    r73e894c r749fe15b  
    4848} hda_stream_dir_t;
    4949
    50 typedef struct hda_stream {
    51         hda_t *hda;
    52         /** Stream ID */
    53         uint8_t sid;
    54         /** Stream descriptor index */
    55         uint8_t sdid;
    56         /** Direction */
    57         hda_stream_dir_t dir;
     50typedef struct hda_stream_buffers {
    5851        /** Number of buffers */
    5952        size_t nbuffers;
     
    6861        /** Physical addresses of buffers */
    6962        uintptr_t *buf_phys;
     63} hda_stream_buffers_t;
     64
     65typedef struct hda_stream {
     66        hda_t *hda;
     67        /** Stream ID */
     68        uint8_t sid;
     69        /** Stream descriptor index */
     70        uint8_t sdid;
     71        /** Direction */
     72        hda_stream_dir_t dir;
     73        /** Buffers */
     74        hda_stream_buffers_t *buffers;
    7075        /** Stream format */
    7176        uint32_t fmt;
    7277} hda_stream_t;
    7378
    74 extern hda_stream_t *hda_stream_create(hda_t *, hda_stream_dir_t, uint32_t);
     79extern int hda_stream_buffers_alloc(hda_t *, hda_stream_buffers_t **);
     80extern void hda_stream_buffers_free(hda_stream_buffers_t *);
     81extern hda_stream_t *hda_stream_create(hda_t *, hda_stream_dir_t,
     82    hda_stream_buffers_t *, uint32_t);
    7583extern void hda_stream_destroy(hda_stream_t *);
    7684extern void hda_stream_start(hda_stream_t *);
  • uspace/drv/block/ata_bd/main.c

    r73e894c r749fe15b  
    8181                rc = EINVAL;
    8282                goto error;
    83                 return EINVAL;
    8483        }
    8584
  • uspace/drv/bus/isa/isa.c

    r73e894c r749fe15b  
    245245        bool opened = false;
    246246        int fd;
    247         size_t len = 0;
     247        size_t len;
     248        ssize_t r;
    248249
    249250        fd = open(conf_path, O_RDONLY);
     
    269270        }
    270271
    271         if (0 >= read(fd, buf, len)) {
     272        r = read_all(fd, buf, len);
     273        if (r < 0) {
    272274                ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
    273275                goto cleanup;
  • uspace/lib/ext4/libext4_directory.c

    r73e894c r749fe15b  
    390390            (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) {
    391391                int rc = ext4_directory_dx_add_entry(parent, child, name);
    392                
     392
    393393                /* Check if index is not corrupted */
    394                 if (rc != EXT4_ERR_BAD_DX_DIR) {
    395                         if (rc != EOK)
    396                                 return rc;
    397                        
    398                         return EOK;
    399                 }
    400                
     394                if (rc != EXT4_ERR_BAD_DX_DIR)
     395                        return rc;
     396
    401397                /* Needed to clear dir index flag if corrupted */
    402398                ext4_inode_clear_flag(parent->inode, EXT4_INODE_FLAG_INDEX);
  • uspace/lib/ext4/libext4_extent.c

    r73e894c r749fe15b  
    797797                        if (rc != EOK) {
    798798                                ext4_balloc_free_block(inode_ref, fblock);
     799                                block_put(block);
    799800                                return rc;
    800801                        }
  • uspace/lib/ext4/libext4_filesystem.c

    r73e894c r749fe15b  
    5353    enum cache_mode cmode)
    5454{
     55        ext4_superblock_t *temp_superblock = NULL;
     56
    5557        fs->device = service_id;
    56        
     58
    5759        /* Initialize block library (4096 is size of communication channel) */
    5860        int rc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096);
    5961        if (rc != EOK)
    60                 return rc;
    61        
     62                goto err;
     63
    6264        /* Read superblock from device to memory */
    63         ext4_superblock_t *temp_superblock;
    6465        rc = ext4_superblock_read_direct(fs->device, &temp_superblock);
    65         if (rc != EOK) {
    66                 block_fini(fs->device);
    67                 return rc;
    68         }
    69        
     66        if (rc != EOK)
     67                goto err_1;
     68
    7069        /* Read block size from superblock and check */
    7170        uint32_t block_size = ext4_superblock_get_block_size(temp_superblock);
    7271        if (block_size > EXT4_MAX_BLOCK_SIZE) {
    73                 block_fini(fs->device);
    74                 return ENOTSUP;
    75         }
    76        
     72                rc = ENOTSUP;
     73                goto err_1;
     74        }
     75
    7776        /* Initialize block caching by libblock */
    7877        rc = block_cache_init(service_id, block_size, 0, cmode);
    79         if (rc != EOK) {
    80                 block_fini(fs->device);
    81                 return rc;
    82         }
    83        
     78        if (rc != EOK)
     79                goto err_1;
     80
    8481        /* Compute limits for indirect block levels */
    8582        uint32_t block_ids_per_block = block_size / sizeof(uint32_t);
     
    9289                    fs->inode_blocks_per_level[i];
    9390        }
    94        
     91
    9592        /* Return loaded superblock */
    9693        fs->superblock = temp_superblock;
    97        
     94
    9895        uint16_t state = ext4_superblock_get_state(fs->superblock);
    99        
     96
    10097        if (((state & EXT4_SUPERBLOCK_STATE_VALID_FS) !=
    10198            EXT4_SUPERBLOCK_STATE_VALID_FS) ||
    10299            ((state & EXT4_SUPERBLOCK_STATE_ERROR_FS) ==
    103100            EXT4_SUPERBLOCK_STATE_ERROR_FS)) {
    104                 block_cache_fini(fs->device);
    105                 block_fini(fs->device);
    106                 return ENOTSUP;
    107         }
    108        
     101                rc = ENOTSUP;
     102                goto err_2;
     103        }
     104
    109105        /* Mark system as mounted */
    110106        ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS);
    111107        rc = ext4_superblock_write_direct(fs->device, fs->superblock);
    112         if (rc != EOK) {
    113                 block_cache_fini(fs->device);
    114                 block_fini(fs->device);
    115                 return rc;
    116         }
    117        
     108        if (rc != EOK)
     109                goto err_2;
     110
    118111        uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock);
    119112        ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1);
    120        
     113
    121114        return EOK;
     115
     116err_2:
     117        block_cache_fini(fs->device);
     118err_1:
     119        block_fini(fs->device);
     120err:
     121        if (temp_superblock)
     122                ext4_superblock_release(temp_superblock);
     123        return rc;
    122124}
    123125
     
    845847                               
    846848                                rc = block_put(subblock);
    847                                 if (rc != EOK)
     849                                if (rc != EOK) {
     850                                        block_put(block);
    848851                                        return rc;
     852                                }
    849853                        }
    850854                       
  • uspace/lib/ext4/libext4_superblock.c

    r73e894c r749fe15b  
    11781178}
    11791179
     1180/** Release the memory allocated for the superblock structure
     1181 *
     1182 * @param sb         Superblock to be freed
     1183 *
     1184 */
     1185void ext4_superblock_release(ext4_superblock_t *sb)
     1186{
     1187        free(sb);
     1188}
     1189
    11801190/** Check sanity of the superblock.
    11811191 *
  • uspace/lib/ext4/libext4_superblock.h

    r73e894c r749fe15b  
    145145extern int ext4_superblock_read_direct(service_id_t, ext4_superblock_t **);
    146146extern int ext4_superblock_write_direct(service_id_t, ext4_superblock_t *);
     147extern void ext4_superblock_release(ext4_superblock_t *);
    147148extern int ext4_superblock_check_sanity(ext4_superblock_t *);
    148149
  • uspace/srv/devman/drv_conn.c

    r73e894c r749fe15b  
    173173        callid = async_get_call(&call);
    174174        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    175                 log_msg(LOG_DEFAULT, LVL_ERROR, 
     175                log_msg(LOG_DEFAULT, LVL_ERROR,
    176176                    "Invalid protocol when trying to receive match id.");
    177                 async_answer_0(callid, EINVAL); 
     177                async_answer_0(callid, EINVAL);
    178178                delete_match_id(match_id);
    179179                return EINVAL;
     
    246246        if (ftype != fun_inner && ftype != fun_exposed) {
    247247                /* Unknown function type */
    248                 log_msg(LOG_DEFAULT, LVL_ERROR, 
     248                log_msg(LOG_DEFAULT, LVL_ERROR,
    249249                    "Unknown function type %d provided by driver.",
    250250                    (int) ftype);
     
    404404        fibril_rwlock_read_unlock(&device_tree.rwlock);
    405405       
    406         rc = fun_offline(fun);
     406        rc = fun_online(fun);
    407407        if (rc != EOK) {
    408408                fun_busy_unlock(fun);
  • uspace/srv/devman/fun.c

    r73e894c r749fe15b  
    348348                loc_register_tree_function(fun, &device_tree);
    349349       
     350        fun->state = FUN_ON_LINE;
    350351        fibril_rwlock_write_unlock(&device_tree.rwlock);
    351352       
Note: See TracChangeset for help on using the changeset viewer.