The SVC is not the same as the Endo. There are some attributes
(such as the Endo ID) that are independent of attributes of
the SVC (like its version).
The current "Endo attributes" are really SVC attributes.
Rename a few functions and variables to reflect that.
Add a new attribute group for Endo-specific attributes, and
populate it with the Endo ID.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The maximum interface id on an Endo is the result of a non-trivial
calculation. It'll be needed for an upcoming patch, so create a
macro to compute it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The file "gpbridge.h" is now used as a single place to define
all protocol message structures. These protocols are not
necessarily related to the GP bridge, so the name of the
file is misleading.
Rename it "greybus_protocols.h".
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Avoid the need for all the source files to include "gpbridge.h"
by just having "greybus.h" include it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Return a pointer-coded error from greybus_create_hd() rather
than NULL in the event an error occurs.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Return a pointer-coded error from gb_endo_create() rather than just
a null pointer in the event an error occurs.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We are going to want to defer creating the endo until we receive a
probe operation from the SVC, which will supply the endo id. Change
gb_endo_create() so it passes the endo_id value as an argument.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change the name of "struct gb_svc" to be "struct svc_info". The
structure now contains only the SVC's serial number and version (and
are place holders anyway). We will be defining a structure that
represents the SVC for the SVC protocol connection, and I want to
take back that name.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
A recent commit moved the I2S samples per message operation
to the PCM's 'hw_params' callback. However, the 'hw_params'
callback is called numerous times while the samples per
message need only be done once (or seldom). Eliminate the
unnecessary samples per message operations by doing it only
once at Greybus protocol init time.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Currently, the audio driver unconditionally sets the I2S
configuration to have a sample rate of 48KHz, two channels,
16 bits per channel, in little endian order. Make this
more flexible by setting the I2S configuration according to
the arguments passed to the PCM 'hw_params' callback.
To accomplish this, query for the supported I2S configurations
at Greybus protocol init time and save them in the 'snd_dev'
structure. When the 'hw_params' callback is called, compare its
arguments to the table of supported configurations. If there is
a match, set the I2S connection accordingly.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Currently, the audio driver activates & deactivates a predefined
CPort ID but that can vary depending on the manifest data of the
module. Instead, use the TX connection's Bundle CPort ID which
contains the correct CPort ID.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Currently, the I2S TX CPort is configured and activated during
the Greybus audio initialization. Unfortunately, this prevents
the audio driver from ever changing the I2S configuration.
To allow the I2S configuration to change according to ASOC requests,
move the CPort activation & deactivation to the audio-pcm workqueue.
Now, when audio is running but the CPort is not active, it will be
activated. When audio is not running and the CPort is active, it
will be deactivated.
This has the side-effect of sending the first piece of audio data
immediately after activating the CPort which is really how it should
work anyway.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove comment about adding start delay since it will
be done when support for A/V synchronization is added.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add the I2C device node for the rt5647 codec.
Eventually, this will be done automatically somewhere
else but for now its done in the audio driver.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The asoc_simple_dai structure does not contain the 'fmt'
member in Linux kernel version v4.1 and later so only
build code that uses it when the kernel version is earlier
than v4.1.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Set the various DAI formats so the bridge on the module
is the master of all clocks and the codec is the slave.
The only DAI protocol currently supported is I2S.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Instead of using the fixed suffix, '6-001b', in the
codec name, generate it from the I2S adapter number
and I2C address of the codec.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The greybus code requires that an operation's response buffer be
the exact size of the response; however, the size of the response to
the GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS operation is unknown.
To fix this, an extension to the I2S specification is required.
In the meantime, set the number of configurations returned to 20
because that is how many configurations will be returned (using
"insider knowledge" of the firmware).
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The rt5647 codec on speaker and mediabar modules require that
the following clock edge settings:
ll_wclk_change_edge GB_I2S_MGMT_EDGE_FALLING
ll_wclk_tx_edge GB_I2S_MGMT_EDGE_RISING
ll_wclk_rx_edge GB_I2S_MGMT_EDGE_FALLING
(Those are the setting that work, at least). So make the Greybus
audio driver configure the GPBridge with those settings.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix section mismatches introduced by b27227ce93c0 ("greybus: Use
gb_gpbridge_protocol_init()"), which added __exit annotation to
gpbridge-protocol exit functions that are called in the error path of
gpbridge_init, which lives in the init section.
This triggered the following modpost warning:
WARNING: modpost: Found 8 section mismatch(es).
Fixes: 16b33d100bff ("protocol: Add gb_gpbridge_protocol_driver()")
Fixes: b27227ce93c0 ("greybus: Use gb_gpbridge_protocol_init()")
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add helper to retrieve the maximum payload size for operations on a
specific connection.
Note that the helper is not inlined due to how the header files are
currently organised, but it is not expected to be called after a
connection has been initialised either.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make sure we never end up with a host device with maximum buffer size
smaller than the shortest Greybus message.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Increase the maximum allowed buffer size to the full 16-bit range
supported by the protocol.
Note that host devices will generally use smaller buffers than the
maximum.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Host devices impose buffer-size constraints on Greybus core which are
taken into account when allocating messages.
Make sure to verify these constraints when the host device is allocated,
rather than when the first message is allocated.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove a couple of unused function prototypes from the greybus header
file.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove unnecessary greybus.h include from header files.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
There are many gpbridge protocol drivers that need gb_protocol_driver()
without the module_init/exit() lines. Lets create one for them.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
That's what followed for .h, etc.. Rename for better consistency.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This is what coding guidelines say. Lets do it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
In order to facilitate re-use of spi structures, split them out of
independent files and add them into a shared gpbridge.h
This will be a prereq to sharing these headers w/ gbsim.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Spaces were present in place of tab. Fix that.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This is what I get over mainline:
greybus/raw.c: In function 'gb_raw_send':
greybus/raw.c:153:2: error: implicit declaration of function 'copy_from_user' [-Werror=implicit-function-declaration]
if (copy_from_user(&request->data[0], data, len)) {
^
greybus/raw.c: In function 'raw_read':
greybus/raw.c:305:2: error: implicit declaration of function 'copy_to_user' [-Werror=implicit-function-declaration]
if (copy_to_user(buf, &raw_data->data[0], raw_data->len)) {
^
Fix this by including uaccess.h.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This adds a driver that implements the greybus Raw protocol as
specified.
It preserves the message boundries by only allowing a read to receive
a "full" message, and any write() call also is passed in a single
greybus request.
Totally untested, given that we have no raw firmware or gbsim code yet.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
ida_simple_* has a built-in spinlock, no need to grab another lock when
accessing it.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
All we need is a simple ida, so use that interface instead of the more
"complex" idr one. Bonus is we don't need to fix the locking issue I
forgot about when using an idr, as ida has one built-in.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
It should remove the object from sysfs when loopback
connection init error.
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add checks for options that shall be enabled in the kernel config
and for options that shall be disable.
To add options to list append them to CONFIG_OPTIONS_ENABLE or
CONFIG_OPTIONS_DISABLE respectively.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
There's no reason we can't support loopback pings or transfers
initiated by the module. Allow it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add some symbols to indicate what kind of "function" the
loopback thread is supposed to be performing--the type of
traffic it generates over its connection.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Use a symbolic constant to define the maximum time (number of
milliseconds) to delay between initiated operations.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix a comment that incorrectly says the delay between messages is
limited to 1024 msec; it actually must be <= 1000 msec.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
If an error occurs starting up the loopback thread, the error code
is not extracted properly. Fix that.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
In gb_loopback_check_attr(), the value of gb->type is checked for
validity. The only valid values are 0, 1, and 2. But the check
allows the value 3. Fix that.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
sparse is rightfully complaining about a lack of converting when
accessing or assigning to little endian fields. Fix them all up to work
properly.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>