From owner-dev-commits-src-main@freebsd.org Thu May 27 20:48:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5051B644FCC; Thu, 27 May 2021 20:48:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Frfzy1nqWz4rYq; Thu, 27 May 2021 20:48:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2296B2B1E; Thu, 27 May 2021 20:48:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14RKmjut084843; Thu, 27 May 2021 20:48:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14RKmjLc084842; Thu, 27 May 2021 20:48:45 GMT (envelope-from git) Date: Thu, 27 May 2021 20:48:45 GMT Message-Id: <202105272048.14RKmjLc084842@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ruslan Bukin Subject: git: f81b451dcccd - main - hdspe: Support for mono sound. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: br X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f81b451dcccd449388dd1b7901683d4cdd481a6e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2021 20:48:46 -0000 The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=f81b451dcccd449388dd1b7901683d4cdd481a6e commit f81b451dcccd449388dd1b7901683d4cdd481a6e Author: Ruslan Bukin AuthorDate: 2021-05-27 20:40:21 +0000 Commit: Ruslan Bukin CommitDate: 2021-05-27 20:40:21 +0000 hdspe: Support for mono sound. This is useful when you have a single monitor speaker. --- sys/dev/sound/pci/hdspe-pcm.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/sys/dev/sound/pci/hdspe-pcm.c b/sys/dev/sound/pci/hdspe-pcm.c index 20cb39d2de14..6e2cccfb0c99 100644 --- a/sys/dev/sound/pci/hdspe-pcm.c +++ b/sys/dev/sound/pci/hdspe-pcm.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2012-2016 Ruslan Bukin + * Copyright (c) 2012-2021 Ruslan Bukin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -196,7 +196,8 @@ hdspechan_enable(struct sc_chinfo *ch, int value) ch->run = value; hdspe_write_1(sc, reg + (4 * ch->lslot), value); - hdspe_write_1(sc, reg + (4 * ch->rslot), value); + if (AFMT_CHANNEL(ch->format) == 2) + hdspe_write_1(sc, reg + (4 * ch->rslot), value); } static int @@ -263,13 +264,16 @@ buffer_copy(struct sc_chinfo *ch) int ssize, dsize; int src, dst; int length; + int n; int i; scp = ch->parent; sc = scp->sc; + n = AFMT_CHANNEL(ch->format); /* n channels */ + length = sndbuf_getready(ch->buffer) / - (4 /* Bytes per sample. */ * 2 /* channels */); + (4 /* Bytes per sample. */ * n); if (ch->dir == PCMDIR_PLAY) { src = sndbuf_getreadyptr(ch->buffer); @@ -278,10 +282,10 @@ buffer_copy(struct sc_chinfo *ch) } src /= 4; /* Bytes per sample. */ - dst = src / 2; /* Destination buffer twice smaller. */ + dst = src / n; /* Destination buffer n-times smaller. */ ssize = ch->size / 4; - dsize = ch->size / 8; + dsize = ch->size / (4 * n); /* * Use two fragment buffer to avoid sound clipping. @@ -303,7 +307,7 @@ buffer_copy(struct sc_chinfo *ch) dst+=1; dst %= dsize; - src+=2; + src += n; src %= ssize; } } @@ -352,7 +356,7 @@ hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, ch->lvol = 0; ch->rvol = 0; - ch->size = HDSPE_CHANBUF_SIZE * 2 /* slots */; + ch->size = HDSPE_CHANBUF_SIZE * 2; /* max size */ ch->data = malloc(ch->size, M_HDSPE, M_NOWAIT); ch->buffer = b; @@ -432,7 +436,8 @@ hdspechan_getptr(kobj_t obj, void *data) snd_mtxunlock(sc->lock); pos = ret & HDSPE_BUF_POSITION_MASK; - pos *= 2; /* Hardbuf twice bigger. */ + if (AFMT_CHANNEL(ch->format) == 2) + pos *= 2; /* Hardbuf twice bigger. */ return (pos); } @@ -608,7 +613,8 @@ hdspechan_setblocksize(kobj_t obj, void *data, uint32_t blocksize) device_printf(scp->dev, "New period=%d\n", sc->period); #endif - sndbuf_resize(ch->buffer, (HDSPE_CHANBUF_SIZE * 2) / (sc->period * 4), + sndbuf_resize(ch->buffer, + (HDSPE_CHANBUF_SIZE * AFMT_CHANNEL(ch->format)) / (sc->period * 4), (sc->period * 4)); end: @@ -623,6 +629,7 @@ static uint32_t hdspe_rfmt[] = { static struct pcmchan_caps hdspe_rcaps = {32000, 192000, hdspe_rfmt, 0}; static uint32_t hdspe_pfmt[] = { + SND_FORMAT(AFMT_S32_LE, 1, 0), SND_FORMAT(AFMT_S32_LE, 2, 0), 0 };