~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to sbc/sbc_primitives_mmx.c

ImportĀ upstreamĀ versionĀ 4.81

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  Bluetooth low-complexity, subband codec (SBC) library
4
4
 *
5
 
 *  Copyright (C) 2004-2009  Marcel Holtmann <marcel@holtmann.org>
 
5
 *  Copyright (C) 2008-2010  Nokia Corporation
 
6
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
6
7
 *  Copyright (C) 2004-2005  Henryk Ploetz <henryk@ploetzli.ch>
7
8
 *  Copyright (C) 2005-2006  Brad Midgley <bmidgley@xmission.com>
8
9
 *
100
101
                :
101
102
                : "r" (in), "r" (consts), "r" (&round_c), "r" (out),
102
103
                        "i" (SBC_PROTO_FIXED4_SCALE)
103
 
                : "memory");
 
104
                : "cc", "memory");
104
105
}
105
106
 
106
107
static inline void sbc_analyze_eight_mmx(const int16_t *in, int32_t *out,
242
243
                :
243
244
                : "r" (in), "r" (consts), "r" (&round_c), "r" (out),
244
245
                        "i" (SBC_PROTO_FIXED8_SCALE)
245
 
                : "memory");
 
246
                : "cc", "memory");
246
247
}
247
248
 
248
249
static inline void sbc_analyze_4b_4s_mmx(int16_t *x, int32_t *out,
275
276
        asm volatile ("emms\n");
276
277
}
277
278
 
 
279
static void sbc_calc_scalefactors_mmx(
 
280
        int32_t sb_sample_f[16][2][8],
 
281
        uint32_t scale_factor[2][8],
 
282
        int blocks, int channels, int subbands)
 
283
{
 
284
        static const SBC_ALIGNED int32_t consts[2] = {
 
285
                1 << SCALE_OUT_BITS,
 
286
                1 << SCALE_OUT_BITS,
 
287
        };
 
288
        int ch, sb;
 
289
        intptr_t blk;
 
290
        for (ch = 0; ch < channels; ch++) {
 
291
                for (sb = 0; sb < subbands; sb += 2) {
 
292
                        blk = (blocks - 1) * (((char *) &sb_sample_f[1][0][0] -
 
293
                                (char *) &sb_sample_f[0][0][0]));
 
294
                        asm volatile (
 
295
                                "movq         (%4), %%mm0\n"
 
296
                        "1:\n"
 
297
                                "movq     (%1, %0), %%mm1\n"
 
298
                                "pxor        %%mm2, %%mm2\n"
 
299
                                "pcmpgtd     %%mm2, %%mm1\n"
 
300
                                "paddd    (%1, %0), %%mm1\n"
 
301
                                "pcmpgtd     %%mm1, %%mm2\n"
 
302
                                "pxor        %%mm2, %%mm1\n"
 
303
 
 
304
                                "por         %%mm1, %%mm0\n"
 
305
 
 
306
                                "sub            %2, %0\n"
 
307
                                "jns            1b\n"
 
308
 
 
309
                                "movd        %%mm0, %k0\n"
 
310
                                "psrlq         $32, %%mm0\n"
 
311
                                "bsrl          %k0, %k0\n"
 
312
                                "subl           %5, %k0\n"
 
313
                                "movl          %k0, (%3)\n"
 
314
 
 
315
                                "movd        %%mm0, %k0\n"
 
316
                                "bsrl          %k0, %k0\n"
 
317
                                "subl           %5, %k0\n"
 
318
                                "movl          %k0, 4(%3)\n"
 
319
                        : "+r" (blk)
 
320
                        : "r" (&sb_sample_f[0][ch][sb]),
 
321
                                "i" ((char *) &sb_sample_f[1][0][0] -
 
322
                                        (char *) &sb_sample_f[0][0][0]),
 
323
                                "r" (&scale_factor[ch][sb]),
 
324
                                "r" (&consts),
 
325
                                "i" (SCALE_OUT_BITS)
 
326
                        : "cc", "memory");
 
327
                }
 
328
        }
 
329
        asm volatile ("emms\n");
 
330
}
 
331
 
278
332
static int check_mmx_support(void)
279
333
{
280
334
#ifdef __amd64__
313
367
        if (check_mmx_support()) {
314
368
                state->sbc_analyze_4b_4s = sbc_analyze_4b_4s_mmx;
315
369
                state->sbc_analyze_4b_8s = sbc_analyze_4b_8s_mmx;
 
370
                state->sbc_calc_scalefactors = sbc_calc_scalefactors_mmx;
316
371
                state->implementation_info = "MMX";
317
372
        }
318
373
}