if (!enable)
                return 0;
 
-       format = &bru->entity.formats[BRU_PAD_SOURCE];
+       format = &bru->entity.formats[bru->entity.source_pad];
 
        /* The hardware is extremely flexible but we have no userspace API to
         * expose all the parameters, nor is it clear whether we would have use
                       VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
                       VI6_BRU_ROP_AROP(VI6_ROP_NOP));
 
-       for (i = 0; i < 4; ++i) {
+       for (i = 0; i < bru->entity.source_pad; ++i) {
                bool premultiplied = false;
                u32 ctrl = 0;
 
        *format = fmt->format;
 
        /* Reset the compose rectangle */
-       if (fmt->pad != BRU_PAD_SOURCE) {
+       if (fmt->pad != bru->entity.source_pad) {
                struct v4l2_rect *compose;
 
                compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which);
        if (fmt->pad == BRU_PAD_SINK(0)) {
                unsigned int i;
 
-               for (i = 0; i <= BRU_PAD_SOURCE; ++i) {
+               for (i = 0; i <= bru->entity.source_pad; ++i) {
                        format = vsp1_entity_get_pad_format(&bru->entity, cfg,
                                                            i, fmt->which);
                        format->code = fmt->format.code;
 {
        struct vsp1_bru *bru = to_bru(subdev);
 
-       if (sel->pad == BRU_PAD_SOURCE)
+       if (sel->pad == bru->entity.source_pad)
                return -EINVAL;
 
        switch (sel->target) {
        struct v4l2_mbus_framefmt *format;
        struct v4l2_rect *compose;
 
-       if (sel->pad == BRU_PAD_SOURCE)
+       if (sel->pad == bru->entity.source_pad)
                return -EINVAL;
 
        if (sel->target != V4L2_SEL_TGT_COMPOSE)
        /* The compose rectangle top left corner must be inside the output
         * frame.
         */
-       format = vsp1_entity_get_pad_format(&bru->entity, cfg, BRU_PAD_SOURCE,
-                                           sel->which);
+       format = vsp1_entity_get_pad_format(&bru->entity, cfg,
+                                           bru->entity.source_pad, sel->which);
        sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1);
        sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1);
 
 
        bru->entity.type = VSP1_ENTITY_BRU;
 
-       ret = vsp1_entity_init(vsp1, &bru->entity, 5);
+       ret = vsp1_entity_init(vsp1, &bru->entity,
+                              vsp1->pdata.num_bru_inputs + 1);
        if (ret < 0)
                return ERR_PTR(ret);