From patchwork Mon Apr 6 23:10:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46797 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 88BB8214B1 for ; Mon, 6 Apr 2015 23:10:31 +0000 (UTC) Received: by wgfh4 with SMTP id h4sf9085330wgf.1 for ; Mon, 06 Apr 2015 16:10:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=qiFvi8xyZeREYuwWdQhftDprI3DFescpZYCFxJDRNxE=; b=Yq5D+FmEf4C+YRSyJ0CK3WphoilhUWM96AYC/1cfQaqTcCQErSP66TvS1XvwksfVAY IRK+cOzWn6MpZvylOJCb6vqzeBTkMvZgdDg8p9zeGDsBtGV8Nb8KHMlWc7jQadGm2vNf pLUG3Cm08d80RdBV5QfZS4YSyh3KttJtq9m5/nl9EtSZC+KjzBNFc8wTea+jo7Ka9+JQ ux02NA2rd5mTh+8OdqS0YKuagaiW+bnJYMqLD+mQwuePRvFuY1Vx4Pk+ARtWkfmO/ECe deOZcvq4sZFf+UTvsMGq4/GeAvuOohYqYYBG/phhdDB5J+IRruVY7kjpxh6mDZWRr+Cu APgA== X-Gm-Message-State: ALoCoQkYrbeauF/2of499l/f1RTPJVVlF1j4AkQRAv/TTci6yerDS98NXx8MpQl15y58WbSO374Y X-Received: by 10.152.3.70 with SMTP id a6mr3595667laa.0.1428361830829; Mon, 06 Apr 2015 16:10:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.37 with SMTP id v5ls633099laj.31.gmail; Mon, 06 Apr 2015 16:10:30 -0700 (PDT) X-Received: by 10.152.219.2 with SMTP id pk2mr15281135lac.107.1428361830690; Mon, 06 Apr 2015 16:10:30 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id kd4si384365lbc.42.2015.04.06.16.10.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 16:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbqq2 with SMTP id qq2so21498271lbb.3 for ; Mon, 06 Apr 2015 16:10:30 -0700 (PDT) X-Received: by 10.112.16.196 with SMTP id i4mr4762542lbd.72.1428361830499; Mon, 06 Apr 2015 16:10:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp92192lbt; Mon, 6 Apr 2015 16:10:29 -0700 (PDT) X-Received: by 10.68.135.233 with SMTP id pv9mr31077424pbb.67.1428361827233; Mon, 06 Apr 2015 16:10:27 -0700 (PDT) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com. [209.85.220.44]) by mx.google.com with ESMTPS id cg12si8529996pdb.97.2015.04.06.16.10.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 16:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.44 as permitted sender) client-ip=209.85.220.44; Received: by pacyx8 with SMTP id yx8so58029372pac.1 for ; Mon, 06 Apr 2015 16:10:26 -0700 (PDT) X-Received: by 10.68.139.225 with SMTP id rb1mr31308751pbb.93.1428361826334; Mon, 06 Apr 2015 16:10:26 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id nw14sm5909429pab.39.2015.04.06.16.10.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Apr 2015 16:10:25 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: John Stultz , mark greer , Alex Elder , Greg Kroah-Hartman Subject: [PATCH 3/3] gbsim: Add GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS support (v2) Date: Mon, 6 Apr 2015 16:10:19 -0700 Message-Id: <1428361819-8899-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428361819-8899-1-git-send-email-john.stultz@linaro.org> References: <1428361819-8899-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add I2S support for GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS messages. Cc: mark greer Cc: Alex Elder Cc: Greg Kroah-Hartman Signed-off-by: John Stultz --- v2: Reworked to re-use the i2s.h header from greybus rather then duplicate it all. Alex: I know this still doesn't "fit in" with other structures in op_msg but I wanted to see if it wasn't better to re-use the greybus structures and avoid duplication. I did shorten the structure element names a bit. :) I can try to do the same for the other structures if you're ok with this. gbsim.h | 4 ++++ i2s.c | 52 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/gbsim.h b/gbsim.h index e74e78d..d3a519a 100644 --- a/gbsim.h +++ b/gbsim.h @@ -14,6 +14,8 @@ #include +#include "i2s.h" + extern int bbb_backend; extern int i2c_adapter; extern int verbose; @@ -229,6 +231,8 @@ struct op_msg { struct pwm_polarity_req pwm_pol_req; struct pwm_enable_req pwm_enb_req; struct pwm_disable_req pwm_dis_req; + struct gb_i2s_mgmt_get_supported_configurations_response i2s_mgmt_get_sup_conf_rsp; + struct gb_i2s_mgmt_get_processing_delay_response i2s_mgmt_get_proc_delay_rsp; }; }; diff --git a/i2s.c b/i2s.c index 9d9f5a1..9b9add6 100644 --- a/i2s.c +++ b/i2s.c @@ -18,17 +18,7 @@ #include "gbsim.h" -#define GB_I2S_MGMT_TYPE_PROTOCOL_VERSION 0x01 -#define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS 0x02 -#define GB_I2S_MGMT_TYPE_SET_CONFIGURATION 0x03 -#define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE 0x04 -#define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY 0x05 -#define GB_I2S_MGMT_TYPE_SET_START_DELAY 0x06 -#define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT 0x07 -#define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08 -#define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09 - -#define GB_I2S_DATA_TYPE_SEND_DATA 0x02 +#define CONFIG_COUNT_MAX 32 void i2s_mgmt_handler(__u8 *rbuf, size_t size) { @@ -36,6 +26,7 @@ void i2s_mgmt_handler(__u8 *rbuf, size_t size) char *tbuf; struct op_msg *op_req, *op_rsp; struct cport_msg *cport_req, *cport_rsp; + struct gb_i2s_mgmt_configuration *conf; size_t sz; tbuf = malloc(4 * 1024); @@ -51,6 +42,45 @@ void i2s_mgmt_handler(__u8 *rbuf, size_t size) oph = (struct op_header *)&op_req->header; switch (oph->type) { + case GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS: + sz = sizeof(struct op_header) + + sizeof(struct gb_i2s_mgmt_get_supported_configurations_response) + + sizeof(struct gb_i2s_mgmt_configuration) * CONFIG_COUNT_MAX; + + printf("JDB: sz=%i\n", sz); + op_rsp->header.size = htole16((__u16)sz); + op_rsp->header.id = oph->id; + + op_rsp->header.type = OP_RESPONSE | GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS; + op_rsp->header.result = PROTOCOL_STATUS_SUCCESS; + + op_rsp->i2s_mgmt_get_sup_conf_rsp.config_count = 1; + + conf = &op_rsp->i2s_mgmt_get_sup_conf_rsp.config[0]; + conf->sample_frequency = htole32(48000); + conf->num_channels = 2; + conf->bytes_per_channel = 2; + conf->byte_order = GB_I2S_MGMT_BYTE_ORDER_LE; + conf->spatial_locations = htole32( + GB_I2S_MGMT_SPATIAL_LOCATION_FL | + GB_I2S_MGMT_SPATIAL_LOCATION_FR); + conf->ll_protocol = htole32(GB_I2S_MGMT_PROTOCOL_I2S); + conf->ll_bclk_role = GB_I2S_MGMT_ROLE_MASTER; + conf->ll_wclk_role = GB_I2S_MGMT_ROLE_MASTER; + conf->ll_wclk_polarity = GB_I2S_MGMT_POLARITY_NORMAL; + conf->ll_wclk_change_edge = GB_I2S_MGMT_EDGE_FALLING; + conf->ll_wclk_tx_edge = GB_I2S_MGMT_EDGE_FALLING; + conf->ll_wclk_rx_edge = GB_I2S_MGMT_EDGE_RISING; + conf->ll_data_offset = 1; + + + + gbsim_debug("Module %d -> AP CPort %d I2S GET_CONFIGURATION response\n ", + cport_to_module_id(cport_req->cport), cport_rsp->cport); + if (verbose) + gbsim_dump((__u8 *)op_rsp, sz); + write(cport_in, cport_rsp, sz + 1); + break; case GB_I2S_MGMT_TYPE_SET_CONFIGURATION: sz = sizeof(struct op_header); op_rsp->header.size = htole16((__u16)sz);