From patchwork Wed Mar 14 16:02:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 10282641 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 B91256061F for ; Wed, 14 Mar 2018 16:03:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3B1F283AD for ; Wed, 14 Mar 2018 16:03:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98A18283B0; Wed, 14 Mar 2018 16:03:34 +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 AE6A7283AD for ; Wed, 14 Mar 2018 16:03:33 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2CC082673FE; Wed, 14 Mar 2018 17:03:09 +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 AA56A2673E5; Wed, 14 Mar 2018 17:03:04 +0100 (CET) Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by alsa0.perex.cz (Postfix) with ESMTP id 5238B2673E5 for ; Wed, 14 Mar 2018 17:02:59 +0100 (CET) Received: by mail-lf0-f68.google.com with SMTP id w16-v6so5573340lfc.13 for ; Wed, 14 Mar 2018 09:02:59 -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=MTFzAO3XhgIlMSOskp6cAgAyl9O7ISDRkrPYnLxA8EE=; b=SxZSGQV8OIu3Ebd16B0d6D5eSvv1DHha20VRh+HjkBW6DgtP5OOSc2KyiwGTF3ll1h UnpZYODqnC2zFo6fa0MzfBBpIVqyYEl9MxNWz30iSuO3qT0sUkn66je8Ez2wcIHC0lt8 a8WBiL+Khd9kMJoG1Z19LZi+J6OY8OM4IjrTMY7/qJwMn65jgxYU+uRO6cxH4S4Krhz4 7lULKsDJXwSZbpkNbeHkRje6qbOvIryrnVQgR1u8SFLOroQemENIWq6OCWo0OtSrQxhh CmeVCekexcO+nnArCMgz+s4aRzXauXSeY7gJHNx15waOkaGnPOt0Aqf0GZTXm3TvUzlL BlZA== 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=MTFzAO3XhgIlMSOskp6cAgAyl9O7ISDRkrPYnLxA8EE=; b=pUwuyCDE6nin2gJ4/xK2tA0HVxgEMEkCPZhD3d+g8w/409yoQVOf0xHOe/6m94OorO 8ss06v/yOLkKoiqM/Yo4gApmzveKX6zNxDJmTzNX88Anof52t/OuZNMnoJf18jpV18hb YnDDXOQ3eiaqUUZtG8V4YuP6hI6IG0B7Nk8c/kZjw7GSr+SxjJCD+kYgr1jkOP/8CRs1 eksVR+QHYgCRwjcXPrBXk+Ot0cgnq3Vz7wfeu0Mz1MKvI+n12+ywMOiE/hBOx59qrvFd iSBKMVXgkXJtvVs6eUYkADLzmoCcn+1A3SedVK9A+6EfmzVVf5YfaNHvtyXaPvMTqQTJ YK+w== X-Gm-Message-State: AElRT7H677ZtpG7R4UZ1m/nhpS4jcDO6ucyU5eVD0Wufr1Q657vpQyGp nsw5IWvNZ3QG6ohf+dDGW4U+wsLk X-Google-Smtp-Source: AG47ELvJuZg/XfKKk5y5o2zZlCTL3oboRrTHtsiRTdaGbwtYZmpK7/UvXZkKqbFRQdT/Y0wElccAIQ== X-Received: by 10.46.21.86 with SMTP id 22mr3645287ljv.24.1521043378885; Wed, 14 Mar 2018 09:02:58 -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 w207-v6sm415244lff.53.2018.03.14.09.02.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:02:57 -0700 (PDT) From: Oleksandr Andrushchenko To: alsa-devel@alsa-project.org, xen-devel@lists.xenproject.org, konrad.wilk@oracle.com, tiwai@suse.de Date: Wed, 14 Mar 2018 18:02:45 +0200 Message-Id: <1521043365-26813-4-git-send-email-andr2000@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521043365-26813-1-git-send-email-andr2000@gmail.com> References: <1521043365-26813-1-git-send-email-andr2000@gmail.com> Cc: andr2000@gmail.com, Oleksandr Andrushchenko Subject: [alsa-devel] [Xen-devel][PATCH v2 3/3] 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 changes are introduced in the protocol: add XENSND_OP_HW_PARAM_QUERY request to read/update configuration space for the parameter given: request passes desired parameter interval (mask) and the response to this request returns min/max interval (mask) for the parameter to be used. Parameters supported by this request/response: - format 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 | 124 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 117 insertions(+), 7 deletions(-) diff --git a/xen/include/public/io/sndif.h b/xen/include/public/io/sndif.h index 1a6a1467f253..ff0ba15b0462 100644 --- a/xen/include/public/io/sndif.h +++ b/xen/include/public/io/sndif.h @@ -465,12 +465,19 @@ #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 #define XENSND_OP_TRIGGER_STOP 2 #define XENSND_OP_TRIGGER_RESUME 3 +#define XENSND_OP_HW_PARAM_FORMAT 0 +#define XENSND_OP_HW_PARAM_RATE 1 +#define XENSND_OP_HW_PARAM_BUFFER 2 +#define XENSND_OP_HW_PARAM_PERIOD 3 +#define XENSND_OP_HW_PARAM_CHANNELS 4 + /* ****************************************************************************** * EVENT CODES @@ -828,28 +835,127 @@ struct xensnd_trigger_req { }; /* + * Request stream configuration parameter range: request interval or + * bit mask of the supported values for the parameter given. + * + * Sound device configuration for a particular stream is a limited subset + * of the multidimensional configuration available on XenStore, for instance, + * once 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 will 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. + * + * 0 1 2 3 octet + * +----------------+----------------+----------------+----------------+ + * | id | _HW_PARAM_QUERY| reserved | 4 + * +----------------+----------------+----------------+----------------+ + * | reserved | 8 + * +----------------+----------------+----------------+----------------+ + * | param | reserved | 12 + * +----------------+----------------+----------------+----------------+ + * | min or mask low 32-bit | 16 + * +----------------+----------------+----------------+----------------+ + * | max or mask high 32-bit | 20 + * +----------------+----------------+----------------+----------------+ + * | reserved | 24 + * +----------------+----------------+----------------+----------------+ + * | reserved | 28 + * +----------------+----------------+----------------+----------------+ + * | reserved | 32 + * +----------------+----------------+----------------+----------------+ + * + * param - uint8_t, XENSND_OP_HW_PARAM_XXX value + * + * The following parameters' payload treated as interval: + * XENSND_OP_HW_PARAM_RATE + * XENSND_OP_HW_PARAM_BUFFER + * XENSND_OP_HW_PARAM_PERIOD + * XENSND_OP_HW_PARAM_CHANNELS + * + * For interval parameters the payload of the request: + * min - uint32_t, minimum value of the parameter + * max - uint32_t, maximum value of the parameter + * + * For the following parameters their min and max values are expressed in + * frames: + * XENSND_OP_HW_PARAM_BUFFER + * XENSND_OP_HW_PARAM_PERIOD + * where frame is defined as a product of the number of channels by the + * number of octets per one sample. + * + * The following parameters' payload treated as a bit mask: + * XENSND_OP_HW_PARAM_FORMAT + * + * For mask parameters the payload of the request: + * mask - uint64_t, bit mask representing values of the parameter + */ + +struct xensnd_query_hw_param_req { + uint8_t param; + uint8_t reserved[3]; + union { + struct { + uint32_t min; + uint32_t max; + } interval; + uint64_t mask; + } val; +}; + +/* *---------------------------------- Responses -------------------------------- * * All response packets have the same length (32 octets) * - * Response for all requests: + * 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 * +----------------+----------------+----------------+----------------+ - * | reserved | 12 + * | min or mask low 32-bit | 12 + * +----------------+----------------+----------------+----------------+ + * | max or mask high 32-bit | 16 + * +----------------+----------------+----------------+----------------+ + * | reserved | 20 * +----------------+----------------+----------------+----------------+ * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| * +----------------+----------------+----------------+----------------+ * | reserved | 32 * +----------------+----------------+----------------+----------------+ * - * 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 - * + * The payload meaning is the same as in the corresponing HW parameter + * request: see XENSND_OP_HW_PARAM_QUERY for details. + */ + +union xensnd_query_hw_param_resp { + struct { + uint32_t min; + uint32_t max; + } interval; + uint64_t mask; +}; + +/* *----------------------------------- Events ---------------------------------- * * Events are sent via a shared page allocated by the front and propagated by @@ -902,6 +1008,7 @@ struct xensnd_req { struct xensnd_open_req open; struct xensnd_rw_req rw; struct xensnd_trigger_req trigger; + struct xensnd_query_hw_param_req hw_param; uint8_t reserved[24]; } op; }; @@ -911,7 +1018,10 @@ struct xensnd_resp { uint8_t operation; uint8_t reserved; int32_t status; - uint8_t reserved1[24]; + union { + union xensnd_query_hw_param_resp hw_param; + uint8_t reserved1[24]; + } resp; }; struct xensnd_evt {