From: "Daniel W. S. Almeida" <dwlsalmeida@xxxxxxxxx>
Digital TV devices consist of several independent hardware components
which are controlled by different drivers.
Each media device is controlled by a group of cooperating drivers with the
bridge driver as the main driver.
This patch adds a bridge driver for the Virtual Digital TV driver [vidtv].
--- /dev/null
+++ b/drivers/media/test-drivers/vidtv/vidtv_mux.c
+static u32 vidtv_mux_check_mux_rate(struct vidtv_mux *m)
+{
+ /*
+ * attempt to maintain a constant mux rate, padding with null packets
+ * if needed
+ */
+
+ u32 nbytes = 0; /* the number of bytes written by this function */
+
+ u64 nbytes_expected; /* the number of bytes we should have written */
+ u64 nbytes_streamed; /* the number of bytes we actually wrote */
+ u32 num_null_pkts; /* number of null packets to bridge the gap */
+
+ u64 elapsed_time_msecs = jiffies_to_usecs(m->timing.current_jiffies -
+ m->timing.past_jiffies);
+
+ elapsed_time_msecs = min(elapsed_time_msecs, (u64)VIDTV_MAX_SLEEP_USECS / 1000);
+ nbytes_expected = div64_u64(m->mux_rate_kbytes_sec * 1000, MSEC_PER_SEC);
+ nbytes_expected *= elapsed_time_msecs;
+
+ nbytes_streamed = m->mux_buf_offset;
+
+ if (nbytes_streamed < nbytes_expected) {
+ /* can't write half a packet: roundup to a 188 multiple */
+ nbytes_expected = roundup(nbytes_expected - nbytes_streamed, TS_PACKET_LEN);
+ num_null_pkts = nbytes_expected / TS_PACKET_LEN;
+ nbytes += vidtv_mux_pad_with_nulls(m, num_null_pkts);
+ }
+
+ return nbytes;
+}
--- /dev/null
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+static void vidtv_s302m_compute_pts(struct vidtv_encoder *e)
+{
+ u64 count = e->sample_count;
+ struct vidtv_access_unit *au = e->access_units;
+
+ while (au) {
+ count += au->num_samples;
+
+ au->pts = count *
+ CLOCK_UNIT_90KHZ / e->sampling_rate_hz;
+
+ au = au->next;
+ }
+}