tspp: Add option to inverse tsif signals

TSIF signals (clock, data, enable and sync) may be configured
to be inversed at TSPP unit input. This is useful in case
TSIF signals from external units need to be inversed.

Change-Id: I4f0bfdc58fb8658dbf10fe3805b8787f9d36aeca
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Extended and unified parameters of demux module

Demux parameters were unified to have same semantics across
different demux plugins. Extended the parameters to add option
to invert the tsif clock signal.

Change-Id: I1b253d27353feb0b9c9214fcfafb8b257da6528e
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: dvb-core: Stall demux in PULL mode when events queue is full

In PULL mode demux should stall when output buffers are full until
there's free space for new data. The demux data events queue could
also get full and overflow if user is not reading data fast enough.
Added checking the fullness of data events queue when working in PULL
mode so that demux stalls in case it is full.

Change-Id: I3d2cb89a2e3c5fb8e1be4b1df9d7efbb8ca458e2
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: TSPP output buffer allocation by demux plugin

The TSPP driver can allocate its output buffers internally or
externally. External buffer allocation is required when Demux wishes
to use the ION driver to allocate a physically contiguous buffer
(e.g. to pass to TZ).
This commit improves the TSPP driver support for external buffer
allocation and implements the external memory allocation and free
functions in the Demux driver.

Change-Id: Id7e815fa56b76401ed593a786eb61d97735deba9
Signed-off-by: Liron Kuch <lkuch@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Set smaller descriptor size for section pipe

Section and PES/recording pipes had same descriptor sizes,
notification rate from BAM for both types was the same. Since
sections are lower-bitrate than PES/recording data, the descriptor
size for sections pipe was reduced to allow better responsiveness
to this kind of data.

Change-Id: I8b99a1b4c38bb9a9fdfa8d3fb4d1864b133d954a
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: dvb-core: Fix memory leak in DVR buffers

When DVR buffer mode changes between internal/external, the DVR
buffer pointer gets updated with the new allocated memory.
This overrides the existing pointer to the memory allocated
previously. The code was changed so that when switching between
internal and external modes the currently allocated memory
is released.

Change-Id: I07690cc3aa86827114419b1d47ee40f47338766b
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: Add information on active filters in debugfs

Expose demux filters settings and status on debugfs to
improve debugging of demux devices.

Change-Id: I08df8a4c6a21a80bda7d0c6712edfdebef70ff0c
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: dvb-core: Improve handling of 192 packets output

Different filters may have different output format, therefore
the ts packet output format should be per feed. It should also
allow outputting real time-stamp if available.

Change-Id: Id174610d50c94f24abae5637ae052aeee92eeec4
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
misc: tspp: Enable notification of TSIF status and expose it in debugfs

Enable TSIF status interrupt to expose the following
information in debugfs:
- stat_rx_chunks: Counts number of TS packets chunks received from HW.
- stat_overflow: Counts number of times buffer has overflowed.
- stat_lost_sync: Counts number of times TSIF lost sync with input.
- stat_timeout: Counts number of times TSIF reached timeout
waiting for packets.

All counters can read and reset by writing to the respective file.

Change-Id: I42e71d072d8b92bdc8ecf941daef4ac0faa94de6
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
dvb: dvb-core: Use kthread instead of workqueue to process DVR input

Existing code uses workqueue for DVR input work which constantly waits
for new data written to the input buffer. This causes the kworker
executing DVR work to be fully occupied by DVR device and does not
allow other drivers using workqueues to use that kworker. To solve
this switched to kernel thread which is solely used for DVR device.

Change-Id: Ica740965aceec63e95eb2be4b3c20e242a8301fe
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Use kthread instead of workqueue

demux used single-threaded workqueue to process TS packets
notified from the HW. Workqueue implementation was changed
so that all work scheduled to workqueues are submitted
to same kworker threads, this result on having TS packet
processing not to be done on demux own thread and compete
with other work scheduled by other drivers. Moved to separate
thread dedicated only for demux.

Change-Id: Ia8b96543f26428a0a12809d34c27849f900cc45e
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
msm: sps: support polling when pipe is in IRQ mode

BAM client has a new use case where active polling is needed when
the pipe is configured in the interrupt mode. Add the support in SPS
driver for this use case.

Change-Id: I55603de946b77004a38ab1dbca995072e9066f54
Signed-off-by: Yan He <yanhe@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
tspp: Improve data-path handling

Existing driver allocated BAM descriptor at fixed sizes each
with interrupt flag set. Notification on data was received when
the descriptor is fully consumed by the HW. The descriptor size
on one hand need to be big enough so that we don't receive too much
interrupts for high-bitrate streams, and on other hand needs
to be small enough so that for low-bitrate stream we are not starved
waiting for data for a long period of time.

The change adds support of allocating small descriptors and set
interrupt flags on part of descriptors. In addition, expiration
timer is used so that if interrupt is not received after long period
of time the timer handler reports back descriptors are already ready
to be consumed. This allows low-rate of interrupts and
handling of low-bitrate streams.

As descriptors are smaller now (size of single TS packet), exposed
API within SW demux that handles a single packet to save the function
call to the API that handles multiple packets for efficiency. Information
regarding the new buffer allocation was added to debugfs.

CRs-Fixed: 420818

Change-Id: I9dedb1d1bc99c871d1aa12addeed9fe187f17bb1
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: mpq_streambuffer linear buffer support

Add linear buffer group management to mpq_streambuffer.
This change enables better support of video data consumers
that are required to use linear buffers scheme by eliminating
the need to copy data between buffers and may result in better
performance.

Change-Id: I8a893f9191ae441475fa535c25cc3295c879cfbc
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Improve PTS/DTS information reporting

PTS/DTS information may exist in the PES headers in the video
transport stream. PTS/DTS information must be reported for video frames
only if it hasn't been reported already. PTS/DTS information must be
reported according to the information available in the PES header
relevant for the video frame currently handled.
This commit updates the algorithm used to report PTS/DTS information
to comply with the above requirements.

Change-Id: Ie2276904e768a36dbd439b66b4aee7d3d98d8527
Signed-off-by: Liron Kuch <lkuch@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: External buffers support for decoder filters

Extend Demux user-space API to set decoder buffers allocated externally
by user, supporting multiple linear buffers or a single cyclic buffer.
Internal decoder buffer allocation is still supported.

Change-Id: I1df53d3961ab7934bd4a969cff1dae435ae1dfc6
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
drivers: media: dvb: mpq: Fix framing for external decoder buffers

Framing used to rely on underlying decoder buffer being managed as
ring buffer, and used absolute addresses to derive frame length.
This fix changes this and framing is now agnostic to the number
of decoder buffers, and whether they are managed as a ring-buffer
or as a group of linear buffers.
In addition, instead of reporting each pattern, framing now only
notifies video consumer on video frame patterns. Previous non-video
frame patterns are still included in the output data.

Change-Id: Ia3fe350110b77b3a7805e23f13927913e643f479
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
tspp: Disable read-complete interrupt

Read-complete interrupt can be generated from TSPP HW for test
purposes only. It is generated for each TS packet TSPP fetches from
TSIF interface. Having it enabled cause great load of interrupts
that are not used by the SW.

Change-Id: I4eb1be173cb3e30a8540fb17223abc034c54f048
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Support new elementary stream data events

Video elemenatry stream data is usually passed from demux to a video
consumer (e.g. video decoder) in kernel-space via tunneling. However
there are cases when the video consumer is a user-space application
controlled by the middleware. This change adds support for notifying
user-space about newly available elementary stream data and
associated meta-data, using the existing events queue mechanism.

Change-Id: I1994879f9056abea389602224fa970bd029b1e56
Signed-off-by: Liron Kuch <lkuch@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: Fix un-mapping of external buffers

The output buffers of demux filters can be set in decoder
and in non-PES filters, it is separate from the video output
buffers. When filter is stopped the buffer should be un-mapped
always if it was mapped previously regardless of the filter's type.

Change-Id: I5e0562b23e983a9c624be2dd71612ef23f3b50d0
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>