Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation with kernel 6.1 #67

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion drivers/media/pci/intel/ipu-isys-csi2-be-soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ __subdev_link_validate(struct v4l2_subdev *sd, struct media_link *link,
struct v4l2_subdev_format *source_fmt,
struct v4l2_subdev_format *sink_fmt)
{
struct ipu_isys_pipeline *ip = container_of(sd->entity.pipe,
struct media_pipeline *media_pipe = media_entity_pipeline(&sd->entity);
struct ipu_isys_pipeline *ip = container_of(media_pipe,
struct ipu_isys_pipeline,
pipe);

Expand Down
24 changes: 15 additions & 9 deletions drivers/media/pci/intel/ipu-isys-csi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ static struct v4l2_subdev_internal_ops csi2_sd_internal_ops = {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
int ipu_isys_csi2_get_link_freq(struct ipu_isys_csi2 *csi2, s64 *link_freq)
{
struct ipu_isys_pipeline *pipe = container_of(csi2->asd.sd.entity.pipe,
struct media_pipeline *media_pipe =
media_entity_pipeline(&csi2->asd.sd.entity);
struct ipu_isys_pipeline *pipe = container_of(media_pipe,
struct ipu_isys_pipeline,
pipe);
struct v4l2_subdev *ext_sd =
Expand Down Expand Up @@ -256,8 +258,9 @@ ipu_isys_csi2_calc_timing(struct ipu_isys_csi2 *csi2,

static int set_stream(struct v4l2_subdev *sd, int enable)
{
struct media_pipeline *media_pipe = media_entity_pipeline(&sd->entity);
struct ipu_isys_csi2 *csi2 = to_ipu_isys_csi2(sd);
struct ipu_isys_pipeline *ip = container_of(sd->entity.pipe,
struct ipu_isys_pipeline *ip = container_of(media_pipe,
struct ipu_isys_pipeline,
pipe);
struct ipu_isys_csi2_config *cfg;
Expand Down Expand Up @@ -315,21 +318,23 @@ static void csi2_capture_done(struct ipu_isys_pipeline *ip,

static int csi2_link_validate(struct media_link *link)
{
struct media_pipeline *media_pipe;
struct ipu_isys_csi2 *csi2;
struct ipu_isys_pipeline *ip;
int rval;

if (!link->sink->entity ||
!link->sink->entity->pipe || !link->source->entity)
if (!link->sink->entity || !link->source->entity)
return -EINVAL;
csi2 =
to_ipu_isys_csi2(media_entity_to_v4l2_subdev(link->sink->entity));
ip = to_ipu_isys_pipeline(link->sink->entity->pipe);
media_pipe = media_entity_pipeline(link->sink->entity);
if (!media_pipe)
return -EINVAL;

ip = to_ipu_isys_pipeline(media_pipe);
csi2->receiver_errors = 0;
ip->csi2 = csi2;
ipu_isys_video_add_capture_done(to_ipu_isys_pipeline
(link->sink->entity->pipe),
csi2_capture_done);
ipu_isys_video_add_capture_done(ip, csi2_capture_done);

rval = v4l2_subdev_link_validate(link);
if (rval)
Expand Down Expand Up @@ -396,7 +401,8 @@ static int __subdev_link_validate(struct v4l2_subdev *sd,
struct v4l2_subdev_format *source_fmt,
struct v4l2_subdev_format *sink_fmt)
{
struct ipu_isys_pipeline *ip = container_of(sd->entity.pipe,
struct media_pipeline *media_pipe = media_entity_pipeline(&sd->entity);
struct ipu_isys_pipeline *ip = container_of(media_pipe,
struct ipu_isys_pipeline,
pipe);

Expand Down
21 changes: 12 additions & 9 deletions drivers/media/pci/intel/ipu-isys-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,9 @@ static void __buf_queue(struct vb2_buffer *vb, bool force)
struct ipu_isys_queue *aq = vb2_queue_to_ipu_isys_queue(vb->vb2_queue);
struct ipu_isys_video *av = ipu_isys_queue_to_video(aq);
struct ipu_isys_buffer *ib = vb2_buffer_to_ipu_isys_buffer(vb);
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct ipu_isys_buffer_list bl;

struct ipu_fw_isys_frame_buff_set_abi *buf = NULL;
Expand Down Expand Up @@ -565,7 +566,7 @@ static void __buf_queue(struct vb2_buffer *vb, bool force)
if (ib->req)
return;

if (!pipe_av || !vb->vb2_queue->streaming) {
if (!pipe_av || !media_pipe || !vb->vb2_queue->streaming) {
dev_dbg(&av->isys->adev->dev,
"not pipe_av set, adding to incoming\n");
return;
Expand Down Expand Up @@ -789,7 +790,7 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)

mutex_lock(&av->isys->stream_mutex);

first = !av->vdev.entity.pipe;
first = !media_entity_pipeline(&av->vdev.entity);

if (first) {
rval = ipu_isys_video_prepare_streaming(av, 1);
Expand All @@ -807,7 +808,7 @@ static int start_streaming(struct vb2_queue *q, unsigned int count)
goto out_unprepare_streaming;
}

ip = to_ipu_isys_pipeline(av->vdev.entity.pipe);
ip = to_ipu_isys_pipeline(media_entity_pipeline(&av->vdev.entity));
pipe_av = container_of(ip, struct ipu_isys_video, ip);
mutex_unlock(&av->mutex);

Expand Down Expand Up @@ -863,8 +864,9 @@ static void stop_streaming(struct vb2_queue *q)
{
struct ipu_isys_queue *aq = vb2_queue_to_ipu_isys_queue(q);
struct ipu_isys_video *av = ipu_isys_queue_to_video(aq);
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct ipu_isys_video *pipe_av =
container_of(ip, struct ipu_isys_video, ip);

Expand Down Expand Up @@ -956,8 +958,9 @@ ipu_isys_buf_calc_sequence_time(struct ipu_isys_buffer *ib,
struct ipu_isys_queue *aq = vb2_queue_to_ipu_isys_queue(vb->vb2_queue);
struct ipu_isys_video *av = ipu_isys_queue_to_video(aq);
struct device *dev = &av->isys->adev->dev;
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
u64 ns;
u32 sequence;

Expand Down
3 changes: 2 additions & 1 deletion drivers/media/pci/intel/ipu-isys-subdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@ int ipu_isys_subdev_link_validate(struct v4l2_subdev *sd,
{
struct v4l2_subdev *source_sd =
media_entity_to_v4l2_subdev(link->source->entity);
struct ipu_isys_pipeline *ip = container_of(sd->entity.pipe,
struct media_pipeline *media_pipe = media_entity_pipeline(&sd->entity);
struct ipu_isys_pipeline *ip = container_of(media_pipe,
struct ipu_isys_pipeline,
pipe);
struct ipu_isys_subdev *asd = to_ipu_isys_subdev(sd);
Expand Down
59 changes: 41 additions & 18 deletions drivers/media/pci/intel/ipu-isys-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,7 @@ static int link_validate(struct media_link *link)
struct ipu_isys_video *av =
container_of(link->sink, struct ipu_isys_video, pad);
/* All sub-devices connected to a video node are ours. */
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct ipu_isys_pipeline *ip = &av->ip;
struct v4l2_subdev *sd;

if (!link->source->entity)
Expand Down Expand Up @@ -645,8 +644,9 @@ static void put_stream_opened(struct ipu_isys_video *av)

static int get_stream_handle(struct ipu_isys_video *av)
{
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
unsigned int stream_handle;
unsigned long flags;

Expand All @@ -667,8 +667,9 @@ static int get_stream_handle(struct ipu_isys_video *av)

static void put_stream_handle(struct ipu_isys_video *av)
{
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
unsigned long flags;

spin_lock_irqsave(&av->isys->lock, flags);
Expand Down Expand Up @@ -883,8 +884,9 @@ void
ipu_isys_prepare_fw_cfg_default(struct ipu_isys_video *av,
struct ipu_fw_isys_stream_cfg_data_abi *cfg)
{
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct ipu_isys_queue *aq = &av->aq;
struct ipu_fw_isys_output_pin_info_abi *pin_info;
struct ipu_isys *isys = av->isys;
Expand Down Expand Up @@ -1036,8 +1038,9 @@ static unsigned int get_comp_format(u32 code)
static int start_stream_firmware(struct ipu_isys_video *av,
struct ipu_isys_buffer_list *bl)
{
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct device *dev = &av->isys->adev->dev;
struct v4l2_subdev_selection sel_fmt = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
Expand Down Expand Up @@ -1275,8 +1278,9 @@ static int start_stream_firmware(struct ipu_isys_video *av,

static void stop_streaming_firmware(struct ipu_isys_video *av)
{
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct device *dev = &av->isys->adev->dev;
int rval, tout;
enum ipu_fw_isys_send_type send_type =
Expand Down Expand Up @@ -1304,8 +1308,9 @@ static void stop_streaming_firmware(struct ipu_isys_video *av)

static void close_streaming_firmware(struct ipu_isys_video *av)
{
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct device *dev = &av->isys->adev->dev;
int rval, tout;

Expand Down Expand Up @@ -1376,12 +1381,19 @@ int ipu_isys_video_prepare_streaming(struct ipu_isys_video *av,
dev_dbg(dev, "prepare stream: %d\n", state);

if (!state) {
ip = to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);

ip = to_ipu_isys_pipeline(media_pipe);

if (ip->interlaced && isys->short_packet_source ==
IPU_ISYS_SHORT_PACKET_FROM_RECEIVER)
short_packet_queue_destroy(ip);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
media_pipeline_stop(av->vdev.entity.pads);
#else
media_pipeline_stop(&av->vdev.entity);
#endif
media_entity_enum_cleanup(&ip->entity_enum);
return 0;
}
Expand Down Expand Up @@ -1410,7 +1422,11 @@ int ipu_isys_video_prepare_streaming(struct ipu_isys_video *av,
if (rval)
return rval;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
rval = media_pipeline_start(av->vdev.entity.pads, &ip->pipe);
#else
rval = media_pipeline_start(&av->vdev.entity, &ip->pipe);
#endif
if (rval < 0) {
dev_dbg(dev, "pipeline start failed\n");
goto out_enum_cleanup;
Expand Down Expand Up @@ -1451,7 +1467,11 @@ int ipu_isys_video_prepare_streaming(struct ipu_isys_video *av,
return 0;

out_pipeline_stop:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
media_pipeline_stop(av->vdev.entity.pads);
#else
media_pipeline_stop(&av->vdev.entity);
#endif

out_enum_cleanup:
media_entity_enum_cleanup(&ip->entity_enum);
Expand All @@ -1470,8 +1490,10 @@ static void configure_stream_watermark(struct ipu_isys_video *av)
struct isys_iwake_watermark *iwake_watermark;
struct v4l2_control vb = { .id = V4L2_CID_VBLANK, .value = 0 };
struct v4l2_control hb = { .id = V4L2_CID_HBLANK, .value = 0 };
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);

ip = to_ipu_isys_pipeline(av->vdev.entity.pipe);
ip = to_ipu_isys_pipeline(media_pipe);
if (!ip->external->entity) {
WARN_ON(1);
return;
Expand Down Expand Up @@ -1578,8 +1600,9 @@ int ipu_isys_video_set_streaming(struct ipu_isys_video *av,
struct media_entity_enum entities;

struct media_entity *entity, *entity2;
struct ipu_isys_pipeline *ip =
to_ipu_isys_pipeline(av->vdev.entity.pipe);
struct media_pipeline *media_pipe =
media_entity_pipeline(&av->vdev.entity);
struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_pipe);
struct v4l2_subdev *sd, *esd;
int rval = 0;

Expand Down
9 changes: 9 additions & 0 deletions drivers/media/pci/intel/ipu.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,13 @@ int request_cpd_fw(const struct firmware **firmware_p, const char *name,
extern enum ipu_version ipu_ver;
void ipu_internal_pdata_init(void);

/* Helpers for building against various kernel versions */
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
#include <media/media-entity.h>
static inline struct media_pipeline *media_entity_pipeline(struct media_entity *entity)
{
return entity->pipe;
}
#endif

#endif /* IPU_H */
3 changes: 2 additions & 1 deletion drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,10 @@ int ipu_isys_csi2_set_stream(struct v4l2_subdev *sd,
struct ipu_isys_csi2_timing timing,
unsigned int nlanes, int enable)
{
struct media_pipeline *media_pipe = media_entity_pipeline(&sd->entity);
struct ipu_isys_csi2 *csi2 = to_ipu_isys_csi2(sd);
struct ipu_isys *isys = csi2->isys;
struct ipu_isys_pipeline *ip = container_of(sd->entity.pipe,
struct ipu_isys_pipeline *ip = container_of(media_pipe,
struct ipu_isys_pipeline,
pipe);
struct ipu_isys_csi2_config *cfg =
Expand Down