From mboxrd@z Thu Jan 1 00:00:00 1970 From: Inki Dae Subject: RE: [PATCH] RFC: omapdrm DRM/KMS driver for TI OMAP platforms Date: Wed, 07 Sep 2011 15:00:40 +0900 Message-ID: <004e01cc6d23$78c151c0$6a43f540$%dae@samsung.com> References: <1314994047-4101-1-git-send-email-rob.clark@linaro.org> <002201cc6bb2$61779780$2466c680$%dae@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-reply-to: Content-language: ko List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-dev-bounces-cunTk1MwBs8s++Sfvej+rw@public.gmane.org Errors-To: linaro-dev-bounces-cunTk1MwBs8s++Sfvej+rw@public.gmane.org To: 'Rob Clark' Cc: "'Valkeinen, Tomi'" , linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org List-Id: dri-devel@lists.freedesktop.org Hello, Rob. > -----Original Message----- > From: robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org [mailto:robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] On Behalf Of Rob > Clark > Sent: Tuesday, September 06, 2011 1:05 AM > To: Inki Dae > Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org; > Valkeinen, Tomi > Subject: Re: [PATCH] RFC: omapdrm DRM/KMS driver for TI OMAP platforms > = > On Mon, Sep 5, 2011 at 4:58 AM, Inki Dae wrote: > > Hello, Rob. > > I didn't look into any comments from other develops yet , so my comments > > could be duplicated with other ones. below is my opinions and I > commented > > your codes also. > > > > We can discuss crtc, encoder and connector. in x86 world, my > understanding, > > each one means the following. > = > just fwiw, some of current implementation in the KMS code is result of > how the DSS2 API works.. ie. a dssdev (panel driver) is really part > encoder and part connector. > = > But on other hand, there are customers who write their own panel > drivers in DSS2 so I'm not sure that we want to completely change > this. And the encoder/connector distinction gets a bit more blurry w/ > smart-panel type displays. > = > [snip] > >> +static int omap_connector_mode_valid(struct drm_connector *connector, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct dr= m_display_mode *mode) > >> +{ > >> + =A0 =A0 struct omap_connector *omap_connector =3D > >> to_omap_connector(connector); > >> + =A0 =A0 struct omap_dss_device *dssdev =3D omap_connector->dssdev; > >> + =A0 =A0 struct omap_dss_driver *dssdrv =3D dssdev->driver; > >> + =A0 =A0 struct omap_video_timings timings =3D {0}; > >> + =A0 =A0 struct drm_device *dev =3D connector->dev; > >> + =A0 =A0 struct drm_display_mode *new_mode; > >> + =A0 =A0 int ret =3D MODE_BAD; > >> + > >> + =A0 =A0 copy_timings_drm_to_omap(&timings, mode); > >> + =A0 =A0 mode->vrefresh =3D drm_mode_vrefresh(mode); > >> + > >> + =A0 =A0 if (!dssdrv->check_timings(dssdev, &timings)) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 /* check if vrefresh is still valid */ > >> + =A0 =A0 =A0 =A0 =A0 =A0 new_mode =3D drm_mode_duplicate(dev, mode); > >> + =A0 =A0 =A0 =A0 =A0 =A0 new_mode->clock =3D timings.pixel_clock; > >> + =A0 =A0 =A0 =A0 =A0 =A0 new_mode->vrefresh =3D 0; > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (mode->vrefresh =3D=3D drm_mode_vrefresh(= new_mode)) > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D MODE_OK; > >> + =A0 =A0 =A0 =A0 =A0 =A0 drm_mode_destroy(dev, new_mode); > >> + =A0 =A0 } > >> + > > > > is there any reason that you call drm_mode_duplicate() to get a clone of > a > > mode? I just wonder it. > = > yes, because the new_mode is modified and I didn't want this fxn to > have unintended side-effects. > = > this works in a slightly funny way, because dssdev->check_timings() is > actually a dssdev->check_and_modify_timings(), modifying the pixel > clock to the closest thing that is supported. We need to compare the > resulting vrefresh to see if it is something matching.. otherwise we > ask for some resolution @ 60Hz and maybe get 30Hz instead. > = > [snip] > >> +/* initialize connector */ > >> +struct drm_connector * omap_connector_init(struct drm_device *dev, > >> + =A0 =A0 =A0 =A0 =A0 =A0 int connector_type, struct omap_dss_device *= dssdev) > >> +{ > >> + =A0 =A0 struct drm_connector *connector =3D NULL; > > > > It appears that this connector is initialized with NULL. This is just > minor > > issue. :) > = > it is so it isn't uninitialized if kzalloc fails and we 'goto fail'.. > I guess in this particular case there is only a single fail point, > although it is a coding pattern that I follow elsewhere where there > are multiple fail points. And at least this way if I added some other > step later where it might fail after the kzalloc(), I won't > accidentally miss the appropriate cleanup. I mostly prefer to have a > single cleanup path when possible so I don't confuse myself later > = > [snip] > >> +static void page_flip_cb(void *arg) > >> +{ > >> + =A0 =A0 struct drm_crtc *crtc =3D arg; > >> + =A0 =A0 struct drm_device *dev =3D crtc->dev; > >> + =A0 =A0 struct omap_crtc *omap_crtc =3D to_omap_crtc(crtc); > >> + =A0 =A0 struct drm_pending_vblank_event *event =3D omap_crtc->event; > >> + =A0 =A0 struct timeval now; > >> + =A0 =A0 unsigned long flags; > >> + > >> + =A0 =A0 WARN_ON(!event); > >> + > >> + =A0 =A0 omap_crtc->event =3D NULL; > >> + > >> + =A0 =A0 update_scanout(crtc); > >> + =A0 =A0 commit(crtc); > >> + > >> + =A0 =A0 /* wakeup userspace */ > >> + =A0 =A0 // TODO: this should happen *after* flip.. somehow.. > >> + =A0 =A0 if (event) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 spin_lock_irqsave(&dev->event_lock, flags); > >> + =A0 =A0 =A0 =A0 =A0 =A0 event->event.sequence =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 drm_vblank_c= ount_and_time(dev, > > omap_crtc->id, > >> &now); > >> + =A0 =A0 =A0 =A0 =A0 =A0 event->event.tv_sec =3D now.tv_sec; > >> + =A0 =A0 =A0 =A0 =A0 =A0 event->event.tv_usec =3D now.tv_usec; > >> + =A0 =A0 =A0 =A0 =A0 =A0 list_add_tail(&event->base.link, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &event->base= .file_priv->event_list); > >> + =A0 =A0 =A0 =A0 =A0 =A0 wake_up_interruptible(&event->base.file_priv->event_wait); > >> + =A0 =A0 =A0 =A0 =A0 =A0 spin_unlock_irqrestore(&dev->event_lock, fla= gs); > >> + =A0 =A0 } > > > > How about moving codes above into interrupt handler for vblank? > > maybe there > = > I should mention a couple of things: > = > 1) drm vblank stuff isn't really used currently.. it is actually DSS2 > layer that is registering for the display related interrupt(s). I'm > not really sure how to handle this best. I suppose the DRM driver > could *also* register for these interrupts, but that seems a bit odd.. > = DRM Framework supports only one interrupt handler. this issue should be resolved. and currently I made our driver to use its own request_irq, not DRM Framework side. we only sets drm_device->irq_enabled to 1 and interrupt handler is registered at display controller or hdmi driver respectively. but I'm not sure that this way is best so I will look over more. Anyway current drm framework should be fixed to be considered with multiple irq. > Also, I guess it is also worth mentioning.. when it comes to vblank, > there are two fundamentally different sorts of displays we deal with. > Something like DVI/HDMI/etc which need constant refreshing. In these > cases we constantly scan-out the buffer until the next page > flip+vsync. And smart panels, where they get scanned out once and > then DSS is no longer reading the scanout buffer until we manually > trigger an update. > = Is the Smart panel CPU interface based lcd panel that has its own framebuffer internally.? > 2) updating things like scanout address for framebuffers, these are > actually double-buffered registers in the DSS block. So the update of > actual scanout address is automatically synchronized by the hardware > w/ the vblank. The one thing I need to do still is defer the event > back to userspace until after the flip so it doesn't start rendering > onto the buffer that is still being scanned out. I'm not quite sure > the best way to do this yet. DSS2 driver has an API that I can > register for IRQ callbacks, although the knowledge about the right > callback to register (VSYNC, VSYNC2, FRAMEDONE, EVSYNC_ODD, > EVSYNC_EVEN, etc) is in the dssdev/connector. I could use > omap_connector_sync() to block until vsync/framedone but I'd prefer a > non-blocking mechanism. > = > > would be some reason that spin_lock_* are used here. > = > dev->event_lock seems to be used to protect modifying event_list > elsewhere.. > = > >> +} > >> + > >> +static int omap_crtc_page_flip_locked(struct drm_crtc *crtc, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0struct drm_framebuffer *fb, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0struct drm_pending_vblank_event *event) > >> +{ > >> + =A0 =A0 struct drm_device *dev =3D crtc->dev; > >> + =A0 =A0 struct omap_crtc *omap_crtc =3D to_omap_crtc(crtc); > >> + > >> + =A0 =A0 DBG("%d -> %d", crtc->fb ? crtc->fb->base.id : -1, fb->base.= id); > >> + > >> + =A0 =A0 if (omap_crtc->event) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "already a pending flip\n"= ); > >> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL; > >> + =A0 =A0 } > >> + > >> + =A0 =A0 crtc->fb =3D fb; > >> + =A0 =A0 omap_crtc->event =3D event; > >> + > >> + =A0 =A0 omap_gem_op_async(omap_framebuffer_bo(fb), OMAP_GEM_READ, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 page_flip_cb, crtc); > >> + > >> + =A0 =A0 return 0; > >> +} > >> + > > > > Where are drm_vblank_get() and drm_vblank_put() called to enable and > disable > > vsync interrupt? and does the this page flip need user-requested > drm_control > > ioctl to install/uninstall a handler?. I think the page_flip feature > should > > work it fine itself. > > > > like this: > > at omap_crtc_page_flip_locked() > > drm_vblank_get(); =A0 <- enable vsync interrupt. > > update famebuffer. <- update overlay and set it to hw. > > > > at interrupt handler > > handle page flip event. > > wake_up_interruptible() <- notify =A0user of page flip event. > > drm_vblank_put(); =A0<- disable vsync interrupt. > > > > I think that page flip callback would be called after vsync interrupt > > occurred. for this, you can refer to set_mode function of libdrm library. > a > > event has user's apage flip handler and when user received any event > from > > kernel side, this handler would be called to update framebuffer > repeatedly. > = > The main reason for the page-flip cb is actually not vsync > synchronization, but rather synchronizing with other hw blocks that > might be rendering to the buffer.. the page flip can be submitted > from userspace while some other hw block (3d, 2d, etc) is still > DMA'ing to the buffer. The sync-obj is intended to give a way to > defer the (in this case) page flip until other hw blocks are done > writing to the buffer. I thought page-flip is used to change buffer register value of display controller into another one like the Pan Display feature of linux framebuffer. actually page flip interface of libdrm library, page_flip_handler, is called with new framebuffer id that has its own buffer. and then the controller using current crtc would be set to buffer address of new framebuffer. and I understood that for other blocks such as 2d/3d accelerators, rendering synchronization you already mentioned above, is not depend on page flip action. It=92s a sequence with my understanding below. 1. allocate a new buffer through drm interface such as DUMB_* or SPECIFIC IOCTLs. 2. render something on this buffer through DRM interfaces that handle 2D/3D Accelerators and also it would use their own interfaces for synchronization. 3. allocate a new framebuffer and attach the buffer to this framebuffer. 4. call page flip to change current framebuffer to the framebuffer above at vblank moment. at this time, buffer address of the framebuffer would be set to a controller. finally, we can see some image rendered on diplay. thus, I think page flip and rendering synchronization have no any relationship. if I missed any points, please give me your comments. > = > (I guess in the same way, I could use the sync-obj to prevent someone > else writing to frame n-1 until the vsync irq.. but as mentioned > earlier I still need to sort out a sane way to handle the different > sorts of irq's we get back for different sorts of panels when they are > done reading from a buffer.) > = > [snip] > >> +static int omap_modeset_init(struct drm_device *dev) > >> +{ > >> + =A0 =A0 const struct omap_drm_platform_data *pdata =3D dev->dev- > >> >platform_data; > >> + =A0 =A0 struct omap_drm_private *priv =3D dev->dev_private; > >> + =A0 =A0 struct omap_dss_device *dssdev =3D NULL; > >> + =A0 =A0 int i, j; > >> + =A0 =A0 unsigned int connected_connectors =3D 0; > >> + > >> + =A0 =A0 /* create encoders for each manager */ > >> + =A0 =A0 int create_encoder(int i) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct omap_overlay_manager *mgr =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 omap_dss_get= _overlay_manager(i); > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_encoder *encoder =3D omap_encoder= _init(dev, mgr); > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!encoder) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "could not= create encoder\n"); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 priv->encoders[priv->num_encoders++] =3D enc= oder; > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 return 0; > >> + =A0 =A0 } > >> + > >> + =A0 =A0 /* create connectors for each display device */ > >> + =A0 =A0 int create_connector(struct omap_dss_device *dssdev) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 static struct notifier_block *notifier; > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_connector *connector; > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!dssdev->driver) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(dev->dev, "%s has n= o driver.. skipping > > it\n", > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 dssdev->name); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!(dssdev->driver->get_timings || > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 dssdev->driver->read_edid)) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(dev->dev, "%s drive= r does not support " > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "get_timings= or read_edid.. skipping it!\n", > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dssdev->name= ); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 connector =3D omap_connector_init(dev, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 get_connecto= r_type(dssdev), dssdev); > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!connector) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "could not= create connector\n"); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 /* track what is already connected.. rather = than looping > >> thru > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* all connectors twice later, first for c= onnected then > for > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* remainder (which could be a race condit= ion if connected > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* status changes) > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (omap_connector_detect(connector, true) = =3D=3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 connector_st= atus_connected) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 connected_connectors |=3D (1= << priv->num_connectors); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 priv->connectors[priv->num_connectors++] =3D= connector; > >> + > >> +#if 0 /* enable when dss2 supports hotplug */ > >> + =A0 =A0 =A0 =A0 =A0 =A0 notifier =3D kzalloc(sizeof(struct notifier_= block), > >> GFP_KERNEL); > >> + =A0 =A0 =A0 =A0 =A0 =A0 notifier->notifier_call =3D omap_drm_notifie= r; > >> + =A0 =A0 =A0 =A0 =A0 =A0 omap_dss_add_notify(dssdev, notifier); > >> +#else > >> + =A0 =A0 =A0 =A0 =A0 =A0 notifier =3D NULL; > >> +#endif > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (j =3D 0; j < priv->num_encoders; j++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct omap_overlay_manager = *mgr =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 omap_encoder_get_manager(priv->encoders[j]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (mgr->device =3D=3D dssde= v) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 drm_mode_connector_attach_encoder(connector, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 priv->encoders[j]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 return 0; > >> + =A0 =A0 } > >> + > >> + =A0 =A0 /* create up to max_overlays CRTCs mapping to overlays.. by > default, > >> + =A0 =A0 =A0* connect the overlays to different managers/encoders, gi= ving > >> priority > >> + =A0 =A0 =A0* to encoders connected to connectors with a detected con= nection > >> + =A0 =A0 =A0*/ > >> + =A0 =A0 int create_crtc(int i) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct omap_overlay *ovl =3D omap_dss_get_ov= erlay(i); > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct omap_overlay_manager *mgr =3D NULL; > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_crtc *crtc; > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (ovl->manager) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DBG("disconnecting %s from %= s", ovl->name, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 ovl->manager->name); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ovl->unset_manager(ovl); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 /* find next best connector, ones with detec= ted connection > >> first > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > >> + =A0 =A0 =A0 =A0 =A0 =A0 while (j < priv->num_connectors && !mgr) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (connected_connectors & (= 1 << j)) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct drm_e= ncoder * encoder =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 omap_connector_attached_encoder( > >> + > > priv->connectors[j]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (encoder)= { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 mgr =3D > > omap_encoder_get_manager(encoder); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 j++; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 /* if we couldn't find another connected con= nector, lets > >> start > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* looking at the unconnected connectors: > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > >> + =A0 =A0 =A0 =A0 =A0 =A0 while (j < 2 * priv->num_connectors && !mgr)= { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int idx =3D j - priv->num_co= nnectors; > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!(connected_connectors &= (1 << idx))) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct drm_e= ncoder * encoder =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 omap_connector_attached_encoder( > >> + > > priv->connectors[idx]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (encoder)= { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 mgr =3D > > omap_encoder_get_manager(encoder); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 j++; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (mgr) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DBG("connecting %s to %s", o= vl->name, mgr->name); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ovl->set_manager(ovl, mgr); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 crtc =3D omap_crtc_init(dev, ovl, priv->num_= crtcs); > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!crtc) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "could not= create CRTC\n"); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 priv->crtcs[priv->num_crtcs++] =3D crtc; > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 return 0; > >> + =A0 =A0 } > >> + > >> + =A0 =A0 drm_mode_config_init(dev); > >> + > >> + =A0 =A0 if (pdata) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 /* if platform data is provided by the board= file, use it > to > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* control which overlays, managers, and d= evices we own. > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < pdata->mgr_cnt; i++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 create_encoder(pdata->mgr_id= s[i]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < pdata->dev_cnt; i++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int m(struct omap_dss_device= *dssdev, void *data) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return ! str= cmp(dssdev->name, data); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct omap_dss_device *dssd= ev =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 omap_dss_fin= d_device( > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 (void *)pdata->dev_names[i], m); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!dssdev) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(dev= ->dev, "no such dssdev: %s\n", > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 pdata->dev_names[i]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 create_connector(dssdev); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 j =3D 0; > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < pdata->ovl_cnt; i++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 create_crtc(pdata->ovl_ids[i= ]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 } else { > >> + =A0 =A0 =A0 =A0 =A0 =A0 /* otherwise just grab up to CONFIG_DRM_OMAP= _NUM_CRTCS and > >> try > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0* to make educated guesses about everythi= ng else > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > >> + =A0 =A0 =A0 =A0 =A0 =A0 int max_overlays =3D min(omap_dss_get_num_ov= erlays(), > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 CONFIG_DRM_OMAP_NUM_CRTCS); > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < omap_dss_get_num_overlay_m= anagers(); i++) > { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 create_encoder(i); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 for_each_dss_dev(dssdev) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 create_connector(dssdev); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 j =3D 0; > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < max_overlays; i++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 create_crtc(i); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 } > >> + > >> + =A0 =A0 /* for now keep the mapping of CRTCs and encoders static.. */ > >> + =A0 =A0 for (i =3D 0; i < priv->num_encoders; i++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_encoder *encoder =3D priv->encode= rs[i]; > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct omap_overlay_manager *mgr =3D > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 omap_encoder= _get_manager(encoder); > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 encoder->possible_crtcs =3D 0; > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 for (j =3D 0; j < priv->num_crtcs; j++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct omap_overlay *ovl =3D > >> + > > omap_crtc_get_overlay(priv->crtcs[j]); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ovl->manager =3D=3D mgr)= { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 encoder->pos= sible_crtcs |=3D (1 << j); > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + > >> + =A0 =A0 =A0 =A0 =A0 =A0 DBG("%s: possible_crtcs=3D%08x", mgr->name, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 encoder->possible_crtcs); > >> + =A0 =A0 } > >> + > >> + =A0 =A0 dump_video_chains(); > >> + > >> + =A0 =A0 dev->mode_config.min_width =3D 640; > >> + =A0 =A0 dev->mode_config.min_height =3D 480; > >> + > >> + =A0 =A0 /* note: pvr can't currently handle dst surfaces larger than= 2k > by > >> 2k */ > >> + =A0 =A0 dev->mode_config.max_width =3D 2048; > >> + =A0 =A0 dev->mode_config.max_height =3D 2048; > >> + > >> + =A0 =A0 dev->mode_config.funcs =3D &omap_mode_config_funcs; > >> + > >> + =A0 =A0 return 0; > >> +} > > > > For code clean, how about moving create_encoder(), create_connector() > and > > create_crtc() into omap_encoder.c, omap_connector.c and omap_crtc.c > file?. > > omap_modeset_init function contains so many codes. it looks like not > good. > = > yeah, this is the way it is mainly because we are still allowing two > cases: (1) omapdrm uses all the DSS2 resources, and (2) the case of > using some platform-data to tell the omapdrm to not use all the > available resources in DSS. This is mainly a transition thing, so you > could (for example) use omapdrm to control some outputs or video > pipes, and omapfb (fbdev) or omap_vout (v4l2) for others. Have a look > at the if (pdata) { ... } else { ... } part at the later part of the > fxn. > = > I expect eventually, when we have overlay support in the DRM driver > (drm_plane stuff) and enough time has elapsed for folks to move away > from legacy fbdev/v4l2 interfaces, that this platform-data stuff can > be removed and this part greatly simplified. But I guess that will be > a couple years. For now I wanted to try and keep the ugly bits > localized in one place ;-) > = > [snip] > = > >> +} > >> + > >> +struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] =3D { > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, > >> DRM_UNLOCKED|DRM_AUTH), > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, > >> DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_GET_BASE, ioctl_get_base, > >> DRM_UNLOCKED|DRM_AUTH), > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, > >> DRM_UNLOCKED|DRM_AUTH), > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, > >> DRM_UNLOCKED|DRM_AUTH), > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, > >> DRM_UNLOCKED|DRM_AUTH), > >> + =A0 =A0 DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, > >> DRM_UNLOCKED|DRM_AUTH), > >> +}; > > > > You also should consider security issue. :) > = > = > All the ioctls do have the DRM_AUTH bit set, so any userspace process > that uses them needs to at least be authenticated with the DRM master. > I don't really see any way to avoid needing to support buffer > allocating in an authenticated client process. > = > So I think this is sufficient, but always possible that I missed > something.. > = Oh, you are right, it seems sufficient. > [snip] > >> + > >> +static void omap_framebuffer_destroy(struct drm_framebuffer *fb) > >> +{ > >> + =A0 =A0 struct drm_device *dev =3D fb->dev; > >> + =A0 =A0 struct omap_framebuffer *omap_fb =3D to_omap_framebuffer(fb); > >> + > >> + =A0 =A0 DBG("destroy: FB ID: %d (%p)", fb->base.id, fb); > >> + > >> + =A0 =A0 drm_framebuffer_cleanup(fb); > >> + > >> + =A0 =A0 if (omap_fb->vaddr) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 iounmap(omap_fb->vaddr); > >> + =A0 =A0 } > > > > You always use reserved memory for drm framebuffer.? If not so, for > > instance, any physical memory was allocated by dma api such as > dma_alloc_* > > then you should call dma_free_*. > = > currently it is always reserved memory.. I've not moved to CMA stuff yet. > = > So currently we have no vaddr in the GEM parts, and only place where > vaddr is created/mapped is in omap_framebuffer part. > = > I think this will have to change though.. partly because > dma_alloc_coherent() also allocates a vaddr. Partly because there > will be some cases where kernel side plugin code might need access to > the buffer. (Not so much for pixel buffers, but for command-stream > type buffers.) > = > Possibly I should pull this into the GEM code w/ a > omap_gem_{get,put}_vaddr() which could do the right thing depending on > where the memory for the buffer came from. Whatever I do, I don't > want to force to have a kernel virtual mapping for all pixel buffers > when it can otherwise be avoided, because I think in a generation or > two kernel address space will start being a limited resource. > = > = > >> + > >> + =A0 =A0 if (omap_gem_put_paddr(omap_fb->bo)) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "could not unmap!\n"); > >> + =A0 =A0 } > >> + > >> + =A0 =A0 if (omap_fb->bo) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 drm_gem_object_unreference_unlocked(omap_fb-= >bo); > >> + =A0 =A0 } > >> + > >> + =A0 =A0 kfree(omap_fb); > >> +} > >> + > >> +static int omap_framebuffer_dirty(struct drm_framebuffer *fb, > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_file *file_priv, unsigned flags, = unsigned color, > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_clip_rect *clips, unsigned num_cl= ips) > >> +{ > >> + =A0 =A0 int i; > >> + > >> + =A0 =A0 for (i =3D 0; i < num_clips; i++) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 omap_framebuffer_flush(fb, clips[i].x1, clip= s[i].y1, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 clips[i].x2 - clips[i].x1, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 clips[i].y2 - clips[i].y1); > >> + =A0 =A0 } > >> + > >> + =A0 =A0 return 0; > >> +} > >> + > >> +static const struct drm_framebuffer_funcs omap_framebuffer_funcs =3D { > >> + =A0 =A0 .create_handle =3D omap_framebuffer_create_handle, > >> + =A0 =A0 .destroy =3D omap_framebuffer_destroy, > >> + =A0 =A0 .dirty =3D omap_framebuffer_dirty, > >> +}; > >> + > >> +int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int > y, > >> + =A0 =A0 =A0 =A0 =A0 =A0 void **vaddr, unsigned long *paddr, int *scr= een_width) > >> +{ > >> + =A0 =A0 struct omap_framebuffer *omap_fb =3D to_omap_framebuffer(fb); > >> + =A0 =A0 int bpp =3D fb->depth / 8; > >> + =A0 =A0 unsigned long offset; > >> + > >> + =A0 =A0 offset =3D (x * bpp) + (y * fb->pitch); > >> + > >> + =A0 =A0 if (vaddr) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!omap_fb->vaddr) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 omap_fb->vaddr =3D ioremap_w= c(omap_fb->paddr, > omap_fb- > >> >size); > >> + =A0 =A0 =A0 =A0 =A0 =A0 } > >> + =A0 =A0 =A0 =A0 =A0 =A0 *vaddr =3D omap_fb->vaddr + offset; > >> + =A0 =A0 } > > > > Did you use ioremap_wc() to map physical memory(reserved memory) that > kernel > > doesn't aware of to kernel space.? if not so, the memory region mapped > to > > kernel space as 1:1, =A0this way would be faced with duplicated cache > > attribute issue mentioned by Russel King before. 1:1 mapping region is > > mapped to kernel space with cachable attribute. > = > Today the carveout memory does not have a kernel virtual mapping. So > we are ok. And I think this should still be the case w/ CMA. > = I wonder what is the carveout and sacnout memory. carvout is physically non continuous memory and scanout is physically continuous memory? > [snip] > >> + > >> +static int omap_fbdev_create(struct drm_fb_helper *helper, > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_fb_helper_surface_size *sizes) > >> +{ > >> + =A0 =A0 struct omap_fbdev *fbdev =3D to_omap_fbdev(helper); > >> + =A0 =A0 struct drm_device *dev =3D helper->dev; > >> + =A0 =A0 struct drm_framebuffer *fb; > >> + =A0 =A0 struct fb_info *fbi; > >> + =A0 =A0 struct drm_mode_fb_cmd mode_cmd =3D {0}; > >> + =A0 =A0 unsigned long paddr; > >> + =A0 =A0 void __iomem *vaddr; > >> + =A0 =A0 int size, screen_width; > >> + =A0 =A0 int ret; > >> + > >> + =A0 =A0 /* only doing ARGB32 since this is what is needed to alpha-b= lend > >> + =A0 =A0 =A0* with video overlays: > >> + =A0 =A0 =A0*/ > >> + =A0 =A0 sizes->surface_bpp =3D 32; > >> + =A0 =A0 sizes->surface_depth =3D 32; > >> + > >> + =A0 =A0 DBG("create fbdev: %dx%d@%d", sizes->surface_width, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sizes->surface_height, sizes= ->surface_bpp); > >> + > >> + =A0 =A0 mode_cmd.width =3D sizes->surface_width; > >> + =A0 =A0 mode_cmd.height =3D sizes->surface_height; > >> + > >> + =A0 =A0 mode_cmd.bpp =3D sizes->surface_bpp; > >> + =A0 =A0 mode_cmd.depth =3D sizes->surface_depth; > >> + > >> + =A0 =A0 mutex_lock(&dev->struct_mutex); > >> + > >> + =A0 =A0 fbi =3D framebuffer_alloc(0, dev->dev); > >> + =A0 =A0 if (!fbi) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "failed to allocate fb inf= o\n"); > >> + =A0 =A0 =A0 =A0 =A0 =A0 ret =3D -ENOMEM; > >> + =A0 =A0 =A0 =A0 =A0 =A0 goto fail; > >> + =A0 =A0 } > >> + > >> + =A0 =A0 DBG("fbi=3D%p, dev=3D%p", fbi, dev); > >> + > >> + =A0 =A0 fbdev->fb =3D omap_framebuffer_init(dev, &mode_cmd, NULL); > >> + =A0 =A0 if (!fbdev->fb) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 dev_err(dev->dev, "failed to allocate fb\n"); > >> + =A0 =A0 =A0 =A0 =A0 =A0 ret =3D -ENOMEM; > >> + =A0 =A0 =A0 =A0 =A0 =A0 goto fail; > > > > In case of fail, framebuffer_release should be called. > = > oh, yeah.. // TODO cleanup ;-) > = > > > >> + =A0 =A0 } > >> + > >> + =A0 =A0 fb =3D fbdev->fb; > >> + =A0 =A0 helper->fb =3D fb; > >> + =A0 =A0 helper->fbdev =3D fbi; > >> + > >> + =A0 =A0 fbi->par =3D helper; > >> + =A0 =A0 fbi->flags =3D FBINFO_DEFAULT; > >> + =A0 =A0 fbi->fbops =3D &omap_fb_ops; > >> + > >> + =A0 =A0 strcpy(fbi->fix.id, MODULE_NAME); > >> + > >> + =A0 =A0 ret =3D fb_alloc_cmap(&fbi->cmap, 256, 0); > >> + =A0 =A0 if (ret) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 ret =3D -ENOMEM; > >> + =A0 =A0 =A0 =A0 =A0 =A0 goto fail; > > > > Also, omap_framebuffer_destroy() should be called to release resource. > > > >> + =A0 =A0 } > >> + > >> + =A0 =A0 drm_fb_helper_fill_fix(fbi, fb->pitch, fb->depth); > >> + =A0 =A0 drm_fb_helper_fill_var(fbi, helper, fb->width, fb->height); > >> + > >> + =A0 =A0 size =3D omap_framebuffer_get_buffer(fb, 0, 0, > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &vaddr, &paddr, &screen_widt= h); > >> + > >> + =A0 =A0 dev->mode_config.fb_base =3D paddr; > >> + > >> + =A0 =A0 fbi->screen_base =3D vaddr; > >> + =A0 =A0 fbi->screen_size =3D size; > >> + =A0 =A0 fbi->fix.smem_start =3D paddr; > >> + =A0 =A0 fbi->fix.smem_len =3D size; > >> + > >> + =A0 =A0 DBG("par=3D%p, %dx%d", fbi->par, fbi->var.xres, fbi->var.yre= s); > >> + =A0 =A0 DBG("allocated %dx%d fb", fbdev->fb->width, fbdev->fb->heigh= t); > >> + > >> + =A0 =A0 mutex_unlock(&dev->struct_mutex); > >> + > >> + =A0 =A0 return 0; > >> + > >> +fail: > >> + =A0 =A0 mutex_unlock(&dev->struct_mutex); > >> + =A0 =A0 // TODO cleanup? > >> + =A0 =A0 return ret; > >> +} > >> + > >> +static void omap_crtc_fb_gamma_set(struct drm_crtc *crtc, > >> + =A0 =A0 =A0 =A0 =A0 =A0 u16 red, u16 green, u16 blue, int regno) > >> +{ > >> + =A0 =A0 DBG("fbdev: set gamma"); > >> +} > >> + > >> +static void omap_crtc_fb_gamma_get(struct drm_crtc *crtc, > >> + =A0 =A0 =A0 =A0 =A0 =A0 u16 *red, u16 *green, u16 *blue, int regno) > >> +{ > >> + =A0 =A0 DBG("fbdev: get gamma"); > >> +} > >> + > >> +static int omap_fbdev_probe(struct drm_fb_helper *helper, > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct drm_fb_helper_surface_size *sizes) > >> +{ > >> + =A0 =A0 int new_fb =3D 0; > >> + =A0 =A0 int ret; > >> + > >> + =A0 =A0 if (!helper->fb) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 ret =3D omap_fbdev_create(helper, sizes); > >> + =A0 =A0 =A0 =A0 =A0 =A0 if (ret) > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return ret; > >> + =A0 =A0 =A0 =A0 =A0 =A0 new_fb =3D 1; > >> + =A0 =A0 } > >> + =A0 =A0 return new_fb; > >> +} > >> + > > > > This strange code must be because of mainline code below. > > fb_probe callback of drm_fb_helper_single_fb_probe function needs return > > values of three types. :( =A0I think this mainline code should be modif= ied > > properly. > > > = > yeah > = > [snip] > >> + > >> +struct omap_gem_object { > >> + =A0 =A0 struct drm_gem_object base; > >> + > >> + =A0 =A0 uint32_t flags; > >> + > >> + =A0 =A0 /** > >> + =A0 =A0 =A0* if buffer is physically contiguous or remapped in TILER= , the > >> + =A0 =A0 =A0* OMAP_BO_DMA flag is set and the paddr is valid. > >> + =A0 =A0 =A0* > >> + =A0 =A0 =A0* Note that OMAP_BO_SCANOUT is a hint from userspace that= DMA > >> capable > >> + =A0 =A0 =A0* buffer is requested, but doesn't mean that it is. =A0Us= e the > >> + =A0 =A0 =A0* OMAP_BO_DMA flag to determine if the buffer has a DMA c= apable > >> + =A0 =A0 =A0* physical address. > >> + =A0 =A0 =A0*/ > >> + =A0 =A0 unsigned long paddr; > >> + > >> + =A0 =A0 /** > >> + =A0 =A0 =A0* Array of backing pages, if allocated. =A0Note that page= s are > never > >> + =A0 =A0 =A0* allocated for buffers originally allocated from contigu= ous > >> memory > >> + =A0 =A0 =A0* (which will have obj->filp=3D=3DNULL) > >> + =A0 =A0 =A0*/ > >> + =A0 =A0 struct page **pages; > > > > Is this array of backing pages used for physically non-continuous > memory?. > > it appears that sgx core with iommu is considered. > = > = > yes (and will be similar for 2d hw). But even in case of scanout > buffers, we can remap them into TILER (which you can think of as a > sort of IOMMU on OMAP4+). The code for this isn't in place yet, but > the intention is to > = > a) if userspace knows it will be a scannout buffer, allocate > physically contiguous to begin with.. if that fails, fall back to > dis-contiguous. > b) if we need to scan it out, but it isn't contiguous, fall back to > remapping into TILER. > = > That is a bit of over-simplification.. for tiled buffers, and buffers > for video encode/decode, these would always be allocated as pages and > remapped into TILER. > = > [sync] > >> + > >> +static inline void sync_op(struct drm_gem_object *obj, > >> + =A0 =A0 =A0 =A0 =A0 =A0 enum omap_gem_op op, bool start) > >> +{ > >> + =A0 =A0 struct omap_gem_object *omap_obj =3D to_omap_bo(obj); > >> + > >> + =A0 =A0 spin_lock(&sync_lock); > >> + > >> + =A0 =A0 if (!omap_obj->sync) { > >> + =A0 =A0 =A0 =A0 =A0 =A0 omap_obj->sync =3D kzalloc(sizeof(*omap_obj-= >sync), > >> GFP_KERNEL); > >> + =A0 =A0 } > > > > If sync_op function is called at interrupt context, use GFP_ATOMIC > instead > > of GFP_KERNEL. from what you use spin_lock/unlock here, it appears that > this > > function would be called at interrupt context. > = > yeah, that is an oversight.. I updated omap_gem_set_sync_object() but > missed this one > = > = > [snip] > >> + > >> +/* common constructor body */ > >> +static struct drm_gem_object * omap_gem_new_impl(struct drm_device > *dev, > >> + =A0 =A0 =A0 =A0 =A0 =A0 size_t size, uint32_t flags, unsigned long p= addr, struct > >> page **pages, > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct omap_gem_vm_ops *ops) > >> +{ > > > > so many arguments are used at this function. I encourage you to use > maximum > > four arguments for ARM system. > > > = > I know the reasoning for this.. although the alternative is to stick > extra param's in a struct on the stack, which roughly amounts to what > the compiler is doing for you anyways for args above the 1st four (ie. > pushing them to the stack). > = > anyways it is a static fxn so compiler has some flexibility to inline > or optimize however it sees fit.. > = > [snip] > >> diff --git a/include/linux/omap_drm.h b/include/linux/omap_drm.h > >> new file mode 100644 > >> index 0000000..81af200 > >> --- /dev/null > >> +++ b/include/linux/omap_drm.h > >> @@ -0,0 +1,191 @@ > >> +/* > >> + * linux/include/linux/omap_drm.h > >> + * > >> + * Copyright (C) 2011 Texas Instruments > >> + * Author: Rob Clark > >> + * > >> + * This program is free software; you can redistribute it and/or > modify > >> it > >> + * under the terms of the GNU General Public License version 2 as > >> published by > >> + * the Free Software Foundation. > >> + * > >> + * This program is distributed in the hope that it will be useful, but > >> WITHOUT > >> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY > or > >> + * FITNESS FOR A PARTICULAR PURPOSE. =A0See the GNU General Public > License > >> for > >> + * more details. > >> + * > >> + * You should have received a copy of the GNU General Public License > >> along with > >> + * this program. =A0If not, see . > >> + */ > >> + > >> +#ifndef __OMAP_DRM_H__ > >> +#define __OMAP_DRM_H__ > >> + > >> +#include > >> +#include > >> + > >> +#define OMAP_PARAM_CHIPSET_ID =A0 =A0 =A0 =A01 =A0 =A0 =A0 /* ie. 0x3= 430, 0x4430, etc > > */ > >> + > >> +struct drm_omap_param { > >> + =A0 =A0 uint64_t param; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* in */ > >> + =A0 =A0 uint64_t value; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* in (set_p= aram), out (get_param) > >> */ > >> +}; > >> + > >> +struct drm_omap_get_base { > >> + =A0 =A0 char plugin_name[64]; =A0 =A0 =A0 =A0 =A0 /* in */ > >> + =A0 =A0 uint32_t ioctl_base; =A0 =A0 =A0 =A0 =A0 =A0/* out */ > >> +}; > >> + > >> +#define OMAP_BO_SCANOUT =A0 =A0 =A0 =A0 =A0 =A0 =A00x00000001 =A0 =A0= =A0/* scanout capable > > (phys > >> contiguous) */ > >> +#define OMAP_BO_CACHE_MASK =A0 0x00000006 =A0 =A0 =A0/* cache type ma= sk, see > >> cache modes */ > >> +#define OMAP_BO_TILED_MASK =A0 0x00000f00 =A0 =A0 =A0/* tiled mapping= mask, see > >> tiled modes */ > >> + > >> +/* cache modes */ > >> +#define OMAP_BO_CACHED =A0 =A0 =A0 =A0 =A0 =A0 =A0 0x00000000 =A0 =A0= =A0/* default */ > >> +#define OMAP_BO_WC =A0 =A0 =A0 =A0 =A0 0x00000002 =A0 =A0 =A0/* write= -combine */ > >> +#define OMAP_BO_UNCACHED =A0 =A0 0x00000004 =A0 =A0 =A0/* strongly-or= dered > > (uncached) */ > >> + > >> +/* tiled modes */ > >> +#define OMAP_BO_TILED_8 =A0 =A0 =A0 =A0 =A0 =A0 =A00x00000100 > >> +#define OMAP_BO_TILED_16 =A0 =A0 0x00000200 > >> +#define OMAP_BO_TILED_32 =A0 =A0 0x00000300 > >> + > >> +struct drm_omap_gem_new { > >> + =A0 =A0 union { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* i= n */ > >> + =A0 =A0 =A0 =A0 =A0 =A0 uint32_t bytes; =A0 =A0 =A0 =A0 /* (for non-= tiled formats) */ > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct { > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint16_t width; > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint16_t height; > >> + =A0 =A0 =A0 =A0 =A0 =A0 } tiled; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* (= for tiled formats) */ > >> + =A0 =A0 } size; > >> + =A0 =A0 uint32_t flags; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* in */ > >> + =A0 =A0 uint64_t offset; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* out */ > >> + =A0 =A0 uint32_t handle; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* out */ > >> +}; > >> + > >> +/* mask of operations: */ > >> +enum omap_gem_op { > >> + =A0 =A0 OMAP_GEM_READ =3D 0x01, > >> + =A0 =A0 OMAP_GEM_WRITE =3D 0x02, > >> +}; > >> + > >> +struct drm_omap_gem_cpu_prep { > >> + =A0 =A0 uint32_t handle; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* buffer ha= ndle (in) */ > >> + =A0 =A0 uint32_t op; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* mask = of omap_gem_op (in) */ > >> +}; > >> + > >> +struct drm_omap_gem_cpu_fini { > >> + =A0 =A0 uint32_t handle; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* buffer ha= ndle (in) */ > >> + =A0 =A0 uint32_t op; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* mask = of omap_gem_op (in) */ > >> + =A0 =A0 /* TODO maybe here we pass down info about what regions are > touched > >> + =A0 =A0 =A0* by sw so we can be clever about cache ops? =A0For now a > > placeholder, > >> + =A0 =A0 =A0* set to zero and we just do full buffer flush.. > >> + =A0 =A0 =A0*/ > >> + =A0 =A0 uint32_t nregions; > >> +}; > >> + > >> +struct drm_omap_gem_info { > >> + =A0 =A0 uint32_t handle; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* buffer ha= ndle (in) */ > >> + =A0 =A0 uint32_t pad; > >> + =A0 =A0 uint64_t offset; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* out */ > >> +}; > >> + > >> +#define DRM_OMAP_GET_PARAM =A0 =A0 =A0 =A0 =A0 0x00 > >> +#define DRM_OMAP_SET_PARAM =A0 =A0 =A0 =A0 =A0 0x01 > >> +#define DRM_OMAP_GET_BASE =A0 =A0 =A0 =A0 =A0 =A00x02 > >> +#define DRM_OMAP_GEM_NEW =A0 =A0 =A0 =A0 =A0 =A0 0x03 > >> +#define DRM_OMAP_GEM_CPU_PREP =A0 =A0 =A0 =A00x04 > >> +#define DRM_OMAP_GEM_CPU_FINI =A0 =A0 =A0 =A00x05 > >> +#define DRM_OMAP_GEM_INFO =A0 =A00x06 > >> +#define DRM_OMAP_NUM_IOCTLS =A0 =A0 =A0 =A0 =A00x07 > >> + > >> +#define DRM_IOCTL_OMAP_GET_PARAM =A0 =A0 DRM_IOWR(DRM_COMMAND_BASE + > >> DRM_OMAP_GET_PARAM, struct drm_omap_param) > >> +#define DRM_IOCTL_OMAP_SET_PARAM =A0 =A0 DRM_IOW (DRM_COMMAND_BASE + > >> DRM_OMAP_SET_PARAM, struct drm_omap_param) > >> +#define DRM_IOCTL_OMAP_GET_BASE =A0 =A0 =A0 =A0 =A0 =A0 =A0DRM_IOWR(D= RM_COMMAND_BASE > + > >> DRM_OMAP_GET_BASE, struct drm_omap_get_base) > >> +#define DRM_IOCTL_OMAP_GEM_NEW =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_IOWR(D= RM_COMMAND_BASE + > >> DRM_OMAP_GEM_NEW, struct drm_omap_gem_new) > >> +#define DRM_IOCTL_OMAP_GEM_CPU_PREP =A0DRM_IOW (DRM_COMMAND_BASE + > >> DRM_OMAP_GEM_CPU_PREP, struct drm_omap_gem_cpu_prep) > >> +#define DRM_IOCTL_OMAP_GEM_CPU_FINI =A0DRM_IOW (DRM_COMMAND_BASE + > >> DRM_OMAP_GEM_CPU_FINI, struct drm_omap_gem_cpu_fini) > >> +#define DRM_IOCTL_OMAP_GEM_INFO =A0 =A0 =A0 =A0 =A0 =A0 =A0DRM_IOWR(D= RM_COMMAND_BASE > + > >> DRM_OMAP_GEM_INFO, struct drm_omap_gem_info) > >> + > >> +/* interface that plug-in drivers can implement */ > >> +struct omap_drm_plugin { > >> + =A0 =A0 const char *name; > >> + > >> + =A0 =A0 /* drm functions */ > >> + =A0 =A0 int (*open)(struct drm_device *dev, struct drm_file *file); > >> + =A0 =A0 int (*load)(struct drm_device *dev, unsigned long flags); > >> + =A0 =A0 int (*unload)(struct drm_device *dev); > >> + =A0 =A0 int (*release)(struct drm_device *dev, struct drm_file *file= ); > >> + > >> + =A0 =A0 struct drm_ioctl_desc *ioctls; > >> + =A0 =A0 int num_ioctls; > >> + =A0 =A0 int ioctl_base; > >> + > >> + =A0 =A0 struct list_head list; =A0/* note, this means struct can't be const.. > >> */ > >> +}; > >> + > >> +int omap_drm_register_plugin(struct omap_drm_plugin *plugin); > >> +int omap_drm_unregister_plugin(struct omap_drm_plugin *plugin); > >> + > >> +int omap_drm_register_mapper(void); > >> +void omap_drm_unregister_mapper(int id); > >> + > >> +/* external mappers should get paddr or pages when it needs the pages > >> pinned > >> + * and put when done.. > >> + */ > >> +int omap_gem_get_paddr(struct drm_gem_object *obj, > >> + =A0 =A0 =A0 =A0 =A0 =A0 unsigned long *paddr, bool remap); > >> +int omap_gem_put_paddr(struct drm_gem_object *obj); > >> +int omap_gem_get_pages(struct drm_gem_object *obj, struct page > ***pages); > >> +int omap_gem_put_pages(struct drm_gem_object *obj); > >> + > >> +uint32_t omap_gem_flags(struct drm_gem_object *obj); > >> +void * omap_gem_priv(struct drm_gem_object *obj, int mapper_id); > >> +void omap_gem_set_priv(struct drm_gem_object *obj, int mapper_id, void > >> *priv); > >> +uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj); > >> + > >> +/* for external plugin buffers wrapped as GEM object (via. > >> omap_gem_new_ext()) > >> + * a vm_ops struct can be provided to get callback notification of > >> various > >> + * events.. > >> + */ > >> +struct omap_gem_vm_ops { > >> + =A0 =A0 void (*open)(struct vm_area_struct * area); > >> + =A0 =A0 void (*close)(struct vm_area_struct * area); > >> + > >> + =A0 =A0 /* note: mmap is not expected to do anything.. it is just to > allow > >> buffer > >> + =A0 =A0 =A0* allocate to update it's own internal state > >> + =A0 =A0 =A0*/ > >> + =A0 =A0 void (*mmap)(struct file *, struct vm_area_struct *); > >> +}; > >> + > >> +struct drm_gem_object * omap_gem_new_ext(struct drm_device *dev, > >> + =A0 =A0 =A0 =A0 =A0 =A0 size_t size, uint32_t flags, unsigned long p= addr, struct > >> page **pages, > >> + =A0 =A0 =A0 =A0 =A0 =A0 struct omap_gem_vm_ops *ops); > >> +struct drm_gem_object * omap_gem_new(struct drm_device *dev, > >> + =A0 =A0 =A0 =A0 =A0 =A0 size_t size, uint32_t flags); > >> + > >> +void omap_gem_op_update(void); > >> +void omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op > op); > >> +void omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op > op); > >> +int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op); > >> +int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op, > >> + =A0 =A0 =A0 =A0 =A0 =A0 void (*fxn)(void *arg), void *arg); > >> +void omap_gem_set_sync_object(struct drm_gem_object *obj, void > *syncobj); > >> + > >> + > >> +/* optional platform data to configure the default configuration of > which > >> + * pipes/overlays/CRTCs are used.. if this is not provided, then > instead > >> the > >> + * first CONFIG_DRM_OMAP_NUM_CRTCS are used, and they are each > connected > >> to > >> + * one manager, with priority given to managers that are connected to > >> + * detected devices. =A0This should be a good default behavior for mo= st > >> cases, > >> + * but yet there still might be times when you wish to do something > >> different. > >> + */ > >> +struct omap_drm_platform_data { > >> + =A0 =A0 int ovl_cnt; > >> + =A0 =A0 const int *ovl_ids; > >> + =A0 =A0 int mgr_cnt; > >> + =A0 =A0 const int *mgr_ids; > >> + =A0 =A0 int dev_cnt; > >> + =A0 =A0 const char **dev_names; > >> +}; > >> + > >> +#endif /* __OMAP_DRM_H__ */ > >> -- > > > > Remove device specific functions from linux/include/linux/omap_drm.h and > > move them to driver folder. I was told that include/linux/*.h file > should > > contain only interfaces for user process from Dave. > = > = > fwiw, the functions in this header are already only ones used by other > kernel drivers.. everything else internal to omapdrm is already in > omap_drv.h. I'll remove these for now (see discussion about plugin > API), although when it is re-introduced they need to be in a header > accessible from other drivers. Although should maybe still be split > from what is needed by userspace? (Something like omapdrm_plugin.h?) > = > = I'm afraid I don't understand what you mean, "Although should maybe still be split from what is needed by userspace? (Something like omapdrm_plugin.h?)", could you please clarify that again? > BR, > -R > = > >> 1.7.5.4 > > > > _______________________________________________ > > dri-devel mailing list > > dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > > http://lists.freedesktop.org/mailman/listinfo/dri-devel > >