diff options
author | Steven Toth <stoth@linuxtv.org> | 2008-09-11 23:27:13 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:37:05 -0400 |
commit | d5748f1079c01c8861b05e0de7c4cda271532cb9 (patch) | |
tree | 5e79346b2b79e202389be8b5efdb437925f4175d | |
parent | ee33c525c4d09756156cd4c18e6586da900eb310 (diff) |
V4L/DVB (9000): S2API: Cleanup code that prepares tuning structures.
Signed-off-by: Steven Toth <stoth@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.c | 219 |
1 files changed, 91 insertions, 128 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 7e9cd7921314..2aaaca620033 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
@@ -1001,6 +1001,8 @@ void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parame | |||
1001 | { | 1001 | { |
1002 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 1002 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
1003 | 1003 | ||
1004 | printk("%s()\n", __FUNCTION__); | ||
1005 | |||
1004 | c->frequency = p->frequency; | 1006 | c->frequency = p->frequency; |
1005 | c->inversion = p->inversion; | 1007 | c->inversion = p->inversion; |
1006 | 1008 | ||
@@ -1029,153 +1031,114 @@ void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parame | |||
1029 | } | 1031 | } |
1030 | } | 1032 | } |
1031 | 1033 | ||
1032 | int dtv_property_cache_submit(struct dvb_frontend *fe) | 1034 | /* Ensure the cached values are set correctly in the frontend |
1035 | * legacy tuning structures, for the advanced tuning API. | ||
1036 | */ | ||
1037 | void dtv_property_legacy_params_sync(struct dvb_frontend *fe) | ||
1033 | { | 1038 | { |
1039 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
1040 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | ||
1041 | struct dvb_frontend_parameters *p = &fepriv->parameters; | ||
1034 | 1042 | ||
1035 | /* We have to do one of two things: | 1043 | printk("%s()\n", __FUNCTION__); |
1036 | * To support legacy devices using the new API we take values from | ||
1037 | * the tv_cache and generate a legacy truning structure. | ||
1038 | * | ||
1039 | * Or, | ||
1040 | * | ||
1041 | * To support advanced tuning devices with the new API we | ||
1042 | * notify the new advance driver type that a tuning operation is required | ||
1043 | * and let it pull values from the cache as is, we don't need to | ||
1044 | * pass structures. | ||
1045 | * | ||
1046 | * We'll use the modulation type to assess how this is handled. as the API | ||
1047 | * progresses we'll probably want to have a flag in dvb_frontend_ops | ||
1048 | * to allow the frontend driver to dictate how it likes to be tuned. | ||
1049 | * | ||
1050 | * Because of how this is attached to the ioctl handler for legacy support, | ||
1051 | * it's important to return an appropriate result code with atleast the following | ||
1052 | * three meanings: | ||
1053 | * < 0 = processing error | ||
1054 | * 0 = lecagy ioctl handler to submit a traditional set_frontend() call. | ||
1055 | * 1 = lecagy ioctl handler should NOT submit a traditional set_frontend() call. | ||
1056 | */ | ||
1057 | 1044 | ||
1058 | int r; | 1045 | p->frequency = c->frequency; |
1046 | p->inversion = c->inversion; | ||
1059 | 1047 | ||
1048 | switch (fe->ops.info.type) { | ||
1049 | case FE_QPSK: | ||
1050 | printk("%s() Preparing QPSK req\n", __FUNCTION__); | ||
1051 | p->u.qpsk.symbol_rate = c->symbol_rate; | ||
1052 | p->u.qpsk.fec_inner = c->fec_inner; | ||
1053 | break; | ||
1054 | case FE_QAM: | ||
1055 | printk("%s() Preparing QAM req\n", __FUNCTION__); | ||
1056 | p->u.qam.symbol_rate = c->symbol_rate; | ||
1057 | p->u.qam.fec_inner = c->fec_inner; | ||
1058 | p->u.qam.modulation = c->modulation; | ||
1059 | break; | ||
1060 | case FE_OFDM: | ||
1061 | printk("%s() Preparing OFDM req\n", __FUNCTION__); | ||
1062 | p->u.ofdm.bandwidth = c->bandwidth; | ||
1063 | p->u.ofdm.code_rate_HP = c->code_rate_HP; | ||
1064 | p->u.ofdm.code_rate_LP = c->code_rate_LP; | ||
1065 | p->u.ofdm.constellation = c->modulation; | ||
1066 | p->u.ofdm.transmission_mode = c->transmission_mode; | ||
1067 | p->u.ofdm.guard_interval = c->guard_interval; | ||
1068 | p->u.ofdm.hierarchy_information = c->hierarchy; | ||
1069 | break; | ||
1070 | case FE_ATSC: | ||
1071 | printk("%s() Preparing VSB req\n", __FUNCTION__); | ||
1072 | p->u.vsb.modulation = c->modulation; | ||
1073 | break; | ||
1074 | } | ||
1075 | } | ||
1076 | |||
1077 | /* Ensure the cached values are set correctly in the frontend | ||
1078 | * legacy tuning structures, for the legacy tuning API. | ||
1079 | */ | ||
1080 | void dtv_property_adv_params_sync(struct dvb_frontend *fe) | ||
1081 | { | ||
1060 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 1082 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
1061 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 1083 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
1062 | struct dvb_frontend_parameters p; | 1084 | struct dvb_frontend_parameters *p = &fepriv->parameters; |
1063 | 1085 | ||
1064 | printk("%s()\n", __FUNCTION__); | 1086 | printk("%s()\n", __FUNCTION__); |
1065 | 1087 | ||
1066 | /* For legacy delivery systems we don't need the delivery_system to be specified */ | 1088 | p->frequency = c->frequency; |
1067 | if(is_legacy_delivery_system(c->delivery_system)) { | 1089 | p->inversion = c->inversion; |
1068 | printk("%s() legacy, modulation = %d\n", __FUNCTION__, c->modulation); | ||
1069 | switch(c->modulation) { | ||
1070 | case QPSK: | ||
1071 | printk("%s() Preparing QPSK req\n", __FUNCTION__); | ||
1072 | p.frequency = c->frequency; | ||
1073 | p.inversion = c->inversion; | ||
1074 | p.u.qpsk.symbol_rate = c->symbol_rate; | ||
1075 | p.u.qpsk.fec_inner = c->fec_inner; | ||
1076 | memcpy(&fepriv->parameters, &p, | ||
1077 | sizeof (struct dvb_frontend_parameters)); | ||
1078 | 1090 | ||
1079 | /* Call the traditional tuning mechanisms. */ | 1091 | switch(c->modulation) { |
1092 | case _8PSK: | ||
1093 | case _16APSK: | ||
1094 | case NBC_QPSK: | ||
1095 | p->u.qpsk.symbol_rate = c->symbol_rate; | ||
1096 | p->u.qpsk.fec_inner = c->fec_inner; | ||
1097 | break; | ||
1098 | default: | ||
1099 | break; | ||
1100 | } | ||
1080 | 1101 | ||
1081 | r = 0; | 1102 | if(c->delivery_system == SYS_ISDBT) { |
1082 | break; | 1103 | /* Fake out a generic DVB-T request so we pass validation in the ioctl */ |
1083 | case QAM_16: | 1104 | p->frequency = c->frequency; |
1084 | case QAM_32: | 1105 | p->inversion = INVERSION_AUTO; |
1085 | case QAM_64: | 1106 | p->u.ofdm.constellation = QAM_AUTO; |
1086 | case QAM_128: | 1107 | p->u.ofdm.code_rate_HP = FEC_AUTO; |
1087 | case QAM_256: | 1108 | p->u.ofdm.code_rate_LP = FEC_AUTO; |
1088 | case QAM_AUTO: | 1109 | p->u.ofdm.bandwidth = BANDWIDTH_AUTO; |
1089 | printk("%s() Preparing QAM req\n", __FUNCTION__); | 1110 | p->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO; |
1090 | p.frequency = c->frequency; | 1111 | p->u.ofdm.guard_interval = GUARD_INTERVAL_AUTO; |
1091 | p.inversion = c->inversion; | 1112 | p->u.ofdm.hierarchy_information = HIERARCHY_AUTO; |
1092 | p.u.qam.symbol_rate = c->symbol_rate; | 1113 | } |
1093 | p.u.vsb.modulation = c->modulation; | 1114 | } |
1094 | printk("%s() frequency = %d\n", __FUNCTION__, p.frequency); | ||
1095 | printk("%s() QAM = %d\n", __FUNCTION__, p.u.vsb.modulation); | ||
1096 | memcpy(&fepriv->parameters, &p, | ||
1097 | sizeof (struct dvb_frontend_parameters)); | ||
1098 | 1115 | ||
1099 | /* At this point we're fully formed for backwards | 1116 | void dtv_property_cache_submit(struct dvb_frontend *fe) |
1100 | * compatability and we need to return this | 1117 | { |
1101 | * via the ioctl handler as SET_FRONTEND (arg). | 1118 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
1102 | * We've already patched the new values into the | ||
1103 | * frontends tuning structures so the ioctl code just | ||
1104 | * continues as if a legacy tune structure was passed | ||
1105 | * from userspace. | ||
1106 | */ | ||
1107 | 1119 | ||
1108 | r = 0; | 1120 | printk("%s()\n", __FUNCTION__); |
1109 | break; | ||
1110 | case VSB_8: | ||
1111 | case VSB_16: | ||
1112 | printk("%s() Preparing VSB req\n", __FUNCTION__); | ||
1113 | p.frequency = c->frequency; | ||
1114 | p.u.vsb.modulation = c->modulation; | ||
1115 | memcpy(&fepriv->parameters, &p, | ||
1116 | sizeof (struct dvb_frontend_parameters)); | ||
1117 | 1121 | ||
1118 | /* Call the traditional tuning mechanisms. */ | 1122 | /* For legacy delivery systems we don't need the delivery_system to |
1123 | * be specified, but we populate the older structures from the cache | ||
1124 | * so we can call set_frontend on older drivers. | ||
1125 | */ | ||
1126 | if(is_legacy_delivery_system(c->delivery_system)) { | ||
1127 | |||
1128 | printk("%s() legacy, modulation = %d\n", __FUNCTION__, c->modulation); | ||
1129 | dtv_property_legacy_params_sync(fe); | ||
1119 | 1130 | ||
1120 | r = 0; | ||
1121 | break; | ||
1122 | /* TODO: Add any missing modulation types */ | ||
1123 | default: | ||
1124 | r = -1; | ||
1125 | } | ||
1126 | } else { | 1131 | } else { |
1132 | printk("%s() adv, modulation = %d\n", __FUNCTION__, c->modulation); | ||
1133 | |||
1127 | /* For advanced delivery systems / modulation types ... | 1134 | /* For advanced delivery systems / modulation types ... |
1128 | * we seed the lecacy dvb_frontend_parameters structure | 1135 | * we seed the lecacy dvb_frontend_parameters structure |
1129 | * so that the sanity checking code later in the IOCTL processing | 1136 | * so that the sanity checking code later in the IOCTL processing |
1130 | * can validate our basic frequency ranges, symbolrates, modulation | 1137 | * can validate our basic frequency ranges, symbolrates, modulation |
1131 | * etc. | 1138 | * etc. |
1132 | */ | 1139 | */ |
1133 | r = -1; | 1140 | dtv_property_adv_params_sync(fe); |
1134 | |||
1135 | switch(c->modulation) { | ||
1136 | case _8PSK: | ||
1137 | case _16APSK: | ||
1138 | case NBC_QPSK: | ||
1139 | /* Just post a notification to the demod driver and let it pull | ||
1140 | * the specific values it wants from its dtv_property_cache. | ||
1141 | * It can decide how best to use those parameters. | ||
1142 | * IOCTL will call set_frontend (by default) due to zigzag | ||
1143 | * support etc. | ||
1144 | */ | ||
1145 | if (fe->ops.set_params) | ||
1146 | r = fe->ops.set_params(fe); | ||
1147 | |||
1148 | p.frequency = c->frequency; | ||
1149 | p.inversion = c->inversion; | ||
1150 | p.u.qpsk.symbol_rate = c->symbol_rate; | ||
1151 | p.u.qpsk.fec_inner = c->fec_inner; | ||
1152 | memcpy(&fepriv->parameters, &p, | ||
1153 | sizeof (struct dvb_frontend_parameters)); | ||
1154 | |||
1155 | r = 0; | ||
1156 | break; | ||
1157 | default: | ||
1158 | r = -1; | ||
1159 | } | ||
1160 | |||
1161 | if(c->delivery_system == SYS_ISDBT) { | ||
1162 | /* Fake out a generic DVB-T request so we pass validation in the ioctl */ | ||
1163 | p.frequency = c->frequency; | ||
1164 | p.inversion = INVERSION_AUTO; | ||
1165 | p.u.ofdm.constellation = QAM_AUTO; | ||
1166 | p.u.ofdm.code_rate_HP = FEC_AUTO; | ||
1167 | p.u.ofdm.code_rate_LP = FEC_AUTO; | ||
1168 | p.u.ofdm.bandwidth = BANDWIDTH_AUTO; | ||
1169 | p.u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO; | ||
1170 | p.u.ofdm.guard_interval = GUARD_INTERVAL_AUTO; | ||
1171 | p.u.ofdm.hierarchy_information = HIERARCHY_AUTO; | ||
1172 | memcpy(&fepriv->parameters, &p, | ||
1173 | sizeof (struct dvb_frontend_parameters)); | ||
1174 | |||
1175 | r = 0; | ||
1176 | } | ||
1177 | } | 1141 | } |
1178 | return r; | ||
1179 | } | 1142 | } |
1180 | 1143 | ||
1181 | static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, | 1144 | static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, |
@@ -1203,13 +1166,13 @@ int dtv_property_process(struct dvb_frontend *fe, struct dtv_property *tvp, | |||
1203 | break; | 1166 | break; |
1204 | case DTV_TUNE: | 1167 | case DTV_TUNE: |
1205 | /* interpret the cache of data, build either a traditional frontend | 1168 | /* interpret the cache of data, build either a traditional frontend |
1206 | * tunerequest and submit it to a subset of the ioctl handler, | 1169 | * tunerequest so we can pass validation in the FE_SET_FRONTEND |
1207 | * or, call a new undefined method on the frontend to deal with | 1170 | * ioctl. |
1208 | * all new tune requests. | ||
1209 | */ | 1171 | */ |
1210 | fe->dtv_property_cache.state = tvp->cmd; | 1172 | fe->dtv_property_cache.state = tvp->cmd; |
1211 | printk("%s() Finalised property cache\n", __FUNCTION__); | 1173 | printk("%s() Finalised property cache\n", __FUNCTION__); |
1212 | r |= dtv_property_cache_submit(fe); | 1174 | dtv_property_cache_submit(fe); |
1175 | |||
1213 | r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, | 1176 | r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND, |
1214 | &fepriv->parameters); | 1177 | &fepriv->parameters); |
1215 | break; | 1178 | break; |