From patchwork Fri Apr 3 00:22:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46739 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 30A02216D1 for ; Fri, 3 Apr 2015 00:22:32 +0000 (UTC) Received: by wibgr10 with SMTP id gr10sf21972696wib.2 for ; Thu, 02 Apr 2015 17:22:31 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=fSbPcdFW2x9iHmBRC6kQDAd4Y2jKpeJS/QDK9EdhSeg=; b=M62pj8SGkNTDbepRgz9B77xwz93Q6rglUnwPw9lXcP7r2GKN4ZS5HHMEV7A0VQ82hy Zkr6XeTsrgBbbwYtk9qoWbqYmMjniKYog5CfJI2ksVinEjOB8AZE2wOLflj7OA5j0uI8 p+l5z6Kf5CPbmcJaUPT92rxCBsvV/HJw0M+Qej6Zzbs7YmHv8VEqcjVE2mgR2nRUuGIO gVjFtRZzIEgV7gOhPOW33XCDk/o09GG/mW4WlxOP36GRR0JJ/zdO65OHyB6olUG2So/U 7ZYrhJvFQfyTrKxHg/BjYruBfB+deVQPY/vPP475bIelH1DFWXBGpfEUSv58LZnf4+MB zdGA== X-Gm-Message-State: ALoCoQlyFI0gzUoluigtwfkRAU2UeaflMmS6YWZnKwf/c1GSDFvf66milgy+BFxhN+vRqZkKUND7 X-Received: by 10.112.29.39 with SMTP id g7mr678507lbh.1.1428020551179; Thu, 02 Apr 2015 17:22:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.66 with SMTP id i2ls277954lah.21.gmail; Thu, 02 Apr 2015 17:22:30 -0700 (PDT) X-Received: by 10.112.170.132 with SMTP id am4mr42731107lbc.89.1428020550927; Thu, 02 Apr 2015 17:22:30 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id c6si5422921lbo.127.2015.04.02.17.22.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 17:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbdc10 with SMTP id c10so70064015lbd.2 for ; Thu, 02 Apr 2015 17:22:30 -0700 (PDT) X-Received: by 10.112.212.106 with SMTP id nj10mr42884699lbc.36.1428020550506; Thu, 02 Apr 2015 17:22: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.57.201 with SMTP id k9csp1657044lbq; Thu, 2 Apr 2015 17:22:29 -0700 (PDT) X-Received: by 10.68.215.100 with SMTP id oh4mr62694578pbc.110.1428020548665; Thu, 02 Apr 2015 17:22:28 -0700 (PDT) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com. [209.85.220.46]) by mx.google.com with ESMTPS id lr6si9586742pab.66.2015.04.02.17.22.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 17:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.46 as permitted sender) client-ip=209.85.220.46; Received: by paboj16 with SMTP id oj16so18418899pab.0 for ; Thu, 02 Apr 2015 17:22:27 -0700 (PDT) X-Received: by 10.68.223.165 with SMTP id qv5mr23694848pbc.82.1428020547603; Thu, 02 Apr 2015 17:22:27 -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 g9sm6360333pdj.24.2015.04.02.17.22.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Apr 2015 17:22:26 -0700 (PDT) From: John Stultz To: projectara-software-dev Cc: John Stultz , Alex Elder , Greg Kroah-Hartman , mark greer Subject: [PATCH] gbsim: Add GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS support Date: Thu, 2 Apr 2015 17:22:24 -0700 Message-Id: <1428020544-16453-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 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.177 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. (This applies on top of the previous patches I sent out) Cc: Alex Elder Cc: Greg Kroah-Hartman Cc: mark greer Signed-off-by: John Stultz --- gbsim.h | 33 ++++++++++++++++++++++++ i2s.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/gbsim.h b/gbsim.h index 1751fb8..715d9cb 100644 --- a/gbsim.h +++ b/gbsim.h @@ -198,6 +198,37 @@ struct pwm_disable_req { __u8 which; }; +struct gb_i2s_mgmt_configuration { + __le32 sample_frequency; + __u8 num_channels; + __u8 bytes_per_channel; + __u8 byte_order; + __u8 pad; + __le32 spatial_locations; + __le32 ll_protocol; + __u8 ll_bclk_role; + __u8 ll_wclk_role; + __u8 ll_wclk_polarity; + __u8 ll_wclk_change_edge; + __u8 ll_wclk_tx_edge; + __u8 ll_wclk_rx_edge; + __u8 ll_data_offset; + __u8 ll_pad; +}; + +struct gb_i2s_mgmt_get_supported_configurations_response { + __u8 config_count; + __u8 pad[3]; + struct gb_i2s_mgmt_configuration config[0]; +}; + +/* get processing request delay has no payload */ +struct gb_i2s_mgmt_get_processing_delay_response { + __le32 microseconds; +}; + + + /* Ops */ struct op_msg { struct op_header header; @@ -229,6 +260,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_supported_conf_resp; + struct gb_i2s_mgmt_get_processing_delay_response i2s_mgmt_get_processing_delay_res; }; }; diff --git a/i2s.c b/i2s.c index d4d3ce9..77a220a 100644 --- a/i2s.c +++ b/i2s.c @@ -28,6 +28,58 @@ #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT 0x08 #define GB_I2S_MGMT_TYPE_REPORT_EVENT 0x09 +#ifndef BIT +#define BIT(n) (1UL << (n)) +#endif +#define GB_I2S_MGMT_BYTE_ORDER_NA BIT(0) +#define GB_I2S_MGMT_BYTE_ORDER_BE BIT(1) +#define GB_I2S_MGMT_BYTE_ORDER_LE BIT(2) + +#define GB_I2S_MGMT_SPATIAL_LOCATION_FL BIT(0) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FR BIT(1) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FC BIT(2) +#define GB_I2S_MGMT_SPATIAL_LOCATION_LFE BIT(3) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BL BIT(4) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BR BIT(5) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FLC BIT(6) +#define GB_I2S_MGMT_SPATIAL_LOCATION_FRC BIT(7) +#define GB_I2S_MGMT_SPATIAL_LOCATION_C BIT(8) /* BC in USB */ +#define GB_I2S_MGMT_SPATIAL_LOCATION_SL BIT(9) +#define GB_I2S_MGMT_SPATIAL_LOCATION_SR BIT(10) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TC BIT(11) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFL BIT(12) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFC BIT(13) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFR BIT(14) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TBL BIT(15) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TBC BIT(16) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TBR BIT(17) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC BIT(18) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC BIT(19) +#define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE BIT(20) +#define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE BIT(21) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TSL BIT(22) +#define GB_I2S_MGMT_SPATIAL_LOCATION_TSR BIT(23) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BC BIT(24) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BLC BIT(25) +#define GB_I2S_MGMT_SPATIAL_LOCATION_BRC BIT(26) +#define GB_I2S_MGMT_SPATIAL_LOCATION_RD BIT(31) + +#define GB_I2S_MGMT_PROTOCOL_PCM BIT(0) +#define GB_I2S_MGMT_PROTOCOL_I2S BIT(1) +#define GB_I2S_MGMT_PROTOCOL_LR_STEREO BIT(2) + +#define GB_I2S_MGMT_ROLE_MASTER BIT(0) +#define GB_I2S_MGMT_ROLE_SLAVE BIT(1) + +#define GB_I2S_MGMT_POLARITY_NORMAL BIT(0) +#define GB_I2S_MGMT_POLARITY_REVERSED BIT(1) + +#define GB_I2S_MGMT_EDGE_RISING BIT(0) +#define GB_I2S_MGMT_EDGE_FALLING BIT(1) + +#define CONFIG_COUNT_MAX 32 + + #define GB_I2S_DATA_TYPE_SEND_DATA 0x02 void i2s_mgmt_handler(__u8 *rbuf, size_t size) @@ -51,6 +103,42 @@ 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_supported_conf_resp.config_count = 1; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].sample_frequency = 48000; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].num_channels = 2; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].bytes_per_channel = 2; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].byte_order = GB_I2S_MGMT_BYTE_ORDER_LE; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].spatial_locations = GB_I2S_MGMT_SPATIAL_LOCATION_FL | + GB_I2S_MGMT_SPATIAL_LOCATION_FR; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_protocol = GB_I2S_MGMT_PROTOCOL_I2S; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_bclk_role = GB_I2S_MGMT_ROLE_MASTER; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_wclk_role = GB_I2S_MGMT_ROLE_MASTER; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_wclk_polarity = GB_I2S_MGMT_POLARITY_NORMAL; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_wclk_change_edge = GB_I2S_MGMT_EDGE_FALLING; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_wclk_tx_edge = GB_I2S_MGMT_EDGE_FALLING; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].ll_wclk_rx_edge = GB_I2S_MGMT_EDGE_RISING; + op_rsp->i2s_mgmt_get_supported_conf_resp.config[0].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, op_rsp->header.size); + write(cport_in, cport_rsp, op_rsp->header.size + 1); + break; case GB_I2S_MGMT_TYPE_SET_CONFIGURATION: sz = sizeof(struct op_header); op_rsp->header.size = htole16((__u16)sz);