Re: Help - trying to get multiproto TT03200 driver working via old API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For what it is worth, here is my change to dvb_frontend.c
I would welcome comments on whether I am going about this the right way, or whether I am wasting my time. I will start testing with this tomorrow.

static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
            unsigned int cmd, void *parg)
{
...
    case FE_SET_FRONTEND: {
        struct dvb_frontend_tune_settings fetunesettings;

        if (dvb_frontend_check_parameters(fe, parg) < 0) {
            err = -EINVAL;
            break;
        }

        memcpy(&fepriv->parameters, parg, sizeof (struct dvb_frontend_parameters));       
        if (fe->legacy) {
            memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings));
            memcpy(&fetunesettings.parameters, parg, sizeof (struct dvb_frontend_parameters));

            /* force auto frequency inversion if requested */
            if (dvb_force_auto_inversion) {
                fepriv->parameters.inversion = INVERSION_AUTO;
                fetunesettings.parameters.inversion = INVERSION_AUTO;
            }
            if (fe->ops.info.type == FE_OFDM) {
                /* without hierarchical coding code_rate_LP is irrelevant,
                 * so we tolerate the otherwise invalid FEC_NONE setting */
                if (fepriv->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE &&
                    fepriv->parameters.u.ofdm.code_rate_LP == FEC_NONE)
                    fepriv->parameters.u.ofdm.code_rate_LP = FEC_AUTO;
            }
        } else {
            if (olddrv_to_newapi(fe, &fepriv->fe_params, &fepriv->parameters, fe->ops.info.type) == -EINVAL)
                printk("%s: ERROR !!! Converting Old parameters --> New parameters\n", __func__);
            memset(&fetunesettings, 0, sizeof (struct dvb_frontend_tune_settings));
            memcpy(&fetunesettings.fe_params, &fepriv->fe_params, sizeof (struct dvbfe_params));

            /* Request the search algorithm to search    */
            fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;

            /* force auto frequency inversion if requested */
            if (dvb_force_auto_inversion) {
                fepriv->fe_params.inversion = DVBFE_INVERSION_AUTO;
                fetunesettings.fe_params.inversion = DVBFE_INVERSION_AUTO;
            }

            if (fe->ops.get_delsys) {
                enum dvbfe_delsys delsys;
                fe->ops.get_delsys(fe, &delsys);
                if ((delsys == DVBFE_DELSYS_DVBT) ||
                    (delsys == DVBFE_DELSYS_DVBH)) {

                    /* without hierachical coding code_rate_LP is irrelevant,
                     * so we tolerate the otherwise invalid FEC_NONE setting */
                    if (fepriv->fe_params.delsys.dvbt.hierarchy == DVBFE_HIERARCHY_OFF &&
                        fepriv->fe_params.delsys.dvbt.code_rate_LP == DVBFE_FEC_NONE)

                        fepriv->fe_params.delsys.dvbt.code_rate_LP = DVBFE_FEC_AUTO;
                }
            }
        }

        /* get frontend-specific tuning settings */
        if (fe->ops.get_tune_settings && (fe->ops.get_tune_settings(fe, &fetunesettings) == 0)) {
            fepriv->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
            fepriv->max_drift = fetunesettings.max_drift;
            fepriv->step_size = fetunesettings.step_size;
        } else {
            /* default values */
            switch(fe->ops.info.type) {
            case FE_QPSK:
                fepriv->min_delay = HZ/20;
                fepriv->step_size = fepriv->parameters.u.qpsk.symbol_rate / 16000;
                fepriv->max_drift = fepriv->parameters.u.qpsk.symbol_rate / 2000;
                break;

            case FE_QAM:
                fepriv->min_delay = HZ/20;
                fepriv->step_size = 0; /* no zigzag */
                fepriv->max_drift = 0;
                break;

            case FE_OFDM:
                fepriv->min_delay = HZ/20;
                fepriv->step_size = fe->ops.info.frequency_stepsize * 2;
                fepriv->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
                break;
            case FE_ATSC:
                fepriv->min_delay = HZ/20;
                fepriv->step_size = 0;
                fepriv->max_drift = 0;
                break;
            }
        }
        if (dvb_override_tune_delay > 0)
            fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000;

        fepriv->state = FESTATE_RETUNE;
        dvb_frontend_wakeup(fe);
        dvb_frontend_add_event(fe, 0);
        fepriv->status = 0;
        err = 0;
        break;
    }

...

    case FE_GET_FRONTEND:
        if (fe->legacy) {
            if (fe->ops.get_frontend) {
                memcpy (parg, &fepriv->parameters, sizeof (struct dvb_frontend_parameters));
                err = fe->ops.get_frontend(fe, (struct dvb_frontend_parameters*) parg);
            }
        } else {
            if (fe->ops.get_params) {
                struct dvbfe_params temporary_params;
                memcpy(&temporary_params, &fepriv->fe_params, sizeof (struct dvbfe_params));
                err = fe->ops.get_params(fe, &temporary_params);
                if (newapi_to_olddrv(&temporary_params, (struct dvb_frontend_parameters*) parg, fepriv->delsys)  == -EINVAL)
                    printk("%s: ERROR !!! Converting New parameters --> Old parameters\n", __func__);
            }
        }
        break;

Roger

Roger James wrote:
Hmm,

Looking at this further. I think the patch will break compatibility with all the old non multi-protocol drivers. That is the last thing I want to do. What is needed is something that converts to the new api only when needed. I wonder if there is a simple test to see if the underlying driver is old or new.

I am somewhat out of my depth here!

I am beginning to think I should have bought a DVB-S card after all. Especially as none of the services I want to view are S2!

Roger

Roger James wrote:
Thanks,

Looking at the patch diff is does not appear too complex. I will try and see if I can work out a minimal patch against the current tree. If not I will fall back on your suggestion. I think it would be desireable if what makes it into the kernel supports new cards been driven in the old way.

Roger

Jelle De Loecker wrote:
I feel your pain, patch-hell isn't a fun place to be :)

Lots of people make guides on how to fix something, unfortunately they forget that trees grow, and a patch that works today probably won't work tomorrow.
Thankfully you can check out different revisions!

I'd sugest you try this patch out on manu's original multiproto tree, revision number 7213 (that was the last update, in april, before she made her patch)

hg clone -r 7213 http://jusst.de/hg/multiproto

Met vriendelijke groeten,

Jelle De Loecker
Kipdola Studios - Tomberg


Roger James schreef:
I am have been trying to get gnutv to drive the TT-3200 driver using the old api (gnutv uses dvb-apps/lib which is not patched for multi proto). After much head scratching I realised that the fialure of the driver to get lock when exercised in this way seemed to be related to DVBFE_ALGO_SEARCH_AGAIN not being set when the FE_SET_FRONTEND ioctl path was followed rather than than the DVBFE_SET_PARAMS path. A search of the list revealed that Anssi Hannula had already worked this out and made a patch (http://www.spinics.net/lists/linux-dvb/msg26174.html). However it does not look like this patch has made it into the code that Manu has asked to be merged into the kernel. Does this mean that the merged code will not be compatible with applications such as gnutv which use dvb-apps/lib or other apps which use the old api?

To help me carry on with my testing. Is there as version of Anssi's patch that can be applied against a recent clone of Manu's code.

I apologise if this has been visited before; but I am finding it virtually impossible to unravel the complexities of what patch matches what tree.

Help

Roger

_______________________________________________ linux-dvb mailing list linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb


_______________________________________________ linux-dvb mailing list linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb


_______________________________________________ linux-dvb mailing list linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux