15 #include <linux/export.h>
16 #include <linux/types.h>
17 #include <linux/errno.h>
23 #define DMFC_RD_CHAN 0x0000
24 #define DMFC_WR_CHAN 0x0004
25 #define DMFC_WR_CHAN_DEF 0x0008
26 #define DMFC_DP_CHAN 0x000c
27 #define DMFC_DP_CHAN_DEF 0x0010
28 #define DMFC_GENERAL1 0x0014
29 #define DMFC_GENERAL2 0x0018
30 #define DMFC_IC_CTRL 0x001c
31 #define DMFC_STAT 0x0020
33 #define DMFC_WR_CHAN_1_28 0
34 #define DMFC_WR_CHAN_2_41 8
35 #define DMFC_WR_CHAN_1C_42 16
36 #define DMFC_WR_CHAN_2C_43 24
38 #define DMFC_DP_CHAN_5B_23 0
39 #define DMFC_DP_CHAN_5F_27 8
40 #define DMFC_DP_CHAN_6B_24 16
41 #define DMFC_DP_CHAN_6F_29 24
43 #define DMFC_FIFO_SIZE_64 (3 << 3)
44 #define DMFC_FIFO_SIZE_128 (2 << 3)
45 #define DMFC_FIFO_SIZE_256 (1 << 3)
46 #define DMFC_FIFO_SIZE_512 (0 << 3)
48 #define DMFC_SEGMENT(x) ((x & 0x7) << 0)
49 #define DMFC_BURSTSIZE_128 (0 << 6)
50 #define DMFC_BURSTSIZE_64 (1 << 6)
51 #define DMFC_BURSTSIZE_32 (2 << 6)
52 #define DMFC_BURSTSIZE_16 (3 << 6)
96 #define DMFC_NUM_CHANNELS ARRAY_SIZE(dmfcdata)
161 "dmfc: using %d slots starting from segment %d for IPU channel %d\n",
162 slots, segment, dmfc->
data->ipu_channel);
203 val &= ~(0xff << dmfc->
data->shift);
204 val |= field << dmfc->
data->shift;
216 static int dmfc_bandwidth_to_slots(
struct ipu_dmfc_priv *priv,
227 static int dmfc_find_slots(
struct ipu_dmfc_priv *priv,
int slots)
229 unsigned slotmask_need, slotmask_used = 0;
232 slotmask_need = (1 <<
slots) - 1;
235 slotmask_used |= priv->
channels[i].slotmask;
237 while (slotmask_need <= 0xff) {
238 if (!(slotmask_used & slotmask_need))
253 dev_dbg(priv->
dev,
"dmfc: freeing %d slots starting from segment %d\n",
271 dmfc_find_slots(priv, priv->
channels[i].slots);
280 ipu_dmfc_setup_channel(&priv->
channels[i],
291 unsigned long bandwidth_pixel_per_second,
int burstsize)
294 int slots = dmfc_bandwidth_to_slots(priv, bandwidth_pixel_per_second);
295 int segment = 0,
ret = 0;
297 dev_dbg(priv->
dev,
"dmfc: trying to allocate %ldMpixel/s for IPU channel %d\n",
298 bandwidth_pixel_per_second / 1000000,
299 dmfc->
data->ipu_channel);
310 segment = dmfc_find_slots(priv, slots);
316 ipu_dmfc_setup_channel(dmfc, slots, segment, burstsize);
332 if ((dmfc->
slots * 64 * 4) / width > dmfc->
data->max_fifo_lines)
333 dmfc_gen1 |= 1 << dmfc->
data->eot_shift;
335 dmfc_gen1 &= ~(1 << dmfc->
data->eot_shift);
349 if (dmfcdata[i].ipu_channel == ipu_channel)
396 dev_dbg(dev,
"dmfc: 8 slots with %ldMpixel/s bandwidth each\n",