From patchwork Mon Mar 19 07:22:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 10291729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94FAF602BD for ; Mon, 19 Mar 2018 07:23:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7666A28E8B for ; Mon, 19 Mar 2018 07:23:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A95528E92; Mon, 19 Mar 2018 07:23:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7199828E90 for ; Mon, 19 Mar 2018 07:23:16 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 60B992674D2; Mon, 19 Mar 2018 08:22:49 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id EB55226748B; Mon, 19 Mar 2018 08:22:44 +0100 (CET) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by alsa0.perex.cz (Postfix) with ESMTP id 9955826748B for ; Mon, 19 Mar 2018 08:22:42 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id g203-v6so9359635lfg.11 for ; Mon, 19 Mar 2018 00:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+3u2Fsh6p6LTXuVphh1SKkE9dvbL4oCFViac9bc2vKU=; b=cQFGgRBfc6ytDEAhJYgRkD5USdo9wzvzjlphKNhg6anuOT223QjV1KECifAtwJIReF 9+QNYZ8T5cUraJk3QZnUxBt7z/RC5ZYuqdWD+Vhg6eToaT5m1zxfxXwDXrxJ1nJ/k6YF XKDD7yQAtNpAseJ3Olg41ScI9KqFx2nJufb4rq9+qKv1ZK+GNLrTYrYjLJ/aKzON6IrE Fi9PGr80WN4vyFk3tBk1999o/PrwgyOwNHdNRt9HMpNuS50ntfaJHQjfyfch2McOlFWd Q1BVDSPl1ioXTI19LVs7VOAUtM7mY+3V7czJDj20j73L0ST/SjCd3FOd241EuCBLfzAK yaTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+3u2Fsh6p6LTXuVphh1SKkE9dvbL4oCFViac9bc2vKU=; b=cfwd8R1BhaTPjJq0ll15QMUIWHnWI8KjkN3PUvfZu5ngVUgPOFz8+jbwNVrkvVR+u3 i2viGqV7oHt+3NdWgQTvxGoLri9zf6qs8HZNqECuGdsM16x1lpjAXfg7xyCJyMAOEkqX gHPv9/1vRfWkC4n/RCYTjyWu7GcDUNOfr8t5ad7m6DHkDj5Wcpy359JeXBiIW0XVIpZr annEBXpPGle8CemiSmoj8PLYSea/7RE33FmSQBko4skojHCbgwocKc9XmZ/bMHJWnBP5 rkezGrEab0XU6cG1+inH2Y7xmt3VSSPu/oEukGtkDAxkJfsayw8dTSoJSwOVG7q7akoz 6J0A== X-Gm-Message-State: AElRT7GvXy7vYCE3BF9E2V2+KlxADVZcEVyuyhugRvangXRtjtOUHVcC 25jqa1nCilEVujEXxe8lWxNEXQ== X-Google-Smtp-Source: AG47ELsW7fHdnitCeAB8tLGpRvgLpbohkyK0bWyyzJ36vWDlaCVBYRK5wsyWRbeKDuBD/zmH9yV1Ng== X-Received: by 2002:a19:136a:: with SMTP id j103-v6mr6989018lfi.19.1521444161425; Mon, 19 Mar 2018 00:22:41 -0700 (PDT) Received: from a2k-HP-ProDesk-600-G2-SFF.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id e123-v6sm3221317lfg.47.2018.03.19.00.22.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Mar 2018 00:22:40 -0700 (PDT) From: Oleksandr Andrushchenko To: alsa-devel@alsa-project.org, xen-devel@lists.xenproject.org, konrad.wilk@oracle.com, tiwai@suse.de Date: Mon, 19 Mar 2018 09:22:24 +0200 Message-Id: <1521444144-12451-6-git-send-email-andr2000@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521444144-12451-1-git-send-email-andr2000@gmail.com> References: <1521444144-12451-1-git-send-email-andr2000@gmail.com> Cc: andr2000@gmail.com, Oleksandr Andrushchenko Subject: [alsa-devel] [Xen-devel][PATCH v3 5/5] sndif: Add explicit back and front parameter negotiation X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Andrushchenko In order to provide explicit stream parameter negotiation between backend and frontend the following change is introduced to the protocol: - add XENSND_OP_HW_PARAM_QUERY request to read/update stream configuration space: request passes desired intervals/formats for the stream parameters and the response returns allowed intervals and formats mask that can be used. Parameters supported by this request/response: - formats mask - sample rate interval - number of channels interval - buffer size, interval, frames - period size, interval, frames Signed-off-by: Oleksandr Andrushchenko Cc: Konrad Rzeszutek Wilk Cc: Takashi Iwai --- xen/include/public/io/sndif.h | 133 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 126 insertions(+), 7 deletions(-) diff --git a/xen/include/public/io/sndif.h b/xen/include/public/io/sndif.h index be8d7c83fa72..417d3ebc7981 100644 --- a/xen/include/public/io/sndif.h +++ b/xen/include/public/io/sndif.h @@ -465,6 +465,7 @@ #define XENSND_OP_MUTE 6 #define XENSND_OP_UNMUTE 7 #define XENSND_OP_TRIGGER 8 +#define XENSND_OP_HW_PARAM_QUERY 9 #define XENSND_OP_TRIGGER_START 0 #define XENSND_OP_TRIGGER_PAUSE 1 @@ -832,28 +833,142 @@ struct xensnd_trigger_req { }; /* - *---------------------------------- Responses -------------------------------- + * Request stream parameter ranges: request intervals and + * masks of supported ranges for stream configuration values. * - * All response packets have the same length (64 octets) + * Sound device configuration for a particular stream is a limited subset + * of the multidimensional configuration available on XenStore, e.g. + * once the frame rate has been selected there is a limited supported range + * for sample rates becomes available (which might be the same set configured + * on XenStore or less). For example, selecting 96kHz sample rate may limit + * number of channels available for such configuration from 4 to 2, etc. + * Thus, each call to XENSND_OP_HW_PARAM_QUERY may reduce configuration + * space making it possible to iteratively get the final stream configuration, + * used in XENSND_OP_OPEN request. + * + * See response format for this request. * - * Response for all requests: * 0 1 2 3 octet * +----------------+----------------+----------------+----------------+ - * | id | operation | reserved | 4 + * | id | _HW_PARAM_QUERY| reserved | 4 * +----------------+----------------+----------------+----------------+ - * | status | 8 + * | reserved | 8 + * +----------------+----------------+----------------+----------------+ + * | formats mask low 32-bit | 12 + * +----------------+----------------+----------------+----------------+ + * | formats mask high 32-bit | 16 + * +----------------+----------------+----------------+----------------+ + * | min rate | 20 + * +----------------+----------------+----------------+----------------+ + * | max rate | 24 + * +----------------+----------------+----------------+----------------+ + * | min channels | 28 + * +----------------+----------------+----------------+----------------+ + * | max channels | 32 + * +----------------+----------------+----------------+----------------+ + * | min buffer frames | 36 + * +----------------+----------------+----------------+----------------+ + * | max buffer frames | 40 + * +----------------+----------------+----------------+----------------+ + * | min period frames | 44 + * +----------------+----------------+----------------+----------------+ + * | max period frames | 48 * +----------------+----------------+----------------+----------------+ - * | reserved | 12 + * | reserved | 52 * +----------------+----------------+----------------+----------------+ * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| * +----------------+----------------+----------------+----------------+ * | reserved | 64 * +----------------+----------------+----------------+----------------+ * + * formats - uint64_t, bit mask representing values of the parameter + * made as bitwise OR of (1 << XENSND_PCM_FORMAT_XXX) values + * + * For interval parameters: + * min - uint32_t, minimum value of the parameter + * max - uint32_t, maximum value of the parameter + * + * Frame is defined as a product of the number of channels by the + * number of octets per one sample. + */ + +struct xensnd_query_hw_param { + uint64_t formats; + struct { + uint32_t min; + uint32_t max; + } rates; + struct { + uint32_t min; + uint32_t max; + } channels; + struct { + uint32_t min; + uint32_t max; + } buffer; + struct { + uint32_t min; + uint32_t max; + } period; +}; + +/* + *---------------------------------- Responses -------------------------------- + * + * All response packets have the same length (64 octets) + * + * All response packets have common header: + * 0 1 2 3 octet + * +----------------+----------------+----------------+----------------+ + * | id | operation | reserved | 4 + * +----------------+----------------+----------------+----------------+ + * | status | 8 + * +----------------+----------------+----------------+----------------+ + * * id - uint16_t, copied from the request * operation - uint8_t, XENSND_OP_* - copied from request * status - int32_t, response status, zero on success and -XEN_EXX on failure * + * + * HW parameter query response - response for XENSND_OP_HW_PARAM_QUERY: + * 0 1 2 3 octet + * +----------------+----------------+----------------+----------------+ + * | id | operation | reserved | 4 + * +----------------+----------------+----------------+----------------+ + * | status | 8 + * +----------------+----------------+----------------+----------------+ + * | formats mask low 32-bit | 12 + * +----------------+----------------+----------------+----------------+ + * | formats mask high 32-bit | 16 + * +----------------+----------------+----------------+----------------+ + * | min rate | 20 + * +----------------+----------------+----------------+----------------+ + * | max rate | 24 + * +----------------+----------------+----------------+----------------+ + * | min channels | 28 + * +----------------+----------------+----------------+----------------+ + * | max channels | 32 + * +----------------+----------------+----------------+----------------+ + * | min buffer frames | 36 + * +----------------+----------------+----------------+----------------+ + * | max buffer frames | 40 + * +----------------+----------------+----------------+----------------+ + * | min period frames | 44 + * +----------------+----------------+----------------+----------------+ + * | max period frames | 48 + * +----------------+----------------+----------------+----------------+ + * | reserved | 52 + * +----------------+----------------+----------------+----------------+ + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| + * +----------------+----------------+----------------+----------------+ + * | reserved | 64 + * +----------------+----------------+----------------+----------------+ + * + * Meaning of the values in this response is the same as for + * XENSND_OP_HW_PARAM_QUERY request. + */ + +/* *----------------------------------- Events ---------------------------------- * * Events are sent via shared page allocated by the front and propagated by @@ -906,6 +1021,7 @@ struct xensnd_req { struct xensnd_open_req open; struct xensnd_rw_req rw; struct xensnd_trigger_req trigger; + struct xensnd_query_hw_param hw_param; uint8_t reserved[56]; } op; }; @@ -915,7 +1031,10 @@ struct xensnd_resp { uint8_t operation; uint8_t reserved; int32_t status; - uint8_t reserved1[56]; + union { + struct xensnd_query_hw_param hw_param; + uint8_t reserved1[56]; + } resp; }; struct xensnd_evt {